clawvault 2.6.0 → 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-K3CDT7IH.js → chunk-E7MFQB6D.js} +61 -20
- 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-YOSEUUNB.js → chunk-H34S76MB.js} +6 -6
- package/dist/{chunk-4TE4JMLA.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-2YDBJS7M.js → chunk-SJSFRIYS.js} +1 -1
- package/dist/{chunk-GSD4ALSI.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 +12 -11
- 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-HA5M6KJB.js +0 -33
- 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/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,369 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/commands/compat.ts
|
|
31
|
+
var compat_exports = {};
|
|
32
|
+
__export(compat_exports, {
|
|
33
|
+
checkOpenClawCompatibility: () => checkOpenClawCompatibility,
|
|
34
|
+
compatCommand: () => compatCommand,
|
|
35
|
+
compatibilityExitCode: () => compatibilityExitCode
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(compat_exports);
|
|
38
|
+
var fs = __toESM(require("fs"), 1);
|
|
39
|
+
var path = __toESM(require("path"), 1);
|
|
40
|
+
var import_gray_matter = __toESM(require("gray-matter"), 1);
|
|
41
|
+
var import_child_process = require("child_process");
|
|
42
|
+
var import_url = require("url");
|
|
43
|
+
var import_meta = {};
|
|
44
|
+
var REQUIRED_HOOK_EVENTS = ["gateway:startup", "command:new", "session:start"];
|
|
45
|
+
var REQUIRED_HOOK_BIN = "clawvault";
|
|
46
|
+
function readOptionalFile(filePath) {
|
|
47
|
+
try {
|
|
48
|
+
if (!fs.existsSync(filePath)) return null;
|
|
49
|
+
return fs.readFileSync(filePath, "utf-8");
|
|
50
|
+
} catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function findPackageRoot() {
|
|
55
|
+
let dir = path.dirname((0, import_url.fileURLToPath)(import_meta.url));
|
|
56
|
+
while (dir !== path.dirname(dir)) {
|
|
57
|
+
if (fs.existsSync(path.join(dir, "package.json"))) {
|
|
58
|
+
return dir;
|
|
59
|
+
}
|
|
60
|
+
dir = path.dirname(dir);
|
|
61
|
+
}
|
|
62
|
+
return path.dirname((0, import_url.fileURLToPath)(import_meta.url));
|
|
63
|
+
}
|
|
64
|
+
function resolveOpenClawHooksDir() {
|
|
65
|
+
const candidates = [
|
|
66
|
+
path.join(process.env.HOME || "", ".openclaw", "hooks", "clawvault"),
|
|
67
|
+
path.join(process.env.OPENCLAW_HOME || "", "hooks", "clawvault"),
|
|
68
|
+
path.join(process.env.OPENCLAW_STATE_DIR || "", "hooks", "clawvault")
|
|
69
|
+
].filter((p) => p && !p.startsWith(path.sep + "hooks"));
|
|
70
|
+
for (const candidate of candidates) {
|
|
71
|
+
if (fs.existsSync(candidate)) {
|
|
72
|
+
return candidate;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
function resolveProjectFile(relativePath, baseDir) {
|
|
78
|
+
if (baseDir) {
|
|
79
|
+
return path.resolve(baseDir, relativePath);
|
|
80
|
+
}
|
|
81
|
+
const fromCwd = path.resolve(process.cwd(), relativePath);
|
|
82
|
+
if (fs.existsSync(fromCwd)) {
|
|
83
|
+
return fromCwd;
|
|
84
|
+
}
|
|
85
|
+
if (relativePath.startsWith("hooks/clawvault/")) {
|
|
86
|
+
const hooksDir = resolveOpenClawHooksDir();
|
|
87
|
+
if (hooksDir) {
|
|
88
|
+
const hookRelative = relativePath.replace("hooks/clawvault/", "");
|
|
89
|
+
const fromHooks = path.resolve(hooksDir, hookRelative);
|
|
90
|
+
if (fs.existsSync(fromHooks)) {
|
|
91
|
+
return fromHooks;
|
|
92
|
+
}
|
|
93
|
+
const fromNestedHooks = path.resolve(hooksDir, "hooks", "clawvault", hookRelative);
|
|
94
|
+
if (fs.existsSync(fromNestedHooks)) {
|
|
95
|
+
return fromNestedHooks;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return path.resolve(findPackageRoot(), relativePath);
|
|
100
|
+
}
|
|
101
|
+
function checkOpenClawCli() {
|
|
102
|
+
const result = (0, import_child_process.spawnSync)("openclaw", ["--version"], { stdio: "ignore" });
|
|
103
|
+
if (result.error) {
|
|
104
|
+
return {
|
|
105
|
+
label: "openclaw CLI available",
|
|
106
|
+
status: "warn",
|
|
107
|
+
detail: "openclaw binary not found",
|
|
108
|
+
hint: "Install OpenClaw CLI to enable hook runtime validation."
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
if (typeof result.status === "number" && result.status !== 0) {
|
|
112
|
+
return {
|
|
113
|
+
label: "openclaw CLI available",
|
|
114
|
+
status: "warn",
|
|
115
|
+
detail: `openclaw --version exited with code ${result.status}`,
|
|
116
|
+
hint: "Ensure OpenClaw CLI is installed and runnable in PATH."
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
if (typeof result.signal === "string" && result.signal.length > 0) {
|
|
120
|
+
return {
|
|
121
|
+
label: "openclaw CLI available",
|
|
122
|
+
status: "warn",
|
|
123
|
+
detail: `openclaw --version terminated by signal ${result.signal}`,
|
|
124
|
+
hint: "Ensure OpenClaw CLI can execute normally in PATH."
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
return { label: "openclaw CLI available", status: "ok" };
|
|
128
|
+
}
|
|
129
|
+
function checkPackageHookRegistration(options) {
|
|
130
|
+
let packageRaw = readOptionalFile(resolveProjectFile("package.json", options.baseDir));
|
|
131
|
+
if (packageRaw && !options.baseDir) {
|
|
132
|
+
try {
|
|
133
|
+
const parsed = JSON.parse(packageRaw);
|
|
134
|
+
if (!parsed.openclaw?.hooks) {
|
|
135
|
+
const fallbackPath = path.resolve(findPackageRoot(), "package.json");
|
|
136
|
+
const fallbackRaw = readOptionalFile(fallbackPath);
|
|
137
|
+
if (fallbackRaw) packageRaw = fallbackRaw;
|
|
138
|
+
}
|
|
139
|
+
} catch {
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (!packageRaw) {
|
|
143
|
+
return {
|
|
144
|
+
label: "package hook registration",
|
|
145
|
+
status: "error",
|
|
146
|
+
detail: "package.json not found"
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
try {
|
|
150
|
+
const parsed = JSON.parse(packageRaw);
|
|
151
|
+
const registeredHooks = parsed.openclaw?.hooks ?? [];
|
|
152
|
+
if (registeredHooks.includes("./hooks/clawvault")) {
|
|
153
|
+
return {
|
|
154
|
+
label: "package hook registration",
|
|
155
|
+
status: "ok",
|
|
156
|
+
detail: "./hooks/clawvault"
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
label: "package hook registration",
|
|
161
|
+
status: "error",
|
|
162
|
+
detail: "Missing ./hooks/clawvault in package openclaw.hooks"
|
|
163
|
+
};
|
|
164
|
+
} catch (err) {
|
|
165
|
+
return {
|
|
166
|
+
label: "package hook registration",
|
|
167
|
+
status: "error",
|
|
168
|
+
detail: err?.message || "Unable to parse package.json"
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function checkHookManifest(options) {
|
|
173
|
+
const hookRaw = readOptionalFile(resolveProjectFile("hooks/clawvault/HOOK.md", options.baseDir));
|
|
174
|
+
if (!hookRaw) {
|
|
175
|
+
return {
|
|
176
|
+
label: "hook manifest",
|
|
177
|
+
status: "error",
|
|
178
|
+
detail: "HOOK.md not found"
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
try {
|
|
182
|
+
const parsed = (0, import_gray_matter.default)(hookRaw);
|
|
183
|
+
const openclaw = parsed.data?.metadata?.openclaw;
|
|
184
|
+
const events = Array.isArray(openclaw?.events) ? openclaw?.events ?? [] : [];
|
|
185
|
+
const missingEvents = REQUIRED_HOOK_EVENTS.filter((event) => !events.includes(event));
|
|
186
|
+
if (missingEvents.length === 0) {
|
|
187
|
+
return {
|
|
188
|
+
label: "hook manifest events",
|
|
189
|
+
status: "ok",
|
|
190
|
+
detail: events.join(", ")
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
label: "hook manifest events",
|
|
195
|
+
status: "error",
|
|
196
|
+
detail: `Missing events: ${missingEvents.join(", ")}`
|
|
197
|
+
};
|
|
198
|
+
} catch (err) {
|
|
199
|
+
return {
|
|
200
|
+
label: "hook manifest events",
|
|
201
|
+
status: "error",
|
|
202
|
+
detail: err?.message || "Unable to parse HOOK.md frontmatter"
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
function checkHookManifestRequirements(options) {
|
|
207
|
+
const hookRaw = readOptionalFile(resolveProjectFile("hooks/clawvault/HOOK.md", options.baseDir));
|
|
208
|
+
if (!hookRaw) {
|
|
209
|
+
return {
|
|
210
|
+
label: "hook manifest requirements",
|
|
211
|
+
status: "error",
|
|
212
|
+
detail: "HOOK.md not found"
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
try {
|
|
216
|
+
const parsed = (0, import_gray_matter.default)(hookRaw);
|
|
217
|
+
const requiresBins = parsed.data?.metadata?.openclaw?.requires?.bins;
|
|
218
|
+
const bins = Array.isArray(requiresBins) ? requiresBins : [];
|
|
219
|
+
if (bins.includes(REQUIRED_HOOK_BIN)) {
|
|
220
|
+
return {
|
|
221
|
+
label: "hook manifest requirements",
|
|
222
|
+
status: "ok",
|
|
223
|
+
detail: `bins: ${bins.join(", ")}`
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
label: "hook manifest requirements",
|
|
228
|
+
status: "warn",
|
|
229
|
+
detail: `Missing required hook bin "${REQUIRED_HOOK_BIN}"`,
|
|
230
|
+
hint: 'Add metadata.openclaw.requires.bins: ["clawvault"] to hooks/clawvault/HOOK.md.'
|
|
231
|
+
};
|
|
232
|
+
} catch (err) {
|
|
233
|
+
return {
|
|
234
|
+
label: "hook manifest requirements",
|
|
235
|
+
status: "error",
|
|
236
|
+
detail: err?.message || "Unable to parse HOOK.md frontmatter"
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function checkHookHandlerSafety(options) {
|
|
241
|
+
const handlerRaw = readOptionalFile(resolveProjectFile("hooks/clawvault/handler.js", options.baseDir));
|
|
242
|
+
if (!handlerRaw) {
|
|
243
|
+
return {
|
|
244
|
+
label: "hook handler script",
|
|
245
|
+
status: "error",
|
|
246
|
+
detail: "handler.js not found"
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
const usesExecFileSync = handlerRaw.includes("execFileSync");
|
|
250
|
+
const usesExecSync = /\bexecSync\b/.test(handlerRaw);
|
|
251
|
+
const enablesShell = /\bshell\s*:\s*true\b/.test(handlerRaw);
|
|
252
|
+
const delegatesAutoProfile = /['"]--profile['"]\s*,\s*['"]auto['"]/.test(handlerRaw);
|
|
253
|
+
const violations = [];
|
|
254
|
+
if (!usesExecFileSync || usesExecSync) {
|
|
255
|
+
violations.push("execFileSync-only execution path");
|
|
256
|
+
}
|
|
257
|
+
if (enablesShell) {
|
|
258
|
+
violations.push("shell:false execution option");
|
|
259
|
+
}
|
|
260
|
+
if (!delegatesAutoProfile) {
|
|
261
|
+
violations.push("shared context profile delegation (--profile auto)");
|
|
262
|
+
}
|
|
263
|
+
if (violations.length > 0) {
|
|
264
|
+
return {
|
|
265
|
+
label: "hook handler safety",
|
|
266
|
+
status: "warn",
|
|
267
|
+
detail: `Missing conventions: ${violations.join(", ")}`,
|
|
268
|
+
hint: "Use execFileSync (no shell), avoid execSync, and delegate profile inference via --profile auto."
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
return { label: "hook handler safety", status: "ok" };
|
|
272
|
+
}
|
|
273
|
+
function checkSkillMetadata(options) {
|
|
274
|
+
const skillRaw = readOptionalFile(resolveProjectFile("SKILL.md", options.baseDir));
|
|
275
|
+
if (!skillRaw) {
|
|
276
|
+
return {
|
|
277
|
+
label: "skill metadata",
|
|
278
|
+
status: "warn",
|
|
279
|
+
detail: "SKILL.md not found",
|
|
280
|
+
hint: "Ensure SKILL.md is present for OpenClaw skill distribution."
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
let hasOpenClawMetadata = false;
|
|
284
|
+
let parseError;
|
|
285
|
+
try {
|
|
286
|
+
const parsed = (0, import_gray_matter.default)(skillRaw);
|
|
287
|
+
const frontmatter = parsed.data ?? {};
|
|
288
|
+
const metadata = frontmatter.metadata && typeof frontmatter.metadata === "object" && !Array.isArray(frontmatter.metadata) ? frontmatter.metadata : void 0;
|
|
289
|
+
hasOpenClawMetadata = Boolean(
|
|
290
|
+
metadata && typeof metadata.openclaw === "object" && metadata.openclaw !== null || typeof frontmatter.openclaw === "object" && frontmatter.openclaw !== null
|
|
291
|
+
);
|
|
292
|
+
} catch {
|
|
293
|
+
parseError = "Unable to parse SKILL.md frontmatter";
|
|
294
|
+
hasOpenClawMetadata = false;
|
|
295
|
+
}
|
|
296
|
+
if (!hasOpenClawMetadata) {
|
|
297
|
+
hasOpenClawMetadata = /"openclaw"\s*:/.test(skillRaw);
|
|
298
|
+
}
|
|
299
|
+
if (!hasOpenClawMetadata) {
|
|
300
|
+
const detail = parseError ? `${parseError} (or missing metadata.openclaw)` : "Missing metadata.openclaw in SKILL.md";
|
|
301
|
+
return {
|
|
302
|
+
label: "skill metadata",
|
|
303
|
+
status: "warn",
|
|
304
|
+
detail,
|
|
305
|
+
hint: "Add metadata.openclaw to SKILL.md frontmatter for OpenClaw compatibility."
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
return { label: "skill metadata", status: "ok" };
|
|
309
|
+
}
|
|
310
|
+
function checkOpenClawCompatibility(options = {}) {
|
|
311
|
+
const checks = [
|
|
312
|
+
checkOpenClawCli(),
|
|
313
|
+
checkPackageHookRegistration(options),
|
|
314
|
+
checkHookManifest(options),
|
|
315
|
+
checkHookManifestRequirements(options),
|
|
316
|
+
checkHookHandlerSafety(options),
|
|
317
|
+
checkSkillMetadata(options)
|
|
318
|
+
];
|
|
319
|
+
const warnings = checks.filter((check) => check.status === "warn").length;
|
|
320
|
+
const errors = checks.filter((check) => check.status === "error").length;
|
|
321
|
+
return {
|
|
322
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
323
|
+
checks,
|
|
324
|
+
warnings,
|
|
325
|
+
errors
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
function formatCompatibilityReport(report) {
|
|
329
|
+
const lines = [];
|
|
330
|
+
lines.push("OpenClaw Compatibility Report");
|
|
331
|
+
lines.push("-".repeat(34));
|
|
332
|
+
lines.push(`Generated: ${report.generatedAt}`);
|
|
333
|
+
lines.push("");
|
|
334
|
+
for (const check of report.checks) {
|
|
335
|
+
const prefix = check.status === "ok" ? "\u2713" : check.status === "warn" ? "\u26A0" : "\u2717";
|
|
336
|
+
lines.push(`${prefix} ${check.label}${check.detail ? ` \u2014 ${check.detail}` : ""}`);
|
|
337
|
+
if (check.hint) {
|
|
338
|
+
lines.push(` ${check.hint}`);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
lines.push("");
|
|
342
|
+
lines.push(`Warnings: ${report.warnings}`);
|
|
343
|
+
lines.push(`Errors: ${report.errors}`);
|
|
344
|
+
return lines.join("\n");
|
|
345
|
+
}
|
|
346
|
+
function compatibilityExitCode(report, options = {}) {
|
|
347
|
+
if (report.errors > 0) {
|
|
348
|
+
return 1;
|
|
349
|
+
}
|
|
350
|
+
if (options.strict && report.warnings > 0) {
|
|
351
|
+
return 1;
|
|
352
|
+
}
|
|
353
|
+
return 0;
|
|
354
|
+
}
|
|
355
|
+
async function compatCommand(options = {}) {
|
|
356
|
+
const report = checkOpenClawCompatibility({ baseDir: options.baseDir });
|
|
357
|
+
if (options.json) {
|
|
358
|
+
console.log(JSON.stringify(report, null, 2));
|
|
359
|
+
} else {
|
|
360
|
+
console.log(formatCompatibilityReport(report));
|
|
361
|
+
}
|
|
362
|
+
return report;
|
|
363
|
+
}
|
|
364
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
365
|
+
0 && (module.exports = {
|
|
366
|
+
checkOpenClawCompatibility,
|
|
367
|
+
compatCommand,
|
|
368
|
+
compatibilityExitCode
|
|
369
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type CompatStatus = 'ok' | 'warn' | 'error';
|
|
2
|
+
interface CompatCheck {
|
|
3
|
+
label: string;
|
|
4
|
+
status: CompatStatus;
|
|
5
|
+
detail?: string;
|
|
6
|
+
hint?: string;
|
|
7
|
+
}
|
|
8
|
+
interface CompatReport {
|
|
9
|
+
generatedAt: string;
|
|
10
|
+
checks: CompatCheck[];
|
|
11
|
+
warnings: number;
|
|
12
|
+
errors: number;
|
|
13
|
+
}
|
|
14
|
+
interface CompatOptions {
|
|
15
|
+
baseDir?: string;
|
|
16
|
+
}
|
|
17
|
+
interface CompatCommandOptions {
|
|
18
|
+
json?: boolean;
|
|
19
|
+
strict?: boolean;
|
|
20
|
+
baseDir?: string;
|
|
21
|
+
}
|
|
22
|
+
declare function checkOpenClawCompatibility(options?: CompatOptions): CompatReport;
|
|
23
|
+
declare function compatibilityExitCode(report: CompatReport, options?: {
|
|
24
|
+
strict?: boolean;
|
|
25
|
+
}): number;
|
|
26
|
+
declare function compatCommand(options?: CompatCommandOptions): Promise<CompatReport>;
|
|
27
|
+
|
|
28
|
+
export { type CompatCheck, type CompatCommandOptions, type CompatReport, type CompatStatus, checkOpenClawCompatibility, compatCommand, compatibilityExitCode };
|
package/dist/commands/compat.js
CHANGED