Skip to content

Commit 8820441

Browse files
committed
feat: add /bm-setup slash command to install/update BM CLI
Registers a /bm-setup command that runs scripts/setup-bm.sh, letting users trigger BM CLI installation on demand instead of only at service start.
1 parent e946894 commit 8820441

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

commands/slash.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,44 @@
1+
import { execSync } from "node:child_process"
2+
import { resolve, dirname } from "node:path"
3+
import { fileURLToPath } from "node:url"
14
import type { OpenClawPluginApi } from "openclaw/plugin-sdk"
25
import type { BmClient } from "../bm-client.ts"
36
import { log } from "../logger.ts"
47

8+
const __dirname = dirname(fileURLToPath(import.meta.url))
9+
510
export function registerCommands(
611
api: OpenClawPluginApi,
712
client: BmClient,
813
): void {
14+
api.registerCommand({
15+
name: "bm-setup",
16+
description:
17+
"Install or update the Basic Memory CLI (requires uv)",
18+
requireAuth: true,
19+
handler: async () => {
20+
const scriptPath = resolve(__dirname, "..", "scripts", "setup-bm.sh")
21+
log.info(`/bm-setup: running ${scriptPath}`)
22+
23+
try {
24+
const output = execSync(`bash "${scriptPath}"`, {
25+
encoding: "utf-8",
26+
timeout: 180_000,
27+
stdio: "pipe",
28+
env: { ...process.env },
29+
})
30+
return { text: output.trim() }
31+
} catch (err: unknown) {
32+
const execErr = err as { stderr?: string; stdout?: string }
33+
const detail = execErr.stderr || execErr.stdout || String(err)
34+
log.error("/bm-setup failed", err)
35+
return {
36+
text: `Setup failed:\n${detail.trim()}`,
37+
}
38+
}
39+
},
40+
})
41+
942
api.registerCommand({
1043
name: "remember",
1144
description: "Save something to the Basic Memory knowledge graph",

0 commit comments

Comments
 (0)