File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { execSync } from "node:child_process"
2+ import { resolve , dirname } from "node:path"
3+ import { fileURLToPath } from "node:url"
14import type { OpenClawPluginApi } from "openclaw/plugin-sdk"
25import type { BmClient } from "../bm-client.ts"
36import { log } from "../logger.ts"
47
8+ const __dirname = dirname ( fileURLToPath ( import . meta. url ) )
9+
510export 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" ,
You can’t perform that action at this time.
0 commit comments