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:
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env node
|
||||
#!/usr/bin/env bun
|
||||
var it=Object.defineProperty;var _=(o,t)=>()=>(o&&(t=o(o=0)),t);var at=(o,t)=>{for(var e in t)it(o,e,{get:t[e],enumerable:!0})};var ut,pt,H,F,W=_(()=>{"use strict";ut=["bugfix","feature","refactor","discovery","decision","change"],pt=["how-it-works","why-it-exists","what-changed","problem-solution","gotcha","pattern","trade-off"],H=ut.join(","),F=pt.join(",")});import{readFileSync as lt,writeFileSync as ft,existsSync as Et}from"fs";import{join as mt}from"path";import{homedir as gt}from"os";var f,A=_(()=>{"use strict";W();y();f=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:mt(gt(),".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:H,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(!Et(t))return this.getAllDefaults();let e=lt(t,"utf-8"),r=JSON.parse(e),n=r;if(r.env&&typeof r.env=="object"){n=r.env;try{ft(t,JSON.stringify(n,null,2),"utf-8"),m.info("SETTINGS","Migrated settings file from nested to flat schema",{settingsPath:t})}catch(i){m.warn("SETTINGS","Failed to auto-migrate settings file",{settingsPath:t},i)}}let s={...this.DEFAULTS};for(let i of Object.keys(this.DEFAULTS))n[i]!==void 0&&(s[i]=n[i]);return s}}});var w,M,m,y=_(()=>{"use strict";A();w=(s=>(s[s.DEBUG=0]="DEBUG",s[s.INFO=1]="INFO",s[s.WARN=2]="WARN",s[s.ERROR=3]="ERROR",s[s.SILENT=4]="SILENT",s))(w||{}),M=class{level=null;useColor;constructor(){this.useColor=process.stdout.isTTY??!1}getLevel(){if(this.level===null){let t=f.get("CLAUDE_MEM_LOG_LEVEL").toUpperCase();this.level=w[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,s){if(t<this.getLevel())return;let i=new Date().toISOString().replace("T"," ").substring(0,23),c=w[t].padEnd(5),E=e.padEnd(6),a="";n?.correlationId?a=`[${n.correlationId}] `:n?.sessionId&&(a=`[session-${n.sessionId}] `);let u="";s!=null&&(this.getLevel()===0&&typeof s=="object"?u=`
|
||||
`+JSON.stringify(s,null,2):u=" "+this.formatData(s));let h="";if(n){let{sessionId:Kt,sdkSessionId:Bt,correlationId:Vt,...$}=n;Object.keys($).length>0&&(h=` {${Object.entries($).map(([ot,st])=>`${ot}=${st}`).join(", ")}}`)}let x=`[${i}] [${c}] [${E}] ${a}${r}${h}${u}`;t===3?console.error(x):console.log(x)}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`})}},m=new M});import{join as l,dirname as _t,basename as se}from"path";import{homedir as dt}from"os";import{fileURLToPath as St}from"url";function Tt(){return typeof __dirname<"u"?__dirname:_t(St(import.meta.url))}var pe,p,I,le,fe,Ee,me,ge,_e,de,Se,Te,Oe,P=_(()=>{"use strict";A();pe=Tt(),p=f.get("CLAUDE_MEM_DATA_DIR"),I=process.env.CLAUDE_CONFIG_DIR||l(dt(),".claude"),le=l(p,"archives"),fe=l(p,"logs"),Ee=l(p,"trash"),me=l(p,"backups"),ge=l(p,"settings.json"),_e=l(p,"claude-mem.db"),de=l(p,"vector-db"),Se=l(I,"settings.json"),Te=l(I,"commands"),Oe=l(I,"CLAUDE.md")});var j={};at(j,{BinaryManager:()=>b});import{existsSync as B,mkdirSync as Ot,writeFileSync as V,readFileSync as G}from"fs";import{join as d}from"path";var C,k,ht,b,X=_(()=>{"use strict";P();C=d(p,"bin"),k=d(C,"version.txt"),ht="https://github.com/thedotmack/claude-mem/releases/download",b=class{static async getExecutablePath(){if(process.platform!=="win32")throw new Error("BinaryManager only used on Windows");let t=this.getCurrentVersion(),e=d(C,"worker-service.exe");return B(e)&&this.getInstalledVersion()===t||await this.downloadBinary(t),e}static async downloadBinary(t){let e=`${ht}/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}
|
||||
|
||||
Reference in New Issue
Block a user