clawvault 2.6.1 → 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-HIHOUSXS.js → chunk-E7MFQB6D.js} +59 -18
- 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-T76H47ZS.js → chunk-H34S76MB.js} +6 -6
- package/dist/{chunk-R6SXNSFD.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-3BTHWPMB.js → chunk-SJSFRIYS.js} +1 -1
- package/dist/{chunk-4VRIMU4O.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 +10 -9
- 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-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/chunk-TLGBDTYT.js +0 -33
- 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,560 @@
|
|
|
1
|
+
// src/plugin/templates.ts
|
|
2
|
+
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
var DEFAULT_SCHEMAS = [
|
|
5
|
+
{
|
|
6
|
+
primitive: "memory_event",
|
|
7
|
+
description: "General memory event for observations",
|
|
8
|
+
fields: {
|
|
9
|
+
type: { type: "string", required: true, default: "memory_event" },
|
|
10
|
+
status: { type: "string", required: true, default: "recorded", enum: ["recorded", "superseded", "corrected"] },
|
|
11
|
+
created: { type: "datetime", required: true, default: "{{datetime}}" },
|
|
12
|
+
observed_at: { type: "datetime", required: true },
|
|
13
|
+
source: { type: "string", required: true, enum: ["openclaw", "claude-code", "replay", "manual-correction"] },
|
|
14
|
+
summary: { type: "string", required: true },
|
|
15
|
+
confidence: { type: "number" },
|
|
16
|
+
importance: { type: "number" }
|
|
17
|
+
},
|
|
18
|
+
keywords: ["preference", "like", "hate", "want", "need", "always", "never", "remember", "note"]
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
primitive: "person",
|
|
22
|
+
description: "People and relationship notes",
|
|
23
|
+
fields: {
|
|
24
|
+
title: { type: "string", required: true, default: "{{title}}" },
|
|
25
|
+
date: { type: "date", required: true, default: "{{date}}" },
|
|
26
|
+
type: { type: "string", required: true, default: "person" },
|
|
27
|
+
relationship: { type: "string", default: "contact" }
|
|
28
|
+
},
|
|
29
|
+
keywords: ["person", "contact", "colleague", "friend", "works at", "lives in", "email", "phone", "name is"]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
primitive: "decision",
|
|
33
|
+
description: "Decision records",
|
|
34
|
+
fields: {
|
|
35
|
+
title: { type: "string", required: true, default: "{{title}}" },
|
|
36
|
+
date: { type: "date", required: true, default: "{{date}}" },
|
|
37
|
+
type: { type: "string", required: true, default: "decision" },
|
|
38
|
+
status: { type: "string", default: "decided", enum: ["proposed", "decided", "superseded"] }
|
|
39
|
+
},
|
|
40
|
+
keywords: ["decided", "decision", "chose", "will use", "go with", "ship", "approved", "rejected"]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
primitive: "task",
|
|
44
|
+
description: "Task primitives",
|
|
45
|
+
fields: {
|
|
46
|
+
status: { type: "string", required: true, default: "open", enum: ["open", "in-progress", "blocked", "done"] },
|
|
47
|
+
created: { type: "datetime", required: true, default: "{{datetime}}" },
|
|
48
|
+
updated: { type: "datetime", required: true, default: "{{datetime}}" },
|
|
49
|
+
priority: { type: "string", enum: ["critical", "high", "medium", "low"] },
|
|
50
|
+
due: { type: "date" }
|
|
51
|
+
},
|
|
52
|
+
keywords: ["task", "todo", "need to", "should", "must", "deadline", "due", "by tomorrow", "by tonight"]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
primitive: "project",
|
|
56
|
+
description: "Project definition documents",
|
|
57
|
+
fields: {
|
|
58
|
+
type: { type: "string", required: true, default: "project" },
|
|
59
|
+
status: { type: "string", required: true, default: "active", enum: ["active", "paused", "completed", "archived"] },
|
|
60
|
+
created: { type: "datetime", required: true, default: "{{datetime}}" },
|
|
61
|
+
updated: { type: "datetime", required: true, default: "{{datetime}}" }
|
|
62
|
+
},
|
|
63
|
+
keywords: ["project", "initiative", "working on", "building", "developing"]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
primitive: "lesson",
|
|
67
|
+
description: "Lessons learned",
|
|
68
|
+
fields: {
|
|
69
|
+
title: { type: "string", required: true, default: "{{title}}" },
|
|
70
|
+
date: { type: "date", required: true, default: "{{date}}" },
|
|
71
|
+
type: { type: "string", required: true, default: "lesson" }
|
|
72
|
+
},
|
|
73
|
+
keywords: ["learned", "lesson", "insight", "realized", "discovered", "found out"]
|
|
74
|
+
}
|
|
75
|
+
];
|
|
76
|
+
function parseYamlFrontmatter(content) {
|
|
77
|
+
const match = content.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
|
|
78
|
+
if (!match) return null;
|
|
79
|
+
const yamlContent = match[1];
|
|
80
|
+
const body = match[2];
|
|
81
|
+
try {
|
|
82
|
+
const frontmatter = parseSimpleYaml(yamlContent);
|
|
83
|
+
return { frontmatter, body };
|
|
84
|
+
} catch {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function parseSimpleYaml(yaml) {
|
|
89
|
+
const result = {};
|
|
90
|
+
const lines = yaml.split("\n");
|
|
91
|
+
let currentKey = "";
|
|
92
|
+
let currentIndent = 0;
|
|
93
|
+
let nestedObject = null;
|
|
94
|
+
let nestedKey = "";
|
|
95
|
+
for (const line of lines) {
|
|
96
|
+
if (!line.trim() || line.trim().startsWith("#")) continue;
|
|
97
|
+
const indent = line.search(/\S/);
|
|
98
|
+
const trimmed = line.trim();
|
|
99
|
+
if (trimmed.startsWith("- ")) {
|
|
100
|
+
const value = trimmed.slice(2).trim();
|
|
101
|
+
if (nestedObject && nestedKey) {
|
|
102
|
+
const arr = nestedObject[nestedKey];
|
|
103
|
+
if (Array.isArray(arr)) {
|
|
104
|
+
arr.push(parseYamlValue(value));
|
|
105
|
+
}
|
|
106
|
+
} else if (currentKey && result[currentKey]) {
|
|
107
|
+
const arr = result[currentKey];
|
|
108
|
+
if (Array.isArray(arr)) {
|
|
109
|
+
arr.push(parseYamlValue(value));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const colonIndex = trimmed.indexOf(":");
|
|
115
|
+
if (colonIndex === -1) continue;
|
|
116
|
+
const key = trimmed.slice(0, colonIndex).trim();
|
|
117
|
+
const valueStr = trimmed.slice(colonIndex + 1).trim();
|
|
118
|
+
if (indent === 0) {
|
|
119
|
+
if (valueStr === "" || valueStr === "|" || valueStr === ">") {
|
|
120
|
+
if (key === "fields") {
|
|
121
|
+
result[key] = {};
|
|
122
|
+
nestedObject = result[key];
|
|
123
|
+
nestedKey = "";
|
|
124
|
+
} else {
|
|
125
|
+
result[key] = {};
|
|
126
|
+
nestedObject = null;
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
result[key] = parseYamlValue(valueStr);
|
|
130
|
+
nestedObject = null;
|
|
131
|
+
}
|
|
132
|
+
currentKey = key;
|
|
133
|
+
currentIndent = indent;
|
|
134
|
+
} else if (nestedObject && indent > 0) {
|
|
135
|
+
if (valueStr === "" || valueStr === "|" || valueStr === ">") {
|
|
136
|
+
nestedObject[key] = {};
|
|
137
|
+
nestedKey = key;
|
|
138
|
+
} else if (nestedKey && indent > 2) {
|
|
139
|
+
const fieldObj = nestedObject[nestedKey];
|
|
140
|
+
if (fieldObj) {
|
|
141
|
+
if (key === "enum") {
|
|
142
|
+
fieldObj[key] = [];
|
|
143
|
+
} else {
|
|
144
|
+
fieldObj[key] = parseYamlValue(valueStr);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
nestedObject[key] = parseYamlValue(valueStr);
|
|
149
|
+
nestedKey = key;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return result;
|
|
154
|
+
}
|
|
155
|
+
function parseYamlValue(value) {
|
|
156
|
+
if (value === "" || value === "null" || value === "~") return null;
|
|
157
|
+
if (value === "true") return true;
|
|
158
|
+
if (value === "false") return false;
|
|
159
|
+
if (/^-?\d+$/.test(value)) return parseInt(value, 10);
|
|
160
|
+
if (/^-?\d+\.\d+$/.test(value)) return parseFloat(value);
|
|
161
|
+
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
|
|
162
|
+
return value.slice(1, -1);
|
|
163
|
+
}
|
|
164
|
+
return value;
|
|
165
|
+
}
|
|
166
|
+
var registry = null;
|
|
167
|
+
function getTemplateRegistry() {
|
|
168
|
+
if (!registry) {
|
|
169
|
+
registry = {
|
|
170
|
+
schemas: /* @__PURE__ */ new Map(),
|
|
171
|
+
keywordIndex: /* @__PURE__ */ new Map(),
|
|
172
|
+
initialized: false
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
return registry;
|
|
176
|
+
}
|
|
177
|
+
function initializeTemplateRegistry(templatesDir) {
|
|
178
|
+
const reg = getTemplateRegistry();
|
|
179
|
+
if (reg.initialized) {
|
|
180
|
+
return reg;
|
|
181
|
+
}
|
|
182
|
+
const dirsToTry = templatesDir ? [templatesDir] : [
|
|
183
|
+
join(process.cwd(), "templates"),
|
|
184
|
+
join(process.cwd(), "..", "..", "templates"),
|
|
185
|
+
join(process.env.HOME ?? ".", "clawvault", "templates"),
|
|
186
|
+
join(process.env.HOME ?? ".", ".clawvault", "templates")
|
|
187
|
+
];
|
|
188
|
+
let loaded = false;
|
|
189
|
+
for (const dir of dirsToTry) {
|
|
190
|
+
if (existsSync(dir)) {
|
|
191
|
+
try {
|
|
192
|
+
loadTemplatesFromDirectory(dir, reg);
|
|
193
|
+
loaded = true;
|
|
194
|
+
break;
|
|
195
|
+
} catch {
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (!loaded || reg.schemas.size === 0) {
|
|
200
|
+
loadDefaultSchemas(reg);
|
|
201
|
+
}
|
|
202
|
+
buildKeywordIndex(reg);
|
|
203
|
+
reg.initialized = true;
|
|
204
|
+
return reg;
|
|
205
|
+
}
|
|
206
|
+
function loadTemplatesFromDirectory(dir, reg) {
|
|
207
|
+
const files = readdirSync(dir).filter((f) => f.endsWith(".md"));
|
|
208
|
+
for (const file of files) {
|
|
209
|
+
const filePath = join(dir, file);
|
|
210
|
+
const content = readFileSync(filePath, "utf-8");
|
|
211
|
+
const parsed = parseYamlFrontmatter(content);
|
|
212
|
+
if (!parsed?.frontmatter?.primitive) continue;
|
|
213
|
+
const schema = convertFrontmatterToSchema(parsed.frontmatter, parsed.body);
|
|
214
|
+
if (schema) {
|
|
215
|
+
reg.schemas.set(schema.primitive, schema);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function convertFrontmatterToSchema(fm, body) {
|
|
220
|
+
const primitive = fm.primitive;
|
|
221
|
+
if (!primitive) return null;
|
|
222
|
+
const fields = {};
|
|
223
|
+
const fmFields = fm.fields;
|
|
224
|
+
if (fmFields) {
|
|
225
|
+
for (const [fieldName, fieldDef] of Object.entries(fmFields)) {
|
|
226
|
+
if (typeof fieldDef === "object" && fieldDef !== null) {
|
|
227
|
+
const def = fieldDef;
|
|
228
|
+
fields[fieldName] = {
|
|
229
|
+
type: def.type || "string",
|
|
230
|
+
required: def.required,
|
|
231
|
+
default: def.default,
|
|
232
|
+
enum: def.enum,
|
|
233
|
+
description: def.description
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
const keywords = extractKeywordsFromSchema(primitive, fm.description, fields);
|
|
239
|
+
return {
|
|
240
|
+
primitive,
|
|
241
|
+
description: fm.description,
|
|
242
|
+
fields,
|
|
243
|
+
bodyTemplate: body,
|
|
244
|
+
keywords
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
function extractKeywordsFromSchema(primitive, description, fields) {
|
|
248
|
+
const keywords = [primitive];
|
|
249
|
+
keywords.push(primitive.replace(/-/g, " "));
|
|
250
|
+
keywords.push(primitive.replace(/_/g, " "));
|
|
251
|
+
switch (primitive) {
|
|
252
|
+
case "memory_event":
|
|
253
|
+
keywords.push("preference", "like", "hate", "want", "need", "always", "never", "remember", "note");
|
|
254
|
+
break;
|
|
255
|
+
case "person":
|
|
256
|
+
keywords.push("person", "contact", "colleague", "friend", "works at", "lives in", "email", "phone", "name is");
|
|
257
|
+
break;
|
|
258
|
+
case "decision":
|
|
259
|
+
keywords.push("decided", "decision", "chose", "will use", "go with", "ship", "approved", "rejected");
|
|
260
|
+
break;
|
|
261
|
+
case "task":
|
|
262
|
+
keywords.push("task", "todo", "need to", "should", "must", "deadline", "due", "by tomorrow", "by tonight");
|
|
263
|
+
break;
|
|
264
|
+
case "project":
|
|
265
|
+
keywords.push("project", "initiative", "working on", "building", "developing");
|
|
266
|
+
break;
|
|
267
|
+
case "lesson":
|
|
268
|
+
keywords.push("learned", "lesson", "insight", "realized", "discovered", "found out");
|
|
269
|
+
break;
|
|
270
|
+
case "trigger":
|
|
271
|
+
keywords.push("trigger", "schedule", "cron", "automated", "recurring");
|
|
272
|
+
break;
|
|
273
|
+
case "run":
|
|
274
|
+
keywords.push("run", "execution", "job", "started", "finished", "failed");
|
|
275
|
+
break;
|
|
276
|
+
case "checkpoint":
|
|
277
|
+
keywords.push("checkpoint", "snapshot", "state", "progress");
|
|
278
|
+
break;
|
|
279
|
+
case "handoff":
|
|
280
|
+
keywords.push("handoff", "transition", "context", "resume");
|
|
281
|
+
break;
|
|
282
|
+
case "daily-note":
|
|
283
|
+
case "daily":
|
|
284
|
+
keywords.push("daily", "today", "journal", "log");
|
|
285
|
+
break;
|
|
286
|
+
case "party":
|
|
287
|
+
keywords.push("party", "agent", "human", "runtime", "service");
|
|
288
|
+
break;
|
|
289
|
+
case "workspace":
|
|
290
|
+
keywords.push("workspace", "shared", "collaboration");
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
if (fields.status?.enum) {
|
|
294
|
+
keywords.push(...fields.status.enum);
|
|
295
|
+
}
|
|
296
|
+
return [...new Set(keywords)];
|
|
297
|
+
}
|
|
298
|
+
function loadDefaultSchemas(reg) {
|
|
299
|
+
for (const schema of DEFAULT_SCHEMAS) {
|
|
300
|
+
reg.schemas.set(schema.primitive, schema);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
function buildKeywordIndex(reg) {
|
|
304
|
+
reg.keywordIndex.clear();
|
|
305
|
+
for (const [primitive, schema] of reg.schemas) {
|
|
306
|
+
const keywords = schema.keywords ?? [primitive];
|
|
307
|
+
for (const keyword of keywords) {
|
|
308
|
+
const lower = keyword.toLowerCase();
|
|
309
|
+
const existing = reg.keywordIndex.get(lower) ?? [];
|
|
310
|
+
if (!existing.includes(primitive)) {
|
|
311
|
+
existing.push(primitive);
|
|
312
|
+
}
|
|
313
|
+
reg.keywordIndex.set(lower, existing);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
function classifyText(text) {
|
|
318
|
+
const reg = getTemplateRegistry();
|
|
319
|
+
if (!reg.initialized) {
|
|
320
|
+
initializeTemplateRegistry();
|
|
321
|
+
}
|
|
322
|
+
const lower = text.toLowerCase();
|
|
323
|
+
const scores = /* @__PURE__ */ new Map();
|
|
324
|
+
for (const [keyword, primitives] of reg.keywordIndex) {
|
|
325
|
+
if (lower.includes(keyword)) {
|
|
326
|
+
for (const primitive of primitives) {
|
|
327
|
+
const existing = scores.get(primitive) ?? { score: 0, keywords: [] };
|
|
328
|
+
existing.score += getKeywordWeight(keyword, primitive);
|
|
329
|
+
existing.keywords.push(keyword);
|
|
330
|
+
scores.set(primitive, existing);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
applyPatternScoring(lower, scores);
|
|
335
|
+
let bestPrimitive = "memory_event";
|
|
336
|
+
let bestScore = 0;
|
|
337
|
+
let bestKeywords = [];
|
|
338
|
+
for (const [primitive, data] of scores) {
|
|
339
|
+
if (data.score > bestScore) {
|
|
340
|
+
bestScore = data.score;
|
|
341
|
+
bestPrimitive = primitive;
|
|
342
|
+
bestKeywords = data.keywords;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
const confidence = Math.min(1, bestScore / 5);
|
|
346
|
+
return {
|
|
347
|
+
primitiveType: bestPrimitive,
|
|
348
|
+
confidence,
|
|
349
|
+
matchedKeywords: [...new Set(bestKeywords)]
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
function getKeywordWeight(keyword, primitive) {
|
|
353
|
+
if (keyword === primitive || keyword === primitive.replace(/-/g, " ")) {
|
|
354
|
+
return 3;
|
|
355
|
+
}
|
|
356
|
+
const strongIndicators = {
|
|
357
|
+
person: ["works at", "lives in", "email", "phone", "name is"],
|
|
358
|
+
decision: ["decided", "chose", "will use", "go with"],
|
|
359
|
+
task: ["deadline", "due", "by tomorrow", "by tonight"],
|
|
360
|
+
memory_event: ["preference", "remember", "note"]
|
|
361
|
+
};
|
|
362
|
+
if (strongIndicators[primitive]?.includes(keyword)) {
|
|
363
|
+
return 2;
|
|
364
|
+
}
|
|
365
|
+
return 1;
|
|
366
|
+
}
|
|
367
|
+
function applyPatternScoring(text, scores) {
|
|
368
|
+
if (/\b(my .+ is|his .+ is|her .+ is|their .+ is)\b/i.test(text)) {
|
|
369
|
+
const existing = scores.get("person") ?? { score: 0, keywords: [] };
|
|
370
|
+
existing.score += 2;
|
|
371
|
+
existing.keywords.push("possessive pattern");
|
|
372
|
+
scores.set("person", existing);
|
|
373
|
+
}
|
|
374
|
+
if (/[\w.-]+@[\w.-]+\.\w+|\+\d{10,}/.test(text)) {
|
|
375
|
+
const existing = scores.get("person") ?? { score: 0, keywords: [] };
|
|
376
|
+
existing.score += 3;
|
|
377
|
+
existing.keywords.push("contact info");
|
|
378
|
+
scores.set("person", existing);
|
|
379
|
+
}
|
|
380
|
+
if (/\b(i prefer|i like|i hate|i love|i want|i need|i always|i never|don't like|dont like)\b/i.test(text)) {
|
|
381
|
+
const existing = scores.get("memory_event") ?? { score: 0, keywords: [] };
|
|
382
|
+
existing.score += 3;
|
|
383
|
+
existing.keywords.push("preference pattern");
|
|
384
|
+
scores.set("memory_event", existing);
|
|
385
|
+
}
|
|
386
|
+
if (/\b(we decided|let's go with|we're going|i chose|we'll use|ship it|do it)\b/i.test(text)) {
|
|
387
|
+
const existing = scores.get("decision") ?? { score: 0, keywords: [] };
|
|
388
|
+
existing.score += 3;
|
|
389
|
+
existing.keywords.push("decision pattern");
|
|
390
|
+
scores.set("decision", existing);
|
|
391
|
+
}
|
|
392
|
+
if (/\b(by tonight|by tomorrow|deadline|due date|by end of|ship by|ready by)\b/i.test(text)) {
|
|
393
|
+
const existing = scores.get("task") ?? { score: 0, keywords: [] };
|
|
394
|
+
existing.score += 2;
|
|
395
|
+
existing.keywords.push("deadline pattern");
|
|
396
|
+
scores.set("task", existing);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
function getSchema(primitiveType) {
|
|
400
|
+
const reg = getTemplateRegistry();
|
|
401
|
+
if (!reg.initialized) {
|
|
402
|
+
initializeTemplateRegistry();
|
|
403
|
+
}
|
|
404
|
+
return reg.schemas.get(primitiveType);
|
|
405
|
+
}
|
|
406
|
+
function getAllSchemas() {
|
|
407
|
+
const reg = getTemplateRegistry();
|
|
408
|
+
if (!reg.initialized) {
|
|
409
|
+
initializeTemplateRegistry();
|
|
410
|
+
}
|
|
411
|
+
return Array.from(reg.schemas.values());
|
|
412
|
+
}
|
|
413
|
+
function getSchemaNames() {
|
|
414
|
+
const reg = getTemplateRegistry();
|
|
415
|
+
if (!reg.initialized) {
|
|
416
|
+
initializeTemplateRegistry();
|
|
417
|
+
}
|
|
418
|
+
return Array.from(reg.schemas.keys());
|
|
419
|
+
}
|
|
420
|
+
function generateFrontmatter(primitiveType, options = {}) {
|
|
421
|
+
const schema = getSchema(primitiveType);
|
|
422
|
+
if (!schema) {
|
|
423
|
+
return {
|
|
424
|
+
type: primitiveType,
|
|
425
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
426
|
+
updated: (/* @__PURE__ */ new Date()).toISOString()
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
const frontmatter = {};
|
|
430
|
+
const now = /* @__PURE__ */ new Date();
|
|
431
|
+
const dateStr = now.toISOString().split("T")[0];
|
|
432
|
+
const datetimeStr = now.toISOString();
|
|
433
|
+
for (const [fieldName, fieldDef] of Object.entries(schema.fields)) {
|
|
434
|
+
if (options.extraFields?.[fieldName] !== void 0) {
|
|
435
|
+
const value = options.extraFields[fieldName];
|
|
436
|
+
if (fieldDef.enum && !fieldDef.enum.includes(String(value))) {
|
|
437
|
+
frontmatter[fieldName] = fieldDef.default ?? fieldDef.enum[0];
|
|
438
|
+
} else {
|
|
439
|
+
frontmatter[fieldName] = value;
|
|
440
|
+
}
|
|
441
|
+
continue;
|
|
442
|
+
}
|
|
443
|
+
if (fieldDef.default !== void 0) {
|
|
444
|
+
let defaultValue = fieldDef.default;
|
|
445
|
+
if (typeof defaultValue === "string") {
|
|
446
|
+
defaultValue = defaultValue.replace("{{datetime}}", datetimeStr).replace("{{date}}", dateStr).replace("{{title}}", options.title ?? "Untitled");
|
|
447
|
+
}
|
|
448
|
+
frontmatter[fieldName] = defaultValue;
|
|
449
|
+
} else if (fieldDef.required) {
|
|
450
|
+
switch (fieldDef.type) {
|
|
451
|
+
case "datetime":
|
|
452
|
+
frontmatter[fieldName] = datetimeStr;
|
|
453
|
+
break;
|
|
454
|
+
case "date":
|
|
455
|
+
frontmatter[fieldName] = dateStr;
|
|
456
|
+
break;
|
|
457
|
+
case "string":
|
|
458
|
+
if (fieldDef.enum?.length) {
|
|
459
|
+
frontmatter[fieldName] = fieldDef.enum[0];
|
|
460
|
+
} else {
|
|
461
|
+
frontmatter[fieldName] = "";
|
|
462
|
+
}
|
|
463
|
+
break;
|
|
464
|
+
case "number":
|
|
465
|
+
frontmatter[fieldName] = 0;
|
|
466
|
+
break;
|
|
467
|
+
case "boolean":
|
|
468
|
+
frontmatter[fieldName] = false;
|
|
469
|
+
break;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
if (options.source && schema.fields.source) {
|
|
474
|
+
frontmatter.source = options.source;
|
|
475
|
+
}
|
|
476
|
+
if (options.sessionId && schema.fields.session_id) {
|
|
477
|
+
frontmatter.session_id = options.sessionId;
|
|
478
|
+
}
|
|
479
|
+
return frontmatter;
|
|
480
|
+
}
|
|
481
|
+
function validateFrontmatter(primitiveType, frontmatter) {
|
|
482
|
+
const schema = getSchema(primitiveType);
|
|
483
|
+
if (!schema) {
|
|
484
|
+
return { valid: true, errors: [] };
|
|
485
|
+
}
|
|
486
|
+
const errors = [];
|
|
487
|
+
for (const [fieldName, fieldDef] of Object.entries(schema.fields)) {
|
|
488
|
+
const value = frontmatter[fieldName];
|
|
489
|
+
if (fieldDef.required && (value === void 0 || value === null || value === "")) {
|
|
490
|
+
errors.push(`Missing required field: ${fieldName}`);
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
if (value === void 0 || value === null) continue;
|
|
494
|
+
if (fieldDef.enum && !fieldDef.enum.includes(String(value))) {
|
|
495
|
+
errors.push(`Invalid value for ${fieldName}: "${value}". Must be one of: ${fieldDef.enum.join(", ")}`);
|
|
496
|
+
}
|
|
497
|
+
switch (fieldDef.type) {
|
|
498
|
+
case "number":
|
|
499
|
+
if (typeof value !== "number" && isNaN(Number(value))) {
|
|
500
|
+
errors.push(`Field ${fieldName} must be a number`);
|
|
501
|
+
}
|
|
502
|
+
break;
|
|
503
|
+
case "boolean":
|
|
504
|
+
if (typeof value !== "boolean" && value !== "true" && value !== "false") {
|
|
505
|
+
errors.push(`Field ${fieldName} must be a boolean`);
|
|
506
|
+
}
|
|
507
|
+
break;
|
|
508
|
+
case "datetime":
|
|
509
|
+
if (typeof value === "string" && isNaN(Date.parse(value))) {
|
|
510
|
+
errors.push(`Field ${fieldName} must be a valid datetime`);
|
|
511
|
+
}
|
|
512
|
+
break;
|
|
513
|
+
case "date":
|
|
514
|
+
if (typeof value === "string" && !/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
515
|
+
errors.push(`Field ${fieldName} must be a valid date (YYYY-MM-DD)`);
|
|
516
|
+
}
|
|
517
|
+
break;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
return { valid: errors.length === 0, errors };
|
|
521
|
+
}
|
|
522
|
+
function serializeFrontmatter(frontmatter) {
|
|
523
|
+
const lines = ["---"];
|
|
524
|
+
for (const [key, value] of Object.entries(frontmatter)) {
|
|
525
|
+
if (value === void 0 || value === null) continue;
|
|
526
|
+
if (Array.isArray(value)) {
|
|
527
|
+
lines.push(`${key}:`);
|
|
528
|
+
for (const item of value) {
|
|
529
|
+
lines.push(` - ${item}`);
|
|
530
|
+
}
|
|
531
|
+
} else if (typeof value === "object") {
|
|
532
|
+
lines.push(`${key}: ${JSON.stringify(value)}`);
|
|
533
|
+
} else if (typeof value === "string" && value.includes("\n")) {
|
|
534
|
+
lines.push(`${key}: |`);
|
|
535
|
+
for (const line of value.split("\n")) {
|
|
536
|
+
lines.push(` ${line}`);
|
|
537
|
+
}
|
|
538
|
+
} else {
|
|
539
|
+
lines.push(`${key}: ${value}`);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
lines.push("---");
|
|
543
|
+
return lines.join("\n");
|
|
544
|
+
}
|
|
545
|
+
function resetTemplateRegistry() {
|
|
546
|
+
registry = null;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
export {
|
|
550
|
+
getTemplateRegistry,
|
|
551
|
+
initializeTemplateRegistry,
|
|
552
|
+
classifyText,
|
|
553
|
+
getSchema,
|
|
554
|
+
getAllSchemas,
|
|
555
|
+
getSchemaNames,
|
|
556
|
+
generateFrontmatter,
|
|
557
|
+
validateFrontmatter,
|
|
558
|
+
serializeFrontmatter,
|
|
559
|
+
resetTemplateRegistry
|
|
560
|
+
};
|
|
@@ -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-E7MFQB6D.js";
|
|
9
5
|
import {
|
|
10
6
|
archiveObservations
|
|
11
7
|
} from "./chunk-MQUJNOHK.js";
|
|
8
|
+
import {
|
|
9
|
+
normalizeObservationContent,
|
|
10
|
+
parseObservationMarkdown
|
|
11
|
+
} from "./chunk-QK3UCXWL.js";
|
|
12
12
|
import {
|
|
13
13
|
formatIsoWeekKey,
|
|
14
14
|
getIsoWeek,
|
|
@@ -213,7 +213,7 @@ function promoteWeekRecords(records) {
|
|
|
213
213
|
return promoted;
|
|
214
214
|
}
|
|
215
215
|
async function maybeGenerateLlmReflection(weekKey, sections) {
|
|
216
|
-
const provider = resolveLlmProvider();
|
|
216
|
+
const provider = await resolveLlmProvider();
|
|
217
217
|
if (!provider) {
|
|
218
218
|
return null;
|
|
219
219
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runReflection
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-H34S76MB.js";
|
|
4
4
|
import {
|
|
5
5
|
Observer
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-3NSBOUT3.js";
|
|
7
7
|
import {
|
|
8
8
|
resolveVaultPath
|
|
9
9
|
} from "./chunk-MXSSG3QU.js";
|
|
@@ -135,7 +135,8 @@ function pushMessage(destination, conversationId, record) {
|
|
|
135
135
|
if (!text) {
|
|
136
136
|
return;
|
|
137
137
|
}
|
|
138
|
-
const
|
|
138
|
+
const rawRole = typeof record.role === "string" ? record.role : typeof record.sender === "string" ? record.sender : void 0;
|
|
139
|
+
const role = rawRole ? rawRole.trim().toLowerCase() : void 0;
|
|
139
140
|
destination.push({
|
|
140
141
|
source: "claude",
|
|
141
142
|
conversationId,
|
|
@@ -151,8 +152,9 @@ function normalizeClaudeExport(input) {
|
|
|
151
152
|
if (!item || typeof item !== "object") continue;
|
|
152
153
|
const record = item;
|
|
153
154
|
const conversationId = typeof record.id === "string" ? record.id : typeof record.uuid === "string" ? record.uuid : void 0;
|
|
154
|
-
|
|
155
|
-
|
|
155
|
+
const recordMessages = Array.isArray(record.messages) ? record.messages : Array.isArray(record.chat_messages) ? record.chat_messages : void 0;
|
|
156
|
+
if (recordMessages) {
|
|
157
|
+
for (const message of recordMessages) {
|
|
156
158
|
if (!message || typeof message !== "object") continue;
|
|
157
159
|
pushMessage(messages, conversationId, message);
|
|
158
160
|
}
|
|
@@ -170,6 +172,9 @@ function normalizeClaudeExport(input) {
|
|
|
170
172
|
if (Array.isArray(root.messages)) {
|
|
171
173
|
return normalizeClaudeExport([{ id: root.id, messages: root.messages }]);
|
|
172
174
|
}
|
|
175
|
+
if (Array.isArray(root.chat_messages)) {
|
|
176
|
+
return normalizeClaudeExport([{ id: root.id, chat_messages: root.chat_messages }]);
|
|
177
|
+
}
|
|
173
178
|
}
|
|
174
179
|
return messages;
|
|
175
180
|
}
|