feat: migrate scripts to Bun runtime

- Updated shebangs in user-message-hook.js, worker-cli.js, and worker-service.cjs to use Bun instead of Node.
- Modified build-hooks.js to generate Bun-compatible shebangs in built scripts.
- Enhanced sync-marketplace.cjs to trigger a worker restart after syncing files via an HTTP request.
- Improved worker-cli.ts to exit with appropriate status codes after executing commands.
- Added build-worker-binary.js to create a Windows executable for the worker service using Bun's compile feature.
This commit is contained in:
Alex Newman
2025-12-11 14:59:44 -05:00
parent ded9671a82
commit 807d1d6100
15 changed files with 79 additions and 34 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env node
#!/usr/bin/env bun
var at=Object.defineProperty;var _=(s,t)=>()=>(s&&(t=s(s=0)),t);var ct=(s,t)=>{for(var e in t)at(s,e,{get:t[e],enumerable:!0})};var pt,lt,$,F,W=_(()=>{"use strict";pt=["bugfix","feature","refactor","discovery","decision","change"],lt=["how-it-works","why-it-exists","what-changed","problem-solution","gotcha","pattern","trade-off"],$=pt.join(","),F=lt.join(",")});import{readFileSync as ft,writeFileSync as gt,existsSync as mt}from"fs";import{join as Et}from"path";import{homedir as _t}from"os";var g,C=_(()=>{"use strict";W();d();g=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-haiku-4-5",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:"37777",CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_DATA_DIR:Et(_t(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES:$,CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS:F,CLAUDE_MEM_CONTEXT_FULL_COUNT:"5",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false"};static getAllDefaults(){return{...this.DEFAULTS}}static get(t){return this.DEFAULTS[t]}static getInt(t){let e=this.get(t);return parseInt(e,10)}static getBool(t){return this.get(t)==="true"}static loadFromFile(t){if(!mt(t))return this.getAllDefaults();let e=ft(t,"utf-8"),r=JSON.parse(e),n=r;if(r.env&&typeof r.env=="object"){n=r.env;try{gt(t,JSON.stringify(n,null,2),"utf-8"),c.info("SETTINGS","Migrated settings file from nested to flat schema",{settingsPath:t})}catch(i){c.warn("SETTINGS","Failed to auto-migrate settings file",{settingsPath:t},i)}}let o={...this.DEFAULTS};for(let i of Object.keys(this.DEFAULTS))n[i]!==void 0&&(o[i]=n[i]);return o}}});var D,M,c,d=_(()=>{"use strict";C();D=(o=>(o[o.DEBUG=0]="DEBUG",o[o.INFO=1]="INFO",o[o.WARN=2]="WARN",o[o.ERROR=3]="ERROR",o[o.SILENT=4]="SILENT",o))(D||{}),M=class{level=null;useColor;constructor(){this.useColor=process.stdout.isTTY??!1}getLevel(){if(this.level===null){let t=g.get("CLAUDE_MEM_LOG_LEVEL").toUpperCase();this.level=D[t]??1}return this.level}correlationId(t,e){return`obs-${t}-${e}`}sessionId(t){return`session-${t}`}formatData(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return t.toString();if(typeof t=="object"){if(t instanceof Error)return this.getLevel()===0?`${t.message}
${t.stack}`:t.message;if(Array.isArray(t))return`[${t.length} items]`;let e=Object.keys(t);return e.length===0?"{}":e.length<=3?JSON.stringify(t):`{${e.length} keys: ${e.slice(0,3).join(", ")}...}`}return String(t)}formatTool(t,e){if(!e)return t;try{let r=typeof e=="string"?JSON.parse(e):e;if(t==="Bash"&&r.command){let n=r.command.length>50?r.command.substring(0,50)+"...":r.command;return`${t}(${n})`}if(t==="Read"&&r.file_path){let n=r.file_path.split("/").pop()||r.file_path;return`${t}(${n})`}if(t==="Edit"&&r.file_path){let n=r.file_path.split("/").pop()||r.file_path;return`${t}(${n})`}if(t==="Write"&&r.file_path){let n=r.file_path.split("/").pop()||r.file_path;return`${t}(${n})`}return t}catch{return t}}log(t,e,r,n,o){if(t<this.getLevel())return;let i=new Date().toISOString().replace("T"," ").substring(0,23),a=D[t].padEnd(5),l=e.padEnd(6),p="";n?.correlationId?p=`[${n.correlationId}] `:n?.sessionId&&(p=`[session-${n.sessionId}] `);let m="";o!=null&&(this.getLevel()===0&&typeof o=="object"?m=`
`+JSON.stringify(o,null,2):m=" "+this.formatData(o));let b="";if(n){let{sessionId:Vt,sdkSessionId:Gt,correlationId:jt,...x}=n;Object.keys(x).length>0&&(b=` {${Object.entries(x).map(([ot,it])=>`${ot}=${it}`).join(", ")}}`)}let N=`[${i}] [${a}] [${l}] ${p}${r}${b}${m}`;t===3?console.error(N):console.log(N)}debug(t,e,r,n){this.log(0,t,e,r,n)}info(t,e,r,n){this.log(1,t,e,r,n)}warn(t,e,r,n){this.log(2,t,e,r,n)}error(t,e,r,n){this.log(3,t,e,r,n)}dataIn(t,e,r,n){this.info(t,`\u2192 ${e}`,r,n)}dataOut(t,e,r,n){this.info(t,`\u2190 ${e}`,r,n)}success(t,e,r,n){this.info(t,`\u2713 ${e}`,r,n)}failure(t,e,r,n){this.error(t,`\u2717 ${e}`,r,n)}timing(t,e,r,n){this.info(t,`\u23F1 ${e}`,n,{duration:`${r}ms`})}},c=new M});import{join as f,dirname as dt,basename as ae}from"path";import{homedir as St}from"os";import{fileURLToPath as Ot}from"url";function Tt(){return typeof __dirname<"u"?__dirname:dt(Ot(import.meta.url))}var fe,u,R,ge,me,Ee,_e,de,Se,Oe,Te,he,Ae,w=_(()=>{"use strict";C();fe=Tt(),u=g.get("CLAUDE_MEM_DATA_DIR"),R=process.env.CLAUDE_CONFIG_DIR||f(St(),".claude"),ge=f(u,"archives"),me=f(u,"logs"),Ee=f(u,"trash"),_e=f(u,"backups"),de=f(u,"settings.json"),Se=f(u,"claude-mem.db"),Oe=f(u,"vector-db"),Te=f(R,"settings.json"),he=f(R,"commands"),Ae=f(R,"CLAUDE.md")});var j={};ct(j,{BinaryManager:()=>k});import{existsSync as B,mkdirSync as ht,writeFileSync as V,readFileSync as G}from"fs";import{join as O}from"path";var y,I,At,k,X=_(()=>{"use strict";w();y=O(u,"bin"),I=O(y,"version.txt"),At="https://github.com/thedotmack/claude-mem/releases/download",k=class{static async getExecutablePath(){if(process.platform!=="win32")throw new Error("BinaryManager only used on Windows");let t=this.getCurrentVersion(),e=O(y,"worker-service.exe");return B(e)&&this.getInstalledVersion()===t||await this.downloadBinary(t),e}static async downloadBinary(t){let e=`${At}/v${t}/worker-service-v${t}-win-x64.exe`;console.log(`Downloading worker binary v${t}...`);let r=await fetch(e);if(!r.ok)throw new Error(`Download failed: ${r.status}