claude-mem 12.4.7 → 12.4.8
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/dist/binaries/worker-service-v10.3.1-win-x64.exe +0 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +8 -0
- package/dist/npx-cli/index.js +189 -197
- package/dist/sdk/index.d.ts +109 -0
- package/dist/sdk/index.js +183 -0
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/plugin/scripts/mcp-server.cjs +24 -24
- package/plugin/scripts/worker-service.cjs +421 -442
- package/plugin/skills/version-bump/SKILL.md +4 -3
- package/plugin/ui/viewer-bundle.js +23 -35
package/dist/npx-cli/index.js
CHANGED
|
@@ -1,73 +1,65 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
`,"utf-8")}var
|
|
4
|
-
`)
|
|
5
|
-
`)
|
|
6
|
-
`){
|
|
7
|
-
|
|
8
|
-
`),n=t.split(`
|
|
9
|
-
`)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
`),
|
|
13
|
-
`).length-1;this.output.write(
|
|
14
|
-
`);this.output.write(
|
|
15
|
-
`).slice(
|
|
16
|
-
`)),this._prevFrame=e;return}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
${
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
${
|
|
24
|
-
|
|
25
|
-
|
|
2
|
+
var ks=Object.create;var Zt=Object.defineProperty;var As=Object.getOwnPropertyDescriptor;var bs=Object.getOwnPropertyNames;var Ms=Object.getPrototypeOf,Is=Object.prototype.hasOwnProperty;var $s=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var m=(t,e)=>()=>(t&&(e=t(t=0)),e);var sn=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),q=(t,e)=>{for(var r in e)Zt(t,r,{get:e[r],enumerable:!0})},Rs=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of bs(e))!Is.call(t,s)&&s!==r&&Zt(t,s,{get:()=>e[s],enumerable:!(o=As(e,s))||o.enumerable});return t};var le=(t,e,r)=>(r=t!=null?ks(Ms(t)):{},Rs(e||!t||!t.__esModule?Zt(r,"default",{value:t,enumerable:!0}):r,t));var Ee=sn((Ac,Qt)=>{var pt=process||{},un=pt.argv||[],dt=pt.env||{},Ps=!(dt.NO_COLOR||un.includes("--no-color"))&&(!!dt.FORCE_COLOR||un.includes("--color")||pt.platform==="win32"||(pt.stdout||{}).isTTY&&dt.TERM!=="dumb"||!!dt.CI),Ts=(t,e,r=t)=>o=>{let s=""+o,i=s.indexOf(e,t.length);return~i?t+Os(s,e,r,i)+e:t+s+e},Os=(t,e,r,o)=>{let s="",i=0;do s+=t.substring(i,o)+r,i=o+e.length,o=t.indexOf(e,i);while(~o);return s+t.substring(i)},an=(t=Ps)=>{let e=t?Ts:()=>String;return{isColorSupported:t,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};Qt.exports=an();Qt.exports.createColors=an});import{existsSync as Ls,readFileSync as Bs}from"fs";function J(t,e){if(!Ls(t))return e;try{return JSON.parse(Bs(t,"utf-8"))}catch(r){throw new Error(`Corrupt JSON file, refusing to overwrite: ${t}: ${r instanceof Error?r.message:String(r)}`)}}var Oe=m(()=>{"use strict"});import{existsSync as Le,mkdirSync as Ns,readFileSync as cn,writeFileSync as js}from"fs";import{homedir as Us}from"os";import{dirname as ln,join as j}from"path";import{fileURLToPath as Ws}from"url";function er(){return process.env.CLAUDE_CONFIG_DIR||j(Us(),".claude")}function $(){return j(er(),"plugins","marketplaces","thedotmack")}function De(){return j(er(),"plugins")}function he(){return j(De(),"known_marketplaces.json")}function Fe(){return j(De(),"installed_plugins.json")}function Se(){return j(er(),"settings.json")}function tr(t){return j(De(),"cache","thedotmack","claude-mem",t)}function mt(){let t=Ws(import.meta.url),e=j(ln(t),"..","..");if(!Le(j(e,"package.json")))throw new Error(`npmPackageRootDirectory: expected package.json at ${e}. Bundle structure may have changed \u2014 update the path walk.`);return e}function rr(){return j(mt(),"plugin")}function Be(){let t=j(rr(),".claude-plugin","plugin.json");if(Le(t))try{let r=JSON.parse(cn(t,"utf-8"));if(r.version)return r.version}catch{}let e=j(mt(),"package.json");if(Le(e))try{let r=JSON.parse(cn(e,"utf-8"));if(r.version)return r.version}catch{}return"0.0.0"}function gt(){let t=$();return Le(j(t,"plugin",".claude-plugin","plugin.json"))}function Ne(t){Le(t)||Ns(t,{recursive:!0})}function se(t,e){Ne(ln(t)),js(t,JSON.stringify(e,null,2)+`
|
|
3
|
+
`,"utf-8")}var te,de=m(()=>{"use strict";Oe();te=process.platform==="win32"});var or=sn((Lc,Dn)=>{"use strict";var nr={to(t,e){return e?`\x1B[${e+1};${t+1}H`:`\x1B[${t+1}G`},move(t,e){let r="";return t<0?r+=`\x1B[${-t}D`:t>0&&(r+=`\x1B[${t}C`),e<0?r+=`\x1B[${-e}A`:e>0&&(r+=`\x1B[${e}B`),r},up:(t=1)=>`\x1B[${t}A`,down:(t=1)=>`\x1B[${t}B`,forward:(t=1)=>`\x1B[${t}C`,backward:(t=1)=>`\x1B[${t}D`,nextLine:(t=1)=>"\x1B[E".repeat(t),prevLine:(t=1)=>"\x1B[F".repeat(t),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},Gs={up:(t=1)=>"\x1B[S".repeat(t),down:(t=1)=>"\x1B[T".repeat(t)},Hs={screen:"\x1B[2J",up:(t=1)=>"\x1B[1J".repeat(t),down:(t=1)=>"\x1B[J".repeat(t),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(t){let e="";for(let r=0;r<t;r++)e+=this.line+(r<t-1?nr.up():"");return t&&(e+=nr.left),e}};Dn.exports={cursor:nr,scroll:Gs,erase:Hs,beep:"\x07"}});import{stdin as Fn,stdout as Sn}from"node:process";import*as ie from"node:readline";import dn from"node:readline";import{WriteStream as Ks}from"node:tty";function Js({onlyFirst:t=!1}={}){let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(e,t?void 0:"g")}function yn(t){if(typeof t!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(Ys,"")}function wn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function je(t,e={}){if(typeof t!="string"||t.length===0||(e={ambiguousIsNarrow:!0,...e},t=yn(t),t.length===0))return 0;t=t.replace(qs()," ");let r=e.ambiguousIsNarrow?1:2,o=0;for(let s of t){let i=s.codePointAt(0);if(!(i<=31||i>=127&&i<=159||i>=768&&i<=879))switch(Xs.eastAsianWidth(s)){case"F":case"W":o+=2;break;case"A":o+=r;break;default:o+=1}}return o}function ei(){let t=new Map;for(let[e,r]of Object.entries(F)){for(let[o,s]of Object.entries(r))F[o]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},r[o]=F[o],t.set(s[0],s[1]);Object.defineProperty(F,e,{value:r,enumerable:!1})}return Object.defineProperty(F,"codes",{value:t,enumerable:!1}),F.color.close="\x1B[39m",F.bgColor.close="\x1B[49m",F.color.ansi=pn(),F.color.ansi256=mn(),F.color.ansi16m=gn(),F.bgColor.ansi=pn(sr),F.bgColor.ansi256=mn(sr),F.bgColor.ansi16m=gn(sr),Object.defineProperties(F,{rgbToAnsi256:{value:(e,r,o)=>e===r&&r===o?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(o/255*5),enumerable:!1},hexToRgb:{value:e=>{let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!r)return[0,0,0];let[o]=r;o.length===3&&(o=[...o].map(i=>i+i).join(""));let s=Number.parseInt(o,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:e=>F.rgbToAnsi256(...F.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let r,o,s;if(e>=232)r=((e-232)*10+8)/255,o=r,s=r;else{e-=16;let u=e%36;r=Math.floor(e/36)/5,o=Math.floor(u/6)/5,s=u%6/5}let i=Math.max(r,o,s)*2;if(i===0)return 30;let n=30+(Math.round(s)<<2|Math.round(o)<<1|Math.round(r));return i===2&&(n+=60),n},enumerable:!1},rgbToAnsi:{value:(e,r,o)=>F.ansi256ToAnsi(F.rgbToAnsi256(e,r,o)),enumerable:!1},hexToAnsi:{value:e=>F.ansi256ToAnsi(F.hexToAnsi256(e)),enumerable:!1}}),F}function En(t,e,r){return String(t).normalize().replace(/\r\n/g,`
|
|
4
|
+
`).split(`
|
|
5
|
+
`).map(o=>ii(o,e,r)).join(`
|
|
6
|
+
`)}function lr(t,e){if(typeof t=="string")return Ct.aliases.get(t)===e;for(let r of t)if(r!==void 0&&lr(r,e))return!0;return!1}function ai(t,e){if(t===e)return;let r=t.split(`
|
|
7
|
+
`),o=e.split(`
|
|
8
|
+
`),s=[];for(let i=0;i<Math.max(r.length,o.length);i++)r[i]!==o[i]&&s.push(i);return s}function ue(t){return t===ur}function ft(t,e){let r=t;r.isTTY&&r.setRawMode(e)}function kn({input:t=Fn,output:e=Sn,overwrite:r=!0,hideCursor:o=!0}={}){let s=ie.createInterface({input:t,output:e,prompt:"",tabSize:1});ie.emitKeypressEvents(t,s),t.isTTY&&t.setRawMode(!0);let i=(n,{name:u,sequence:c})=>{let D=String(n);if(lr([D,u,c],"cancel")){o&&e.write(b.cursor.show),process.exit(0);return}if(!r)return;ie.moveCursor(e,u==="return"?0:-1,u==="return"?-1:0,()=>{ie.clearLine(e,1,()=>{t.once("keypress",i)})})};return o&&e.write(b.cursor.hide),t.once("keypress",i),()=>{t.off("keypress",i),o&&e.write(b.cursor.show),t.isTTY&&!ci&&t.setRawMode(!1),s.terminal=!1,s.close()}}var b,Ys,vn,Vs,Xs,zs,qs,sr,pn,mn,gn,F,Zs,Qs,ti,Ft,ri,ar,_n,ni,xn,cr,fn,Cn,oi,ir,si,ii,ui,Ct,ci,ur,li,Di,U,Et,ht,di,pi,hn,An,Dr=m(()=>{b=le(or(),1);Ys=Js();vn={exports:{}};(function(t){var e={};t.exports=e,e.eastAsianWidth=function(o){var s=o.charCodeAt(0),i=o.length==2?o.charCodeAt(1):0,n=s;return 55296<=s&&s<=56319&&56320<=i&&i<=57343&&(s&=1023,i&=1023,n=s<<10|i,n+=65536),n==12288||65281<=n&&n<=65376||65504<=n&&n<=65510?"F":n==8361||65377<=n&&n<=65470||65474<=n&&n<=65479||65482<=n&&n<=65487||65490<=n&&n<=65495||65498<=n&&n<=65500||65512<=n&&n<=65518?"H":4352<=n&&n<=4447||4515<=n&&n<=4519||4602<=n&&n<=4607||9001<=n&&n<=9002||11904<=n&&n<=11929||11931<=n&&n<=12019||12032<=n&&n<=12245||12272<=n&&n<=12283||12289<=n&&n<=12350||12353<=n&&n<=12438||12441<=n&&n<=12543||12549<=n&&n<=12589||12593<=n&&n<=12686||12688<=n&&n<=12730||12736<=n&&n<=12771||12784<=n&&n<=12830||12832<=n&&n<=12871||12880<=n&&n<=13054||13056<=n&&n<=19903||19968<=n&&n<=42124||42128<=n&&n<=42182||43360<=n&&n<=43388||44032<=n&&n<=55203||55216<=n&&n<=55238||55243<=n&&n<=55291||63744<=n&&n<=64255||65040<=n&&n<=65049||65072<=n&&n<=65106||65108<=n&&n<=65126||65128<=n&&n<=65131||110592<=n&&n<=110593||127488<=n&&n<=127490||127504<=n&&n<=127546||127552<=n&&n<=127560||127568<=n&&n<=127569||131072<=n&&n<=194367||177984<=n&&n<=196605||196608<=n&&n<=262141?"W":32<=n&&n<=126||162<=n&&n<=163||165<=n&&n<=166||n==172||n==175||10214<=n&&n<=10221||10629<=n&&n<=10630?"Na":n==161||n==164||167<=n&&n<=168||n==170||173<=n&&n<=174||176<=n&&n<=180||182<=n&&n<=186||188<=n&&n<=191||n==198||n==208||215<=n&&n<=216||222<=n&&n<=225||n==230||232<=n&&n<=234||236<=n&&n<=237||n==240||242<=n&&n<=243||247<=n&&n<=250||n==252||n==254||n==257||n==273||n==275||n==283||294<=n&&n<=295||n==299||305<=n&&n<=307||n==312||319<=n&&n<=322||n==324||328<=n&&n<=331||n==333||338<=n&&n<=339||358<=n&&n<=359||n==363||n==462||n==464||n==466||n==468||n==470||n==472||n==474||n==476||n==593||n==609||n==708||n==711||713<=n&&n<=715||n==717||n==720||728<=n&&n<=731||n==733||n==735||768<=n&&n<=879||913<=n&&n<=929||931<=n&&n<=937||945<=n&&n<=961||963<=n&&n<=969||n==1025||1040<=n&&n<=1103||n==1105||n==8208||8211<=n&&n<=8214||8216<=n&&n<=8217||8220<=n&&n<=8221||8224<=n&&n<=8226||8228<=n&&n<=8231||n==8240||8242<=n&&n<=8243||n==8245||n==8251||n==8254||n==8308||n==8319||8321<=n&&n<=8324||n==8364||n==8451||n==8453||n==8457||n==8467||n==8470||8481<=n&&n<=8482||n==8486||n==8491||8531<=n&&n<=8532||8539<=n&&n<=8542||8544<=n&&n<=8555||8560<=n&&n<=8569||n==8585||8592<=n&&n<=8601||8632<=n&&n<=8633||n==8658||n==8660||n==8679||n==8704||8706<=n&&n<=8707||8711<=n&&n<=8712||n==8715||n==8719||n==8721||n==8725||n==8730||8733<=n&&n<=8736||n==8739||n==8741||8743<=n&&n<=8748||n==8750||8756<=n&&n<=8759||8764<=n&&n<=8765||n==8776||n==8780||n==8786||8800<=n&&n<=8801||8804<=n&&n<=8807||8810<=n&&n<=8811||8814<=n&&n<=8815||8834<=n&&n<=8835||8838<=n&&n<=8839||n==8853||n==8857||n==8869||n==8895||n==8978||9312<=n&&n<=9449||9451<=n&&n<=9547||9552<=n&&n<=9587||9600<=n&&n<=9615||9618<=n&&n<=9621||9632<=n&&n<=9633||9635<=n&&n<=9641||9650<=n&&n<=9651||9654<=n&&n<=9655||9660<=n&&n<=9661||9664<=n&&n<=9665||9670<=n&&n<=9672||n==9675||9678<=n&&n<=9681||9698<=n&&n<=9701||n==9711||9733<=n&&n<=9734||n==9737||9742<=n&&n<=9743||9748<=n&&n<=9749||n==9756||n==9758||n==9792||n==9794||9824<=n&&n<=9825||9827<=n&&n<=9829||9831<=n&&n<=9834||9836<=n&&n<=9837||n==9839||9886<=n&&n<=9887||9918<=n&&n<=9919||9924<=n&&n<=9933||9935<=n&&n<=9953||n==9955||9960<=n&&n<=9983||n==10045||n==10071||10102<=n&&n<=10111||11093<=n&&n<=11097||12872<=n&&n<=12879||57344<=n&&n<=63743||65024<=n&&n<=65039||n==65533||127232<=n&&n<=127242||127248<=n&&n<=127277||127280<=n&&n<=127337||127344<=n&&n<=127386||917760<=n&&n<=917999||983040<=n&&n<=1048573||1048576<=n&&n<=1114109?"A":"N"},e.characterLength=function(o){var s=this.eastAsianWidth(o);return s=="F"||s=="W"||s=="A"?2:1};function r(o){return o.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}e.length=function(o){for(var s=r(o),i=0,n=0;n<s.length;n++)i=i+this.characterLength(s[n]);return i},e.slice=function(o,s,i){textLen=e.length(o),s=s||0,i=i||1,s<0&&(s=textLen+s),i<0&&(i=textLen+i);for(var n="",u=0,c=r(o),D=0;D<c.length;D++){var d=c[D],p=e.length(d);if(u>=s-(p==2?1:0))if(u+p<=i)n+=d;else break;u+=p}return n}})(vn);Vs=vn.exports,Xs=wn(Vs),zs=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},qs=wn(zs);sr=10,pn=(t=0)=>e=>`\x1B[${e+t}m`,mn=(t=0)=>e=>`\x1B[${38+t};5;${e}m`,gn=(t=0)=>(e,r,o)=>`\x1B[${38+t};2;${e};${r};${o}m`,F={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(F.modifier);Zs=Object.keys(F.color),Qs=Object.keys(F.bgColor);[...Zs,...Qs];ti=ei(),Ft=new Set(["\x1B","\x9B"]),ri=39,ar="\x07",_n="[",ni="]",xn="m",cr=`${ni}8;;`,fn=t=>`${Ft.values().next().value}${_n}${t}${xn}`,Cn=t=>`${Ft.values().next().value}${cr}${t}${ar}`,oi=t=>t.split(" ").map(e=>je(e)),ir=(t,e,r)=>{let o=[...e],s=!1,i=!1,n=je(yn(t[t.length-1]));for(let[u,c]of o.entries()){let D=je(c);if(n+D<=r?t[t.length-1]+=c:(t.push(c),n=0),Ft.has(c)&&(s=!0,i=o.slice(u+1).join("").startsWith(cr)),s){i?c===ar&&(s=!1,i=!1):c===xn&&(s=!1);continue}n+=D,n===r&&u<o.length-1&&(t.push(""),n=0)}!n&&t[t.length-1].length>0&&t.length>1&&(t[t.length-2]+=t.pop())},si=t=>{let e=t.split(" "),r=e.length;for(;r>0&&!(je(e[r-1])>0);)r--;return r===e.length?t:e.slice(0,r).join(" ")+e.slice(r).join("")},ii=(t,e,r={})=>{if(r.trim!==!1&&t.trim()==="")return"";let o="",s,i,n=oi(t),u=[""];for(let[D,d]of t.split(" ").entries()){r.trim!==!1&&(u[u.length-1]=u[u.length-1].trimStart());let p=je(u[u.length-1]);if(D!==0&&(p>=e&&(r.wordWrap===!1||r.trim===!1)&&(u.push(""),p=0),(p>0||r.trim===!1)&&(u[u.length-1]+=" ",p++)),r.hard&&n[D]>e){let I=e-p,_=1+Math.floor((n[D]-I-1)/e);Math.floor((n[D]-1)/e)<_&&u.push(""),ir(u,d,e);continue}if(p+n[D]>e&&p>0&&n[D]>0){if(r.wordWrap===!1&&p<e){ir(u,d,e);continue}u.push("")}if(p+n[D]>e&&r.wordWrap===!1){ir(u,d,e);continue}u[u.length-1]+=d}r.trim!==!1&&(u=u.map(D=>si(D)));let c=[...u.join(`
|
|
9
|
+
`)];for(let[D,d]of c.entries()){if(o+=d,Ft.has(d)){let{groups:I}=new RegExp(`(?:\\${_n}(?<code>\\d+)m|\\${cr}(?<uri>.*)${ar})`).exec(c.slice(D).join(""))||{groups:{}};if(I.code!==void 0){let _=Number.parseFloat(I.code);s=_===ri?void 0:_}else I.uri!==void 0&&(i=I.uri.length===0?void 0:I.uri)}let p=ti.codes.get(Number(s));c[D+1]===`
|
|
10
|
+
`?(i&&(o+=Cn("")),s&&p&&(o+=fn(p))):d===`
|
|
11
|
+
`&&(s&&p&&(o+=fn(s)),i&&(o+=Cn(i)))}return o};ui=["up","down","left","right","space","enter","cancel"],Ct={actions:new Set(ui),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]])};ci=globalThis.process.platform.startsWith("win"),ur=Symbol("clack:cancel");li=Object.defineProperty,Di=(t,e,r)=>e in t?li(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,U=(t,e,r)=>(Di(t,typeof e!="symbol"?e+"":e,r),r),Et=class{constructor(e,r=!0){U(this,"input"),U(this,"output"),U(this,"_abortSignal"),U(this,"rl"),U(this,"opts"),U(this,"_render"),U(this,"_track",!1),U(this,"_prevFrame",""),U(this,"_subscribers",new Map),U(this,"_cursor",0),U(this,"state","initial"),U(this,"error",""),U(this,"value");let{input:o=Fn,output:s=Sn,render:i,signal:n,...u}=e;this.opts=u,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=r,this._abortSignal=n,this.input=o,this.output=s}unsubscribe(){this._subscribers.clear()}setSubscriber(e,r){let o=this._subscribers.get(e)??[];o.push(r),this._subscribers.set(e,o)}on(e,r){this.setSubscriber(e,{cb:r})}once(e,r){this.setSubscriber(e,{cb:r,once:!0})}emit(e,...r){let o=this._subscribers.get(e)??[],s=[];for(let i of o)i.cb(...r),i.once&&s.push(()=>o.splice(o.indexOf(i),1));for(let i of s)i()}prompt(){return new Promise((e,r)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),e(ur);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}let o=new Ks(0);o._write=(s,i,n)=>{this._track&&(this.value=this.rl?.line.replace(/\t/g,""),this._cursor=this.rl?.cursor??0,this.emit("value",this.value)),n()},this.input.pipe(o),this.rl=dn.createInterface({input:this.input,output:o,tabSize:2,prompt:"",escapeCodeTimeout:50}),dn.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),ft(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(b.cursor.show),this.output.off("resize",this.render),ft(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(b.cursor.show),this.output.off("resize",this.render),ft(this.input,!1),e(ur)})})}onKeypress(e,r){if(this.state==="error"&&(this.state="active"),r?.name&&(!this._track&&Ct.aliases.has(r.name)&&this.emit("cursor",Ct.aliases.get(r.name)),Ct.actions.has(r.name)&&this.emit("cursor",r.name)),e&&(e.toLowerCase()==="y"||e.toLowerCase()==="n")&&this.emit("confirm",e.toLowerCase()==="y"),e===" "&&this.opts.placeholder&&(this.value||(this.rl?.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),e&&this.emit("key",e.toLowerCase()),r?.name==="return"){if(this.opts.validate){let o=this.opts.validate(this.value);o&&(this.error=o instanceof Error?o.message:o,this.state="error",this.rl?.write(this.value))}this.state!=="error"&&(this.state="submit")}lr([e,r?.name,r?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
|
|
12
|
+
`),ft(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=En(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
|
|
13
|
+
`).length-1;this.output.write(b.cursor.move(-999,e*-1))}render(){let e=En(this._render(this)??"",process.stdout.columns,{hard:!0});if(e!==this._prevFrame){if(this.state==="initial")this.output.write(b.cursor.hide);else{let r=ai(this._prevFrame,e);if(this.restoreCursor(),r&&r?.length===1){let o=r[0];this.output.write(b.cursor.move(0,o)),this.output.write(b.erase.lines(1));let s=e.split(`
|
|
14
|
+
`);this.output.write(s[o]),this._prevFrame=e,this.output.write(b.cursor.move(0,s.length-o-1));return}if(r&&r?.length>1){let o=r[0];this.output.write(b.cursor.move(0,o)),this.output.write(b.erase.down());let s=e.split(`
|
|
15
|
+
`).slice(o);this.output.write(s.join(`
|
|
16
|
+
`)),this._prevFrame=e;return}this.output.write(b.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}},ht=class extends Et{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",r=>{this.output.write(b.cursor.move(0,-1)),this.value=r,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}},di=Object.defineProperty,pi=(t,e,r)=>e in t?di(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,hn=(t,e,r)=>(pi(t,typeof e!="symbol"?e+"":e,r),r),An=class extends Et{constructor(t){super(t,!1),hn(this,"options"),hn(this,"cursor",0),this.options=t.options,this.value=[...t.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:e})=>e===t.cursorAt),0),this.on("key",e=>{e==="a"&&this.toggleAll()}),this.on("cursor",e=>{switch(e){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){let t=this.value.length===this.options.length;this.value=t?[]:this.options.map(e=>e.value)}toggleValue(){let t=this.value.includes(this._value);this.value=t?this.value.filter(e=>e!==this._value):[...this.value,this._value]}}});import{stripVTControlCharacters as dr}from"node:util";import Y from"node:process";function mi(){return Y.platform!=="win32"?Y.env.TERM!=="linux":!!Y.env.CI||!!Y.env.WT_SESSION||!!Y.env.TERMINUS_SUBLIME||Y.env.ConEmuTask==="{cmd::Cmder}"||Y.env.TERM_PROGRAM==="Terminus-Sublime"||Y.env.TERM_PROGRAM==="vscode"||Y.env.TERM==="xterm-256color"||Y.env.TERM==="alacritty"||Y.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var l,St,pr,w,gi,Pn,Tn,yt,fi,y,Ue,bn,Mn,Ci,In,Ei,Zc,$n,hi,Fi,Si,yi,wi,vi,_i,On,Rn,We,Ln,Ge,He,wt,pe,R,xi,vt,mr=m(()=>{Dr();Dr();l=le(Ee(),1),St=le(or(),1);pr=mi(),w=(t,e)=>pr?t:e,gi=w("\u25C6","*"),Pn=w("\u25A0","x"),Tn=w("\u25B2","x"),yt=w("\u25C7","o"),fi=w("\u250C","T"),y=w("\u2502","|"),Ue=w("\u2514","\u2014"),bn=w("\u25CF",">"),Mn=w("\u25CB"," "),Ci=w("\u25FB","[\u2022]"),In=w("\u25FC","[+]"),Ei=w("\u25FB","[ ]"),Zc=w("\u25AA","\u2022"),$n=w("\u2500","-"),hi=w("\u256E","+"),Fi=w("\u251C","+"),Si=w("\u256F","+"),yi=w("\u25CF","\u2022"),wi=w("\u25C6","*"),vi=w("\u25B2","!"),_i=w("\u25A0","x"),On=t=>{switch(t){case"initial":case"active":return l.default.cyan(gi);case"cancel":return l.default.red(Pn);case"error":return l.default.yellow(Tn);case"submit":return l.default.green(yt)}},Rn=t=>{let{cursor:e,options:r,style:o}=t,s=t.maxItems??Number.POSITIVE_INFINITY,i=Math.max(process.stdout.rows-4,0),n=Math.min(i,Math.max(s,5)),u=0;e>=u+n-3?u=Math.max(Math.min(e-n+3,r.length-n),0):e<u+2&&(u=Math.max(e-2,0));let c=n<r.length&&u>0,D=n<r.length&&u+n<r.length;return r.slice(u,u+n).map((d,p,I)=>{let _=p===0&&c,g=p===I.length-1&&D;return _||g?l.default.dim("..."):o(d,p+u===e)})},We=t=>{let e=t.active??"Yes",r=t.inactive??"No";return new ht({active:e,inactive:r,initialValue:t.initialValue??!0,render(){let o=`${l.default.gray(y)}
|
|
17
|
+
${On(this.state)} ${t.message}
|
|
18
|
+
`,s=this.value?e:r;switch(this.state){case"submit":return`${o}${l.default.gray(y)} ${l.default.dim(s)}`;case"cancel":return`${o}${l.default.gray(y)} ${l.default.strikethrough(l.default.dim(s))}
|
|
19
|
+
${l.default.gray(y)}`;default:return`${o}${l.default.cyan(y)} ${this.value?`${l.default.green(bn)} ${e}`:`${l.default.dim(Mn)} ${l.default.dim(e)}`} ${l.default.dim("/")} ${this.value?`${l.default.dim(Mn)} ${l.default.dim(r)}`:`${l.default.green(bn)} ${r}`}
|
|
20
|
+
${l.default.cyan(Ue)}
|
|
21
|
+
`}}}).prompt()},Ln=t=>{let e=(r,o)=>{let s=r.label??String(r.value);return o==="active"?`${l.default.cyan(Ci)} ${s} ${r.hint?l.default.dim(`(${r.hint})`):""}`:o==="selected"?`${l.default.green(In)} ${l.default.dim(s)}`:o==="cancelled"?`${l.default.strikethrough(l.default.dim(s))}`:o==="active-selected"?`${l.default.green(In)} ${s} ${r.hint?l.default.dim(`(${r.hint})`):""}`:o==="submitted"?`${l.default.dim(s)}`:`${l.default.dim(Ei)} ${l.default.dim(s)}`};return new An({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(r){if(this.required&&r.length===0)return`Please select at least one option.
|
|
22
|
+
${l.default.reset(l.default.dim(`Press ${l.default.gray(l.default.bgWhite(l.default.inverse(" space ")))} to select, ${l.default.gray(l.default.bgWhite(l.default.inverse(" enter ")))} to submit`))}`},render(){let r=`${l.default.gray(y)}
|
|
23
|
+
${On(this.state)} ${t.message}
|
|
24
|
+
`,o=(s,i)=>{let n=this.value.includes(s.value);return i&&n?e(s,"active-selected"):n?e(s,"selected"):e(s,i?"active":"inactive")};switch(this.state){case"submit":return`${r}${l.default.gray(y)} ${this.options.filter(({value:s})=>this.value.includes(s)).map(s=>e(s,"submitted")).join(l.default.dim(", "))||l.default.dim("none")}`;case"cancel":{let s=this.options.filter(({value:i})=>this.value.includes(i)).map(i=>e(i,"cancelled")).join(l.default.dim(", "));return`${r}${l.default.gray(y)} ${s.trim()?`${s}
|
|
25
|
+
${l.default.gray(y)}`:""}`}case"error":{let s=this.error.split(`
|
|
26
|
+
`).map((i,n)=>n===0?`${l.default.yellow(Ue)} ${l.default.yellow(i)}`:` ${i}`).join(`
|
|
27
|
+
`);return`${r+l.default.yellow(y)} ${Rn({options:this.options,cursor:this.cursor,maxItems:t.maxItems,style:o}).join(`
|
|
28
|
+
${l.default.yellow(y)} `)}
|
|
29
|
+
${s}
|
|
30
|
+
`}default:return`${r}${l.default.cyan(y)} ${Rn({options:this.options,cursor:this.cursor,maxItems:t.maxItems,style:o}).join(`
|
|
31
|
+
${l.default.cyan(y)} `)}
|
|
32
|
+
${l.default.cyan(Ue)}
|
|
33
|
+
`}}}).prompt()},Ge=(t="",e="")=>{let r=`
|
|
34
|
+
${t}
|
|
35
|
+
`.split(`
|
|
36
|
+
`),o=dr(e).length,s=Math.max(r.reduce((n,u)=>{let c=dr(u);return c.length>n?c.length:n},0),o)+2,i=r.map(n=>`${l.default.gray(y)} ${l.default.dim(n)}${" ".repeat(s-dr(n).length)}${l.default.gray(y)}`).join(`
|
|
37
|
+
`);process.stdout.write(`${l.default.gray(y)}
|
|
38
|
+
${l.default.green(yt)} ${l.default.reset(e)} ${l.default.gray($n.repeat(Math.max(s-o-1,1))+hi)}
|
|
39
|
+
${i}
|
|
40
|
+
${l.default.gray(Fi+$n.repeat(s+2)+Si)}
|
|
41
|
+
`)},He=(t="")=>{process.stdout.write(`${l.default.gray(Ue)} ${l.default.red(t)}
|
|
42
|
+
|
|
43
|
+
`)},wt=(t="")=>{process.stdout.write(`${l.default.gray(fi)} ${t}
|
|
44
|
+
`)},pe=(t="")=>{process.stdout.write(`${l.default.gray(y)}
|
|
45
|
+
${l.default.gray(Ue)} ${t}
|
|
46
|
+
|
|
47
|
+
`)},R={message:(t="",{symbol:e=l.default.gray(y)}={})=>{let r=[`${l.default.gray(y)}`];if(t){let[o,...s]=t.split(`
|
|
48
|
+
`);r.push(`${e} ${o}`,...s.map(i=>`${l.default.gray(y)} ${i}`))}process.stdout.write(`${r.join(`
|
|
26
49
|
`)}
|
|
27
|
-
`)},info:
|
|
28
|
-
|
|
29
|
-
`)},
|
|
30
|
-
`)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
${d("gray",k)}`:""}`}case"error":{let c=n?`${d("yellow",k)} `:"",u=this.error.split(`
|
|
40
|
-
`).map((h,E)=>E===0?`${n?`${d("yellow",ot)} `:""}${d("yellow",h)}`:` ${h}`).join(`
|
|
41
|
-
`),g=s.split(`
|
|
42
|
-
`).length,f=u.split(`
|
|
43
|
-
`).length+1;return`${s}${c}${so({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:c.length,rowPadding:g+f,style:a}).join(`
|
|
44
|
-
${c}`)}
|
|
45
|
-
${u}
|
|
46
|
-
`}default:{let c=n?`${d("cyan",k)} `:"",u=s.split(`
|
|
47
|
-
`).length,g=n?2:1;return`${s}${c}${so({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:c.length,rowPadding:u+g,style:a}).join(`
|
|
48
|
-
${c}`)}
|
|
49
|
-
${n?d("cyan",ot):""}
|
|
50
|
-
`}}}}).prompt()},Ji=e=>d("dim",e),Yi=(e,t,r)=>{let n={hard:!0,trim:!1},o=ie(e,t,n).split(`
|
|
51
|
-
`),s=o.reduce((c,u)=>Math.max(H(u),c),0),i=o.map(r).reduce((c,u)=>Math.max(H(u),c),0),a=t-(i-s);return ie(e,a,n)},at=(e="",t="",r)=>{let n=r?.output??Z.stdout,o=r?.withGuide??j.withGuide,s=r?.format??Ji,i=["",...Yi(e,et(n)-6,s).split(`
|
|
52
|
-
`).map(s),""],a=H(t),c=Math.max(i.reduce((h,E)=>{let p=H(E);return p>h?p:h},0),a)+2,u=i.map(h=>`${d("gray",k)} ${h}${" ".repeat(c-H(h))}${d("gray",k)}`).join(`
|
|
53
|
-
`),g=o?`${d("gray",k)}
|
|
54
|
-
`:"",f=o?Ni:ji;n.write(`${g}${d("green",Gt)} ${d("reset",t)} ${d("gray",oo.repeat(Math.max(c-a-1,1))+Li)}
|
|
55
|
-
${u}
|
|
56
|
-
${d("gray",f+oo.repeat(c+2)+Ui)}
|
|
57
|
-
`)},Xi=e=>d("magenta",e),zi=({indicator:e="dots",onCancel:t,output:r=process.stdout,cancelMessage:n,errorMessage:o,frames:s=Fr?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:i=Fr?80:120,signal:a,...c}={})=>{let u=Pi(),g,f,h=!1,E=!1,p="",m,y=performance.now(),P=et(r),O=c?.styleFrame??Xi,M=A=>{let q=A>1?o??j.messages.error:n??j.messages.cancel;E=A===1,h&&(Ye(q,A),E&&typeof t=="function"&&t())},R=()=>M(2),_=()=>M(1),T=()=>{process.on("uncaughtExceptionMonitor",R),process.on("unhandledRejection",R),process.on("SIGINT",_),process.on("SIGTERM",_),process.on("exit",M),a&&a.addEventListener("abort",_)},C=()=>{process.removeListener("uncaughtExceptionMonitor",R),process.removeListener("unhandledRejection",R),process.removeListener("SIGINT",_),process.removeListener("SIGTERM",_),process.removeListener("exit",M),a&&a.removeEventListener("abort",_)},$=()=>{if(m===void 0)return;u&&r.write(`
|
|
58
|
-
`);let A=ie(m,P,{hard:!0,trim:!1}).split(`
|
|
59
|
-
`);A.length>1&&r.write(nt.cursor.up(A.length-1)),r.write(nt.cursor.to(0)),r.write(nt.erase.down())},ue=A=>A.replace(/\.+$/,""),we=A=>{let q=(performance.now()-A)/1e3,de=Math.floor(q/60),pe=Math.floor(q%60);return de>0?`[${de}m ${pe}s]`:`[${pe}s]`},ve=c.withGuide??j.withGuide,qs=(A="")=>{h=!0,g=qn({output:r}),p=ue(A),y=performance.now(),ve&&r.write(`${d("gray",k)}
|
|
60
|
-
`);let q=0,de=0;T(),f=setInterval(()=>{if(u&&p===m)return;$(),m=p;let pe=O(s[q]),Mt;if(u)Mt=`${pe} ${p}...`;else if(e==="timer")Mt=`${pe} ${p} ${we(y)}`;else{let Qs=".".repeat(Math.floor(de)).slice(0,3);Mt=`${pe} ${p}${Qs}`}let Zs=ie(Mt,P,{hard:!0,trim:!1});r.write(Zs),q=q+1<s.length?q+1:0,de=de<4?de+.125:0},i)},Ye=(A="",q=0,de=!1)=>{if(!h)return;h=!1,clearInterval(f),$();let pe=q===0?d("green",Gt):q===1?d("red",io):d("red",ao);p=A??p,de||(e==="timer"?r.write(`${pe} ${p} ${we(y)}
|
|
61
|
-
`):r.write(`${pe} ${p}
|
|
62
|
-
`)),C(),g()};return{start:qs,stop:(A="")=>Ye(A,0),message:(A="")=>{p=ue(A??p)},cancel:(A="")=>Ye(A,1),error:(A="")=>Ye(A,2),clear:()=>Ye("",0,!0),get isCancelled(){return E}}},ju={light:x("\u2500","-"),heavy:x("\u2501","="),block:x("\u2588","#")},Gu=`${d("gray",k)} `,Ht=async(e,t)=>{for(let r of e){if(r.enabled===!1)continue;let n=zi(t);n.start(r.title);let o=await r.task(n.message);n.stop(o||r.title)}}});import{readFileSync as qi,writeFileSync as po,existsSync as mo,mkdirSync as Zi}from"fs";import{join as go,dirname as Qi}from"path";import{homedir as fo}from"os";var F,ke=S(()=>{"use strict";F=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-sonnet-4-6",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:String(37700+(process.getuid?.()??77)%100),CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_PROVIDER:"claude",CLAUDE_MEM_CLAUDE_AUTH_METHOD:"cli",CLAUDE_MEM_GEMINI_API_KEY:"",CLAUDE_MEM_GEMINI_MODEL:"gemini-2.5-flash-lite",CLAUDE_MEM_GEMINI_RATE_LIMITING_ENABLED:"true",CLAUDE_MEM_GEMINI_MAX_CONTEXT_MESSAGES:"20",CLAUDE_MEM_GEMINI_MAX_TOKENS:"100000",CLAUDE_MEM_OPENROUTER_API_KEY:"",CLAUDE_MEM_OPENROUTER_MODEL:"xiaomi/mimo-v2-flash:free",CLAUDE_MEM_OPENROUTER_SITE_URL:"",CLAUDE_MEM_OPENROUTER_APP_NAME:"claude-mem",CLAUDE_MEM_OPENROUTER_MAX_CONTEXT_MESSAGES:"20",CLAUDE_MEM_OPENROUTER_MAX_TOKENS:"100000",CLAUDE_MEM_DATA_DIR:go(fo(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_MODE:"code",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"false",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"false",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"false",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_FULL_COUNT:"0",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",CLAUDE_MEM_CONTEXT_SHOW_TERMINAL_OUTPUT:"true",CLAUDE_MEM_FOLDER_CLAUDEMD_ENABLED:"false",CLAUDE_MEM_FOLDER_USE_LOCAL_MD:"false",CLAUDE_MEM_TRANSCRIPTS_ENABLED:"true",CLAUDE_MEM_TRANSCRIPTS_CONFIG_PATH:go(fo(),".claude-mem","transcript-watch.json"),CLAUDE_MEM_MAX_CONCURRENT_AGENTS:"2",CLAUDE_MEM_HOOK_FAIL_LOUD_THRESHOLD:"3",CLAUDE_MEM_EXCLUDED_PROJECTS:"",CLAUDE_MEM_FOLDER_MD_EXCLUDE:"[]",CLAUDE_MEM_SEMANTIC_INJECT:"false",CLAUDE_MEM_SEMANTIC_INJECT_LIMIT:"5",CLAUDE_MEM_TIER_ROUTING_ENABLED:"true",CLAUDE_MEM_TIER_SIMPLE_MODEL:"haiku",CLAUDE_MEM_TIER_SUMMARY_MODEL:"",CLAUDE_MEM_CHROMA_ENABLED:"true",CLAUDE_MEM_CHROMA_MODE:"local",CLAUDE_MEM_CHROMA_HOST:"127.0.0.1",CLAUDE_MEM_CHROMA_PORT:"8000",CLAUDE_MEM_CHROMA_SSL:"false",CLAUDE_MEM_CHROMA_API_KEY:"",CLAUDE_MEM_CHROMA_TENANT:"default_tenant",CLAUDE_MEM_CHROMA_DATABASE:"default_database",CLAUDE_MEM_TELEGRAM_ENABLED:"true",CLAUDE_MEM_TELEGRAM_BOT_TOKEN:"",CLAUDE_MEM_TELEGRAM_CHAT_ID:"",CLAUDE_MEM_TELEGRAM_TRIGGER_TYPES:"security_alert",CLAUDE_MEM_TELEGRAM_TRIGGER_CONCEPTS:""};static getAllDefaults(){return{...this.DEFAULTS}}static get(t){return process.env[t]??this.DEFAULTS[t]}static getInt(t){let r=this.get(t);return parseInt(r,10)}static getBool(t){let r=this.get(t);return r==="true"||r===!0}static applyEnvOverrides(t){let r={...t};for(let n of Object.keys(this.DEFAULTS))process.env[n]!==void 0&&(r[n]=process.env[n]);return r}static loadFromFile(t){try{if(!mo(t)){let i=this.getAllDefaults();try{let a=Qi(t);mo(a)||Zi(a,{recursive:!0}),po(t,JSON.stringify(i,null,2),"utf-8"),console.log("[SETTINGS] Created settings file with defaults:",t)}catch(a){console.warn("[SETTINGS] Failed to create settings file, using in-memory defaults:",t,a instanceof Error?a.message:String(a))}return this.applyEnvOverrides(i)}let r=qi(t,"utf-8"),n=JSON.parse(r),o=n;if(n.env&&typeof n.env=="object"){o=n.env;try{po(t,JSON.stringify(o,null,2),"utf-8"),console.log("[SETTINGS] Migrated settings file from nested to flat schema:",t)}catch(i){console.warn("[SETTINGS] Failed to auto-migrate settings file:",t,i instanceof Error?i.message:String(i))}}let s={...this.DEFAULTS};for(let i of Object.keys(this.DEFAULTS))o[i]!==void 0&&(s[i]=o[i]);return this.applyEnvOverrides(s)}catch(r){return console.warn("[SETTINGS] Failed to load settings, using defaults:",t,r instanceof Error?r.message:String(r)),this.applyEnvOverrides(this.getAllDefaults())}}}});async function Bt(e,t=1e4){let r=`http://127.0.0.1:${e}`,n=!1;try{await fetch(`${r}/api/admin/shutdown`,{method:"POST",signal:AbortSignal.timeout(5e3)}),n=!0}catch{return{workerWasRunning:!1,confirmedStopped:!0}}let o=500,s=Math.ceil(t/o);for(let i=0;i<s;i++){await new Promise(a=>setTimeout(a,o));try{await fetch(`${r}/api/health`,{signal:AbortSignal.timeout(1e3)})}catch(a){if(a instanceof Error&&a.name==="AbortError")continue;return{workerWasRunning:n,confirmedStopped:!0}}}return{workerWasRunning:n,confirmedStopped:!1}}var Nr=S(()=>{"use strict"});import{execSync as ea}from"child_process";import{existsSync as re,readdirSync as ta}from"fs";import{homedir as ho}from"os";import{join as ne}from"path";function ct(e){try{return ea(`${me?"where":"which"} ${e}`,{stdio:"pipe"}),!0}catch(t){return process.env.DEBUG&&console.error(`[ide-detection] ${e} not in PATH:`,t instanceof Error?t.message:String(t)),!1}}function ra(e){let t=ne(ho(),".vscode","extensions");if(!re(t))return!1;try{return ta(t).some(n=>n.toLowerCase().includes(e.toLowerCase()))}catch(r){return console.warn("[ide-detection] Failed to read VS Code extensions directory:",r instanceof Error?r.message:String(r)),!1}}function lt(){let e=ho();return[{id:"claude-code",label:"Claude Code",detected:re(ne(e,".claude")),supported:!0,hint:"recommended"},{id:"gemini-cli",label:"Gemini CLI",detected:re(ne(e,".gemini")),supported:!0},{id:"opencode",label:"OpenCode",detected:re(ne(e,".config","opencode"))||ct("opencode"),supported:!0,hint:"plugin-based integration"},{id:"openclaw",label:"OpenClaw",detected:re(ne(e,".openclaw")),supported:!0,hint:"plugin-based integration"},{id:"windsurf",label:"Windsurf",detected:re(ne(e,".codeium","windsurf")),supported:!0},{id:"codex-cli",label:"Codex CLI",detected:re(ne(e,".codex")),supported:!0,hint:"transcript-based integration"},{id:"cursor",label:"Cursor",detected:re(ne(e,".cursor")),supported:!0,hint:"hooks + MCP integration"},{id:"copilot-cli",label:"Copilot CLI",detected:ct("copilot"),supported:!0,hint:"MCP-based integration"},{id:"antigravity",label:"Antigravity",detected:re(ne(e,".gemini","antigravity")),supported:!0,hint:"MCP-based integration"},{id:"goose",label:"Goose",detected:re(ne(e,".config","goose"))||ct("goose"),supported:!0,hint:"MCP-based integration"},{id:"crush",label:"Crush",detected:ct("crush"),supported:!0,hint:"MCP-based integration"},{id:"roo-code",label:"Roo Code",detected:ra("roo-code"),supported:!0,hint:"MCP-based integration"},{id:"warp",label:"Warp",detected:re(ne(e,".warp"))||ct("warp"),supported:!0,hint:"MCP-based integration"}]}var Eo=S(()=>{"use strict";xe()});import{appendFileSync as na,existsSync as So,mkdirSync as oa,readFileSync as sa}from"fs";import{join as Kt}from"path";import{homedir as ia}from"os";var Ur,Co,jr,l,J=S(()=>{"use strict";Ur=(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))(Ur||{}),Co=Kt(ia(),".claude-mem"),jr=class{level=null;useColor;logFilePath=null;logFileInitialized=!1;constructor(){this.useColor=process.stdout.isTTY??!1}ensureLogFileInitialized(){if(!this.logFileInitialized){this.logFileInitialized=!0;try{let t=Kt(Co,"logs");So(t)||oa(t,{recursive:!0});let r=new Date().toISOString().split("T")[0];this.logFilePath=Kt(t,`claude-mem-${r}.log`)}catch(t){console.error("[LOGGER] Failed to initialize log file:",t instanceof Error?t.message:String(t)),this.logFilePath=null}}}getLevel(){if(this.level===null)try{let t=Kt(Co,"settings.json");if(So(t)){let r=sa(t,"utf-8"),o=(JSON.parse(r).CLAUDE_MEM_LOG_LEVEL||"INFO").toUpperCase();this.level=Ur[o]??1}else this.level=1}catch(t){console.error("[LOGGER] Failed to load log level from settings:",t instanceof Error?t.message:String(t)),this.level=1}return this.level}correlationId(t,r){return`obs-${t}-${r}`}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}
|
|
63
|
-
${t.stack}`:t.message;if(Array.isArray(t))return`[${t.length} items]`;let r=Object.keys(t);return r.length===0?"{}":r.length<=3?JSON.stringify(t):`{${r.length} keys: ${r.slice(0,3).join(", ")}...}`}return String(t)}formatTool(t,r){if(!r)return t;let n=r;if(typeof r=="string")try{n=JSON.parse(r)}catch{n=r}if(t==="Bash"&&n.command)return`${t}(${n.command})`;if(n.file_path)return`${t}(${n.file_path})`;if(n.notebook_path)return`${t}(${n.notebook_path})`;if(t==="Glob"&&n.pattern)return`${t}(${n.pattern})`;if(t==="Grep"&&n.pattern)return`${t}(${n.pattern})`;if(n.url)return`${t}(${n.url})`;if(n.query)return`${t}(${n.query})`;if(t==="Task"){if(n.subagent_type)return`${t}(${n.subagent_type})`;if(n.description)return`${t}(${n.description})`}return t==="Skill"&&n.skill?`${t}(${n.skill})`:t==="LSP"&&n.operation?`${t}(${n.operation})`:t}formatTimestamp(t){let r=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0"),a=String(t.getSeconds()).padStart(2,"0"),c=String(t.getMilliseconds()).padStart(3,"0");return`${r}-${n}-${o} ${s}:${i}:${a}.${c}`}log(t,r,n,o,s){if(t<this.getLevel())return;this.ensureLogFileInitialized();let i=this.formatTimestamp(new Date),a=Ur[t].padEnd(5),c=r.padEnd(6),u="";o?.correlationId?u=`[${o.correlationId}] `:o?.sessionId&&(u=`[session-${o.sessionId}] `);let g="";s!=null&&(s instanceof Error?g=this.getLevel()===0?`
|
|
64
|
-
${s.message}
|
|
65
|
-
${s.stack}`:` ${s.message}`:this.getLevel()===0&&typeof s=="object"?g=`
|
|
66
|
-
`+JSON.stringify(s,null,2):g=" "+this.formatData(s));let f="";if(o){let{sessionId:E,memorySessionId:p,correlationId:m,...y}=o;Object.keys(y).length>0&&(f=` {${Object.entries(y).map(([O,M])=>`${O}=${M}`).join(", ")}}`)}let h=`[${i}] [${a}] [${c}] ${u}${n}${f}${g}`;if(this.logFilePath)try{na(this.logFilePath,h+`
|
|
67
|
-
`,"utf8")}catch(E){process.stderr.write(`[LOGGER] Failed to write to log file: ${E instanceof Error?E.message:String(E)}
|
|
68
|
-
`)}else process.stderr.write(h+`
|
|
69
|
-
`)}debug(t,r,n,o){this.log(0,t,r,n,o)}info(t,r,n,o){this.log(1,t,r,n,o)}warn(t,r,n,o){this.log(2,t,r,n,o)}error(t,r,n,o){this.log(3,t,r,n,o)}dataIn(t,r,n,o){this.info(t,`\u2192 ${r}`,n,o)}dataOut(t,r,n,o){this.info(t,`\u2190 ${r}`,n,o)}success(t,r,n,o){this.info(t,`\u2713 ${r}`,n,o)}failure(t,r,n,o){this.error(t,`\u2717 ${r}`,n,o)}timing(t,r,n,o){this.info(t,`\u23F1 ${r}`,o,{duration:`${n}ms`})}happyPathError(t,r,n,o,s=""){let u=((new Error().stack||"").split(`
|
|
70
|
-
`)[2]||"").match(/at\s+(?:.*\s+)?\(?([^:]+):(\d+):(\d+)\)?/),g=u?`${u[1].split("/").pop()}:${u[2]}`:"unknown",f={...n,location:g};return this.warn(t,`[HAPPY-PATH] ${r}`,f,o),s}},l=new jr});function yo(e){return process.platform==="win32"?Math.round(e*ut.WINDOWS_MULTIPLIER):e}var ut,Gr=S(()=>{"use strict";ut={DEFAULT:3e5,HEALTH_CHECK:3e3,POST_SPAWN_WAIT:15e3,READINESS_WAIT:3e4,PORT_IN_USE_WAIT:3e3,WORKER_STARTUP_WAIT:1e3,PRE_RESTART_SETTLE_DELAY:2e3,POWERSHELL_COMMAND:1e4,WINDOWS_MULTIPLIER:1.5}});import{join as G,dirname as aa,basename as ca}from"path";import{homedir as wo}from"os";import{existsSync as la,mkdirSync as ld}from"fs";import{execSync as dd}from"child_process";import{fileURLToPath as ua}from"url";function da(){return typeof __dirname<"u"?__dirname:aa(ua(import.meta.url))}function pa(){if(process.env.CLAUDE_MEM_DATA_DIR)return process.env.CLAUDE_MEM_DATA_DIR;let e=G(wo(),".claude-mem"),t=G(e,"settings.json");try{if(la(t)){let{readFileSync:r}=si("fs"),n=JSON.parse(r(t,"utf-8")),o=n.env??n;if(o.CLAUDE_MEM_DATA_DIR)return o.CLAUDE_MEM_DATA_DIR}}catch{}return e}var gd,Y,De,Vt,fd,hd,Ed,Sd,Cd,ma,yd,wd,ga,vd,_d,xd,$d,dt=S(()=>{"use strict";J();gd=da();Y=pa(),De=process.env.CLAUDE_CONFIG_DIR||G(wo(),".claude"),Vt=G(De,"plugins","marketplaces","thedotmack"),fd=G(Y,"archives"),hd=G(Y,"logs"),Ed=G(Y,"trash"),Sd=G(Y,"backups"),Cd=G(Y,"modes"),ma=G(Y,"settings.json"),yd=G(Y,"claude-mem.db"),wd=G(Y,"vector-db"),ga=G(Y,"observer-sessions"),vd=ca(ga),_d=G(De,"settings.json"),xd=G(De,"commands"),$d=G(De,"CLAUDE.md")});var vo=S(()=>{"use strict";ke();dt()});var _o=S(()=>{"use strict"});import{spawn as Dd,spawnSync as fa}from"child_process";import{existsSync as ha,mkdirSync as xo,readFileSync as $o,writeFileSync as Ea}from"fs";import{homedir as Sa}from"os";import Jt from"path";function ae(e){if(!Number.isInteger(e)||e<0||e===0)return!1;try{return process.kill(e,0),!0}catch(t){if(t instanceof Error){let r=t.code;return r==="EPERM"?!0:(l.debug("SYSTEM","PID check failed",{pid:e,code:r}),!1)}return l.warn("SYSTEM","PID check threw non-Error",{pid:e,error:String(t)}),!1}}function _a(e){if(!Number.isInteger(e)||e<=0)return null;if(process.platform==="linux")try{let t=$o(`/proc/${e}/stat`,"utf-8"),r=t.lastIndexOf(") ");if(r<0)return null;let o=t.slice(r+2).split(" ")[19];return o&&/^\d+$/.test(o)?o:null}catch(t){return l.debug("SYSTEM","captureProcessStartToken: /proc read failed",{pid:e,error:t instanceof Error?t.message:String(t)}),null}if(process.platform==="win32")return null;try{let t=fa("ps",["-p",String(e),"-o","lstart="],{encoding:"utf-8",timeout:2e3,env:{...process.env,LC_ALL:"C",LANG:"C"}});if(t.status!==0)return null;let r=t.stdout.trim();return r.length>0?r:null}catch(t){return l.debug("SYSTEM","captureProcessStartToken: ps exec failed",{pid:e,error:t instanceof Error?t.message:String(t)}),null}}function ko(e){if(!e||!ae(e.pid))return!1;if(!e.startToken)return!0;let t=_a(e.pid);if(t===null)return!0;let r=t===e.startToken;return r||l.debug("SYSTEM","verifyPidFileOwnership: start-token mismatch (PID reused)",{pid:e.pid,stored:e.startToken,current:t}),r}function Yt(){return Wr||(Wr=new Hr),Wr}var Ca,ya,wa,va,Hr,Wr,Xt=S(()=>{"use strict";J();_o();Ca=5e3,ya=1e3,wa=Jt.join(Sa(),".claude-mem"),va=Jt.join(wa,"supervisor.json");Hr=class{registryPath;entries=new Map;runtimeProcesses=new Map;initialized=!1;constructor(t=va){this.registryPath=t}initialize(){if(this.initialized)return;if(this.initialized=!0,xo(Jt.dirname(this.registryPath),{recursive:!0}),!ha(this.registryPath)){this.persist();return}try{let n=JSON.parse($o(this.registryPath,"utf-8")).processes??{};for(let[o,s]of Object.entries(n))this.entries.set(o,s)}catch(r){r instanceof Error?l.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath},r):l.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath,error:String(r)}),this.entries.clear()}let t=this.pruneDeadEntries();t>0&&l.info("SYSTEM","Removed dead processes from supervisor registry",{removed:t}),this.persist()}register(t,r,n){this.initialize(),this.entries.set(t,r),n&&this.runtimeProcesses.set(t,n),this.persist()}unregister(t){this.initialize(),this.entries.delete(t),this.runtimeProcesses.delete(t),this.persist()}clear(){this.entries.clear(),this.runtimeProcesses.clear(),this.persist()}getAll(){return this.initialize(),Array.from(this.entries.entries()).map(([t,r])=>({id:t,...r})).sort((t,r)=>{let n=Date.parse(t.startedAt),o=Date.parse(r.startedAt);return(Number.isNaN(n)?0:n)-(Number.isNaN(o)?0:o)})}getBySession(t){let r=String(t);return this.getAll().filter(n=>n.sessionId!==void 0&&String(n.sessionId)===r)}getRuntimeProcess(t){return this.runtimeProcesses.get(t)}getByPid(t){return this.getAll().filter(r=>r.pid===t)}pruneDeadEntries(){this.initialize();let t=0;for(let[r,n]of this.entries)ae(n.pid)||(this.entries.delete(r),this.runtimeProcesses.delete(r),t+=1);return t>0&&this.persist(),t}async reapSession(t){this.initialize();let r=this.getBySession(t);if(r.length===0)return 0;let n=typeof t=="number"?t:Number(t)||void 0;l.info("SYSTEM",`Reaping ${r.length} process(es) for session ${t}`,{sessionId:n,pids:r.map(a=>a.pid)});let o=r.filter(a=>ae(a.pid));for(let a of o)try{typeof a.pgid=="number"&&process.platform!=="win32"?process.kill(-a.pgid,"SIGTERM"):process.kill(a.pid,"SIGTERM")}catch(c){c instanceof Error?c.code!=="ESRCH"&&l.debug("SYSTEM",`Failed to SIGTERM session process PID ${a.pid}`,{pid:a.pid,pgid:a.pgid},c):l.warn("SYSTEM",`Failed to SIGTERM session process PID ${a.pid} (non-Error)`,{pid:a.pid,pgid:a.pgid,error:String(c)})}let s=Date.now()+Ca;for(;Date.now()<s&&o.filter(c=>ae(c.pid)).length!==0;)await new Promise(c=>setTimeout(c,100));let i=o.filter(a=>ae(a.pid));for(let a of i){l.warn("SYSTEM",`Session process PID ${a.pid} did not exit after SIGTERM, sending SIGKILL`,{pid:a.pid,pgid:a.pgid,sessionId:n});try{typeof a.pgid=="number"&&process.platform!=="win32"?process.kill(-a.pgid,"SIGKILL"):process.kill(a.pid,"SIGKILL")}catch(c){c instanceof Error?c.code!=="ESRCH"&&l.debug("SYSTEM",`Failed to SIGKILL session process PID ${a.pid}`,{pid:a.pid,pgid:a.pgid},c):l.warn("SYSTEM",`Failed to SIGKILL session process PID ${a.pid} (non-Error)`,{pid:a.pid,pgid:a.pgid,error:String(c)})}}if(i.length>0){let a=Date.now()+ya;for(;Date.now()<a&&i.filter(u=>ae(u.pid)).length!==0;)await new Promise(u=>setTimeout(u,100))}for(let a of r)this.entries.delete(a.id),this.runtimeProcesses.delete(a.id);return this.persist(),l.info("SYSTEM",`Reaped ${r.length} process(es) for session ${t}`,{sessionId:n,reaped:r.length}),r.length}persist(){let t={processes:Object.fromEntries(this.entries.entries())};xo(Jt.dirname(this.registryPath),{recursive:!0}),Ea(this.registryPath,JSON.stringify(t,null,2))}},Wr=null});import{execFile as xa}from"child_process";import{rmSync as $a}from"fs";import{homedir as ka}from"os";import Mo from"path";import{promisify as Ia}from"util";async function Ao(e){let t=e.currentPid??process.pid,r=e.pidFilePath??Aa,n=e.registry.getAll(),o=[...n].filter(i=>i.pid!==t).sort((i,a)=>Date.parse(a.startedAt)-Date.parse(i.startedAt));for(let i of o){if(!ae(i.pid)){e.registry.unregister(i.id);continue}try{await bo(i,"SIGTERM")}catch(a){a instanceof Error?l.debug("SYSTEM","Failed to send SIGTERM to child process",{pid:i.pid,pgid:i.pgid,type:i.type},a):l.warn("SYSTEM","Failed to send SIGTERM to child process (non-Error)",{pid:i.pid,pgid:i.pgid,type:i.type,error:String(a)})}}await Io(o,5e3);let s=o.filter(i=>ae(i.pid));for(let i of s)try{await bo(i,"SIGKILL")}catch(a){a instanceof Error?l.debug("SYSTEM","Failed to force kill child process",{pid:i.pid,pgid:i.pgid,type:i.type},a):l.warn("SYSTEM","Failed to force kill child process (non-Error)",{pid:i.pid,pgid:i.pgid,type:i.type,error:String(a)})}await Io(s,1e3);for(let i of o)e.registry.unregister(i.id);for(let i of n.filter(a=>a.pid===t))e.registry.unregister(i.id);try{$a(r,{force:!0})}catch(i){i instanceof Error?l.debug("SYSTEM","Failed to remove PID file during shutdown",{pidFilePath:r},i):l.warn("SYSTEM","Failed to remove PID file during shutdown (non-Error)",{pidFilePath:r,error:String(i)})}e.registry.pruneDeadEntries()}async function Io(e,t){let r=Date.now()+t;for(;Date.now()<r;){if(e.filter(o=>ae(o.pid)).length===0)return;await new Promise(o=>setTimeout(o,100))}}async function bo(e,t){let{pid:r,pgid:n}=e;if(process.platform!=="win32"){try{typeof n=="number"?process.kill(-n,t):process.kill(r,t)}catch(i){if(i instanceof Error&&i.code==="ESRCH")return;throw i}return}if(t==="SIGTERM"){try{process.kill(r,t)}catch(i){if(i instanceof Error&&i.code==="ESRCH")return;throw i}return}let o=await Ta();if(o){await new Promise((i,a)=>{o(r,t,c=>{if(!c){i();return}if(c.code==="ESRCH"){i();return}a(c)})});return}let s=["/PID",String(r),"/T"];t==="SIGKILL"&&s.push("/F"),await ba("taskkill",s,{timeout:ut.POWERSHELL_COMMAND,windowsHide:!0})}async function Ta(){let e="tree-kill";try{let t=await import(e);return t.default??t}catch(t){return l.debug("SYSTEM","tree-kill module not available, using fallback",{},t instanceof Error?t:void 0),null}}var ba,Ma,Aa,To=S(()=>{"use strict";J();Gr();Xt();ba=Ia(xa),Ma=Mo.join(ka(),".claude-mem"),Aa=Mo.join(Ma,"worker.pid")});function Ra(){let t=Yt().pruneDeadEntries();t>0&&l.info("SYSTEM",`Health check: pruned ${t} dead process(es) from registry`)}function Po(){Oe===null&&(Oe=setInterval(Ra,Ro),Oe.unref(),l.debug("SYSTEM","Health checker started",{intervalMs:Ro}))}function Do(){Oe!==null&&(clearInterval(Oe),Oe=null,l.debug("SYSTEM","Health checker stopped"))}var Ro,Oe,Oo=S(()=>{"use strict";J();Xt();Ro=3e4,Oe=null});import{existsSync as Pa,readFileSync as Da,rmSync as Fo}from"fs";import{homedir as Oa}from"os";import Lo from"path";function No(e={}){let t=e.pidFilePath??La;if(!Pa(t))return"missing";let r=null;try{r=JSON.parse(Da(t,"utf-8"))}catch(o){return o instanceof Error?l.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:t},o):l.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:t,error:String(o)}),Fo(t,{force:!0}),"invalid"}return ko(r)&&r?((e.logAlive??!0)&&l.info("SYSTEM","Worker already running (PID alive)",{existingPid:r.pid,existingPort:r.port,startedAt:r.startedAt}),"alive"):(l.info("SYSTEM","Removing stale PID file (worker process is dead or PID has been reused)",{pid:r?.pid,port:r?.port,startedAt:r?.startedAt}),Fo(t,{force:!0}),"stale")}var Fa,La,Br,ip,Uo=S(()=>{"use strict";J();Xt();To();Oo();Fa=Lo.join(Oa(),".claude-mem"),La=Lo.join(Fa,"worker.pid"),Br=class{registry;started=!1;stopPromise=null;signalHandlersRegistered=!1;shutdownInitiated=!1;shutdownHandler=null;constructor(t){this.registry=t}async start(){if(this.started)return;if(this.registry.initialize(),No({logAlive:!1})==="alive")throw new Error("Worker already running");this.started=!0,Po()}configureSignalHandlers(t){if(this.shutdownHandler=t,this.signalHandlersRegistered)return;this.signalHandlersRegistered=!0;let r=async n=>{if(this.shutdownInitiated){l.warn("SYSTEM",`Received ${n} but shutdown already in progress`);return}this.shutdownInitiated=!0,l.info("SYSTEM",`Received ${n}, shutting down...`);try{this.shutdownHandler?await this.shutdownHandler():await this.stop()}catch(o){o instanceof Error?l.error("SYSTEM","Error during shutdown",{},o):l.error("SYSTEM","Error during shutdown (non-Error)",{error:String(o)});try{await this.stop()}catch(s){s instanceof Error?l.debug("SYSTEM","Supervisor shutdown fallback failed",{},s):l.debug("SYSTEM","Supervisor shutdown fallback failed",{error:String(s)})}}process.exit(0)};process.on("SIGTERM",()=>{r("SIGTERM")}),process.on("SIGINT",()=>{r("SIGINT")}),process.platform!=="win32"&&(process.argv.includes("--daemon")?process.on("SIGHUP",()=>{l.debug("SYSTEM","Ignoring SIGHUP in daemon mode")}):process.on("SIGHUP",()=>{r("SIGHUP")}))}async stop(){if(this.stopPromise){await this.stopPromise;return}Do(),this.stopPromise=Ao({registry:this.registry,currentPid:process.pid}).finally(()=>{this.started=!1,this.stopPromise=null}),await this.stopPromise}assertCanSpawn(t){if(this.stopPromise!==null)throw new Error(`Supervisor is shutting down, refusing to spawn ${t}`)}registerProcess(t,r,n){this.registry.register(t,r,n)}unregisterProcess(t){this.registry.unregister(t)}getRegistry(){return this.registry}},ip=new Br(Yt())});import jo from"path";import{readFileSync as pp,existsSync as mp,writeFileSync as gp,renameSync as fp,mkdirSync as hp}from"fs";import{spawn as Sp,execSync as Cp}from"child_process";function Ua(e,t={},r){return new Promise((n,o)=>{let s=setTimeout(()=>o(new Error(`Request timed out after ${r}ms`)),r);fetch(e,t).then(i=>{clearTimeout(s),n(i)},i=>{clearTimeout(s),o(i)})})}function pt(){if(zt!==null)return zt;let e=jo.join(F.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),t=F.loadFromFile(e);return zt=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),zt}function ja(){if(qt!==null)return qt;let e=jo.join(F.get("CLAUDE_MEM_DATA_DIR"),"settings.json");return qt=F.loadFromFile(e).CLAUDE_MEM_WORKER_HOST,qt}function Ga(e){return`http://${ja()}:${pt()}${e}`}function Zt(e,t={}){let r=t.method??"GET",n=t.timeoutMs??Na,o=Ga(e),s={method:r};return t.headers&&(s.headers=t.headers),t.body&&(s.body=t.body),n>0?Ua(o,s,n):fetch(o,s)}var Na,zt,qt,Qt=S(()=>{"use strict";J();Gr();ke();dt();vo();Uo();Na=(()=>{let e=process.env.CLAUDE_MEM_HEALTH_TIMEOUT_MS;if(e){let t=parseInt(e,10);if(Number.isFinite(t)&&t>=500&&t<=3e5)return t;l.warn("SYSTEM","Invalid CLAUDE_MEM_HEALTH_TIMEOUT_MS, using default",{value:e,min:500,max:3e5})}return yo(ut.HEALTH_CHECK)})();zt=null,qt=null});import{existsSync as Wa,readFileSync as Ha,writeFileSync as Go,mkdirSync as Wo,renameSync as Ba}from"fs";import{join as Kr,basename as Mp}from"path";function Ho(e){try{return Wa(e)?JSON.parse(Ha(e,"utf-8")):{}}catch(t){return l.error("CONFIG","Failed to read Cursor registry, using empty registry",{file:e,error:t instanceof Error?t.message:String(t)}),{}}}function Bo(e,t){let r=Kr(e,"..");Wo(r,{recursive:!0}),Go(e,JSON.stringify(t,null,2))}function Vr(e,t){let r=Kr(e,".cursor","rules"),n=Kr(r,"claude-mem-context.mdc"),o=`${n}.tmp`;Wo(r,{recursive:!0});let s=`---
|
|
50
|
+
`)},info:t=>{R.message(t,{symbol:l.default.blue(yi)})},success:t=>{R.message(t,{symbol:l.default.green(wi)})},step:t=>{R.message(t,{symbol:l.default.green(yt)})},warn:t=>{R.message(t,{symbol:l.default.yellow(vi)})},warning:t=>{R.warn(t)},error:t=>{R.message(t,{symbol:l.default.red(_i)})}},xi=()=>{let t=pr?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],e=pr?80:120,r=process.env.CI==="true",o,s,i=!1,n="",u,c=O=>{let K=O>1?"Something went wrong":"Canceled";i&&N(K,O)},D=()=>c(2),d=()=>c(1),p=()=>{process.on("uncaughtExceptionMonitor",D),process.on("unhandledRejection",D),process.on("SIGINT",d),process.on("SIGTERM",d),process.on("exit",c)},I=()=>{process.removeListener("uncaughtExceptionMonitor",D),process.removeListener("unhandledRejection",D),process.removeListener("SIGINT",d),process.removeListener("SIGTERM",d),process.removeListener("exit",c)},_=()=>{if(u===void 0)return;r&&process.stdout.write(`
|
|
51
|
+
`);let O=u.split(`
|
|
52
|
+
`);process.stdout.write(St.cursor.move(-999,O.length-1)),process.stdout.write(St.erase.down(O.length))},g=O=>O.replace(/\.+$/,""),h=(O="")=>{i=!0,o=kn(),n=g(O),process.stdout.write(`${l.default.gray(y)}
|
|
53
|
+
`);let K=0,oe=0;p(),s=setInterval(()=>{if(r&&n===u)return;_(),u=n;let _s=l.default.magenta(t[K]),xs=r?"...":".".repeat(Math.floor(oe)).slice(0,3);process.stdout.write(`${_s} ${n}${xs}`),K=K+1<t.length?K+1:0,oe=oe<t.length?oe+.125:0},e)},N=(O="",K=0)=>{i=!1,clearInterval(s),_();let oe=K===0?l.default.green(yt):K===1?l.default.red(Pn):l.default.red(Tn);n=g(O??n),process.stdout.write(`${oe} ${n}
|
|
54
|
+
`),I(),o()};return{start:h,stop:N,message:(O="")=>{n=g(O??n)}}},vt=async t=>{for(let e of t){if(e.enabled===!1)continue;let r=xi();r.start(e.title);let o=await e.task(r.message);r.stop(o||e.title)}}});import{readFileSync as ki,writeFileSync as Nn,existsSync as jn,mkdirSync as Ai}from"fs";import{join as Un,dirname as bi}from"path";import{homedir as Wn}from"os";var x,me=m(()=>{"use strict";x=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-sonnet-4-6",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:String(37700+(process.getuid?.()??77)%100),CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_PROVIDER:"claude",CLAUDE_MEM_CLAUDE_AUTH_METHOD:"cli",CLAUDE_MEM_GEMINI_API_KEY:"",CLAUDE_MEM_GEMINI_MODEL:"gemini-2.5-flash-lite",CLAUDE_MEM_GEMINI_RATE_LIMITING_ENABLED:"true",CLAUDE_MEM_GEMINI_MAX_CONTEXT_MESSAGES:"20",CLAUDE_MEM_GEMINI_MAX_TOKENS:"100000",CLAUDE_MEM_OPENROUTER_API_KEY:"",CLAUDE_MEM_OPENROUTER_MODEL:"xiaomi/mimo-v2-flash:free",CLAUDE_MEM_OPENROUTER_SITE_URL:"",CLAUDE_MEM_OPENROUTER_APP_NAME:"claude-mem",CLAUDE_MEM_OPENROUTER_MAX_CONTEXT_MESSAGES:"20",CLAUDE_MEM_OPENROUTER_MAX_TOKENS:"100000",CLAUDE_MEM_DATA_DIR:Un(Wn(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_MODE:"code",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"false",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"false",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"false",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_FULL_COUNT:"0",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",CLAUDE_MEM_CONTEXT_SHOW_TERMINAL_OUTPUT:"true",CLAUDE_MEM_FOLDER_CLAUDEMD_ENABLED:"false",CLAUDE_MEM_FOLDER_USE_LOCAL_MD:"false",CLAUDE_MEM_TRANSCRIPTS_ENABLED:"true",CLAUDE_MEM_TRANSCRIPTS_CONFIG_PATH:Un(Wn(),".claude-mem","transcript-watch.json"),CLAUDE_MEM_MAX_CONCURRENT_AGENTS:"2",CLAUDE_MEM_HOOK_FAIL_LOUD_THRESHOLD:"3",CLAUDE_MEM_EXCLUDED_PROJECTS:"",CLAUDE_MEM_FOLDER_MD_EXCLUDE:"[]",CLAUDE_MEM_SEMANTIC_INJECT:"false",CLAUDE_MEM_SEMANTIC_INJECT_LIMIT:"5",CLAUDE_MEM_TIER_ROUTING_ENABLED:"true",CLAUDE_MEM_TIER_SIMPLE_MODEL:"haiku",CLAUDE_MEM_TIER_SUMMARY_MODEL:"",CLAUDE_MEM_CHROMA_ENABLED:"true",CLAUDE_MEM_CHROMA_MODE:"local",CLAUDE_MEM_CHROMA_HOST:"127.0.0.1",CLAUDE_MEM_CHROMA_PORT:"8000",CLAUDE_MEM_CHROMA_SSL:"false",CLAUDE_MEM_CHROMA_API_KEY:"",CLAUDE_MEM_CHROMA_TENANT:"default_tenant",CLAUDE_MEM_CHROMA_DATABASE:"default_database",CLAUDE_MEM_TELEGRAM_ENABLED:"true",CLAUDE_MEM_TELEGRAM_BOT_TOKEN:"",CLAUDE_MEM_TELEGRAM_CHAT_ID:"",CLAUDE_MEM_TELEGRAM_TRIGGER_TYPES:"security_alert",CLAUDE_MEM_TELEGRAM_TRIGGER_CONCEPTS:""};static getAllDefaults(){return{...this.DEFAULTS}}static get(e){return process.env[e]??this.DEFAULTS[e]}static getInt(e){let r=this.get(e);return parseInt(r,10)}static getBool(e){let r=this.get(e);return r==="true"||r===!0}static applyEnvOverrides(e){let r={...e};for(let o of Object.keys(this.DEFAULTS))process.env[o]!==void 0&&(r[o]=process.env[o]);return r}static loadFromFile(e){try{if(!jn(e)){let n=this.getAllDefaults();try{let u=bi(e);jn(u)||Ai(u,{recursive:!0}),Nn(e,JSON.stringify(n,null,2),"utf-8"),console.log("[SETTINGS] Created settings file with defaults:",e)}catch(u){console.warn("[SETTINGS] Failed to create settings file, using in-memory defaults:",e,u instanceof Error?u.message:String(u))}return this.applyEnvOverrides(n)}let r=ki(e,"utf-8"),o=JSON.parse(r),s=o;if(o.env&&typeof o.env=="object"){s=o.env;try{Nn(e,JSON.stringify(s,null,2),"utf-8"),console.log("[SETTINGS] Migrated settings file from nested to flat schema:",e)}catch(n){console.warn("[SETTINGS] Failed to auto-migrate settings file:",e,n instanceof Error?n.message:String(n))}}let i={...this.DEFAULTS};for(let n of Object.keys(this.DEFAULTS))s[n]!==void 0&&(i[n]=s[n]);return this.applyEnvOverrides(i)}catch(r){return console.warn("[SETTINGS] Failed to load settings, using defaults:",e,r instanceof Error?r.message:String(r)),this.applyEnvOverrides(this.getAllDefaults())}}}});async function _t(t,e=1e4){let r=`http://127.0.0.1:${t}`,o=!1;try{await fetch(`${r}/api/admin/shutdown`,{method:"POST",signal:AbortSignal.timeout(5e3)}),o=!0}catch{return{workerWasRunning:!1,confirmedStopped:!0}}let s=500,i=Math.ceil(e/s);for(let n=0;n<i;n++){await new Promise(u=>setTimeout(u,s));try{await fetch(`${r}/api/health`,{signal:AbortSignal.timeout(1e3)})}catch(u){if(u instanceof Error&&u.name==="AbortError")continue;return{workerWasRunning:o,confirmedStopped:!0}}}return{workerWasRunning:o,confirmedStopped:!1}}var gr=m(()=>{"use strict"});import{execSync as Mi}from"child_process";import{existsSync as V,readdirSync as Ii}from"fs";import{homedir as Gn}from"os";import{join as X}from"path";function Ke(t){try{return Mi(`${te?"where":"which"} ${t}`,{stdio:"pipe"}),!0}catch(e){return process.env.DEBUG&&console.error(`[ide-detection] ${t} not in PATH:`,e instanceof Error?e.message:String(e)),!1}}function $i(t){let e=X(Gn(),".vscode","extensions");if(!V(e))return!1;try{return Ii(e).some(o=>o.toLowerCase().includes(t.toLowerCase()))}catch(r){return console.warn("[ide-detection] Failed to read VS Code extensions directory:",r instanceof Error?r.message:String(r)),!1}}function Je(){let t=Gn();return[{id:"claude-code",label:"Claude Code",detected:V(X(t,".claude")),supported:!0,hint:"recommended"},{id:"gemini-cli",label:"Gemini CLI",detected:V(X(t,".gemini")),supported:!0},{id:"opencode",label:"OpenCode",detected:V(X(t,".config","opencode"))||Ke("opencode"),supported:!0,hint:"plugin-based integration"},{id:"openclaw",label:"OpenClaw",detected:V(X(t,".openclaw")),supported:!0,hint:"plugin-based integration"},{id:"windsurf",label:"Windsurf",detected:V(X(t,".codeium","windsurf")),supported:!0},{id:"codex-cli",label:"Codex CLI",detected:V(X(t,".codex")),supported:!0,hint:"transcript-based integration"},{id:"cursor",label:"Cursor",detected:V(X(t,".cursor")),supported:!0,hint:"hooks + MCP integration"},{id:"copilot-cli",label:"Copilot CLI",detected:Ke("copilot"),supported:!0,hint:"MCP-based integration"},{id:"antigravity",label:"Antigravity",detected:V(X(t,".gemini","antigravity")),supported:!0,hint:"MCP-based integration"},{id:"goose",label:"Goose",detected:V(X(t,".config","goose"))||Ke("goose"),supported:!0,hint:"MCP-based integration"},{id:"crush",label:"Crush",detected:Ke("crush"),supported:!0,hint:"MCP-based integration"},{id:"roo-code",label:"Roo Code",detected:$i("roo-code"),supported:!0,hint:"MCP-based integration"},{id:"warp",label:"Warp",detected:V(X(t,".warp"))||Ke("warp"),supported:!0,hint:"MCP-based integration"}]}var Hn=m(()=>{"use strict";de()});import{appendFileSync as Ri,existsSync as Kn,mkdirSync as Pi,readFileSync as Ti}from"fs";import{join as xt}from"path";import{homedir as Oi}from"os";var fr,Jn,Cr,a,L=m(()=>{"use strict";fr=(i=>(i[i.DEBUG=0]="DEBUG",i[i.INFO=1]="INFO",i[i.WARN=2]="WARN",i[i.ERROR=3]="ERROR",i[i.SILENT=4]="SILENT",i))(fr||{}),Jn=xt(Oi(),".claude-mem"),Cr=class{level=null;useColor;logFilePath=null;logFileInitialized=!1;constructor(){this.useColor=process.stdout.isTTY??!1}ensureLogFileInitialized(){if(!this.logFileInitialized){this.logFileInitialized=!0;try{let e=xt(Jn,"logs");Kn(e)||Pi(e,{recursive:!0});let r=new Date().toISOString().split("T")[0];this.logFilePath=xt(e,`claude-mem-${r}.log`)}catch(e){console.error("[LOGGER] Failed to initialize log file:",e instanceof Error?e.message:String(e)),this.logFilePath=null}}}getLevel(){if(this.level===null)try{let e=xt(Jn,"settings.json");if(Kn(e)){let r=Ti(e,"utf-8"),s=(JSON.parse(r).CLAUDE_MEM_LOG_LEVEL||"INFO").toUpperCase();this.level=fr[s]??1}else this.level=1}catch(e){console.error("[LOGGER] Failed to load log level from settings:",e instanceof Error?e.message:String(e)),this.level=1}return this.level}correlationId(e,r){return`obs-${e}-${r}`}sessionId(e){return`session-${e}`}formatData(e){if(e==null)return"";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return e.toString();if(typeof e=="object"){if(e instanceof Error)return this.getLevel()===0?`${e.message}
|
|
55
|
+
${e.stack}`:e.message;if(Array.isArray(e))return`[${e.length} items]`;let r=Object.keys(e);return r.length===0?"{}":r.length<=3?JSON.stringify(e):`{${r.length} keys: ${r.slice(0,3).join(", ")}...}`}return String(e)}formatTool(e,r){if(!r)return e;let o=r;if(typeof r=="string")try{o=JSON.parse(r)}catch{o=r}if(e==="Bash"&&o.command)return`${e}(${o.command})`;if(o.file_path)return`${e}(${o.file_path})`;if(o.notebook_path)return`${e}(${o.notebook_path})`;if(e==="Glob"&&o.pattern)return`${e}(${o.pattern})`;if(e==="Grep"&&o.pattern)return`${e}(${o.pattern})`;if(o.url)return`${e}(${o.url})`;if(o.query)return`${e}(${o.query})`;if(e==="Task"){if(o.subagent_type)return`${e}(${o.subagent_type})`;if(o.description)return`${e}(${o.description})`}return e==="Skill"&&o.skill?`${e}(${o.skill})`:e==="LSP"&&o.operation?`${e}(${o.operation})`:e}formatTimestamp(e){let r=e.getFullYear(),o=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0"),i=String(e.getHours()).padStart(2,"0"),n=String(e.getMinutes()).padStart(2,"0"),u=String(e.getSeconds()).padStart(2,"0"),c=String(e.getMilliseconds()).padStart(3,"0");return`${r}-${o}-${s} ${i}:${n}:${u}.${c}`}log(e,r,o,s,i){if(e<this.getLevel())return;this.ensureLogFileInitialized();let n=this.formatTimestamp(new Date),u=fr[e].padEnd(5),c=r.padEnd(6),D="";s?.correlationId?D=`[${s.correlationId}] `:s?.sessionId&&(D=`[session-${s.sessionId}] `);let d="";i!=null&&(i instanceof Error?d=this.getLevel()===0?`
|
|
56
|
+
${i.message}
|
|
57
|
+
${i.stack}`:` ${i.message}`:this.getLevel()===0&&typeof i=="object"?d=`
|
|
58
|
+
`+JSON.stringify(i,null,2):d=" "+this.formatData(i));let p="";if(s){let{sessionId:_,memorySessionId:g,correlationId:h,...N}=s;Object.keys(N).length>0&&(p=` {${Object.entries(N).map(([K,oe])=>`${K}=${oe}`).join(", ")}}`)}let I=`[${n}] [${u}] [${c}] ${D}${o}${p}${d}`;if(this.logFilePath)try{Ri(this.logFilePath,I+`
|
|
59
|
+
`,"utf8")}catch(_){process.stderr.write(`[LOGGER] Failed to write to log file: ${_ instanceof Error?_.message:String(_)}
|
|
60
|
+
`)}else process.stderr.write(I+`
|
|
61
|
+
`)}debug(e,r,o,s){this.log(0,e,r,o,s)}info(e,r,o,s){this.log(1,e,r,o,s)}warn(e,r,o,s){this.log(2,e,r,o,s)}error(e,r,o,s){this.log(3,e,r,o,s)}dataIn(e,r,o,s){this.info(e,`\u2192 ${r}`,o,s)}dataOut(e,r,o,s){this.info(e,`\u2190 ${r}`,o,s)}success(e,r,o,s){this.info(e,`\u2713 ${r}`,o,s)}failure(e,r,o,s){this.error(e,`\u2717 ${r}`,o,s)}timing(e,r,o,s){this.info(e,`\u23F1 ${r}`,s,{duration:`${o}ms`})}happyPathError(e,r,o,s,i=""){let D=((new Error().stack||"").split(`
|
|
62
|
+
`)[2]||"").match(/at\s+(?:.*\s+)?\(?([^:]+):(\d+):(\d+)\)?/),d=D?`${D[1].split("/").pop()}:${D[2]}`:"unknown",p={...o,location:d};return this.warn(e,`[HAPPY-PATH] ${r}`,p,s),i}},a=new Cr});function Yn(t){return process.platform==="win32"?Math.round(t*Ye.WINDOWS_MULTIPLIER):t}var Ye,Er=m(()=>{"use strict";Ye={DEFAULT:3e5,HEALTH_CHECK:3e3,POST_SPAWN_WAIT:15e3,READINESS_WAIT:3e4,PORT_IN_USE_WAIT:3e3,WORKER_STARTUP_WAIT:1e3,PRE_RESTART_SETTLE_DELAY:2e3,POWERSHELL_COMMAND:1e4,WINDOWS_MULTIPLIER:1.5}});import{join as M,dirname as Li,basename as Bi}from"path";import{homedir as Vn}from"os";import{existsSync as Ni,mkdirSync as Fl}from"fs";import{execSync as yl}from"child_process";import{fileURLToPath as ji}from"url";function Ui(){return typeof __dirname<"u"?__dirname:Li(ji(import.meta.url))}function Wi(){if(process.env.CLAUDE_MEM_DATA_DIR)return process.env.CLAUDE_MEM_DATA_DIR;let t=M(Vn(),".claude-mem"),e=M(t,"settings.json");try{if(Ni(e)){let{readFileSync:r}=$s("fs"),o=JSON.parse(r(e,"utf-8")),s=o.env??o;if(s.CLAUDE_MEM_DATA_DIR)return s.CLAUDE_MEM_DATA_DIR}}catch{}return t}var _l,B,ye,kt,xl,kl,Al,bl,Ml,Gi,Il,$l,Hi,Rl,Pl,Tl,Ol,Ve=m(()=>{"use strict";L();_l=Ui();B=Wi(),ye=process.env.CLAUDE_CONFIG_DIR||M(Vn(),".claude"),kt=M(ye,"plugins","marketplaces","thedotmack"),xl=M(B,"archives"),kl=M(B,"logs"),Al=M(B,"trash"),bl=M(B,"backups"),Ml=M(B,"modes"),Gi=M(B,"settings.json"),Il=M(B,"claude-mem.db"),$l=M(B,"vector-db"),Hi=M(B,"observer-sessions"),Rl=Bi(Hi),Pl=M(ye,"settings.json"),Tl=M(ye,"commands"),Ol=M(ye,"CLAUDE.md")});var Xn=m(()=>{"use strict";me();Ve()});var zn=m(()=>{"use strict"});import{spawn as Kl,spawnSync as Ki}from"child_process";import{existsSync as Ji,mkdirSync as qn,readFileSync as Zn,writeFileSync as Yi}from"fs";import{homedir as Vi}from"os";import At from"path";function Z(t){if(!Number.isInteger(t)||t<0||t===0)return!1;try{return process.kill(t,0),!0}catch(e){if(e instanceof Error){let r=e.code;return r==="EPERM"?!0:(a.debug("SYSTEM","PID check failed",{pid:t,code:r}),!1)}return a.warn("SYSTEM","PID check threw non-Error",{pid:t,error:String(e)}),!1}}function Qi(t){if(!Number.isInteger(t)||t<=0)return null;if(process.platform==="linux")try{let e=Zn(`/proc/${t}/stat`,"utf-8"),r=e.lastIndexOf(") ");if(r<0)return null;let s=e.slice(r+2).split(" ")[19];return s&&/^\d+$/.test(s)?s:null}catch(e){return a.debug("SYSTEM","captureProcessStartToken: /proc read failed",{pid:t,error:e instanceof Error?e.message:String(e)}),null}if(process.platform==="win32")return null;try{let e=Ki("ps",["-p",String(t),"-o","lstart="],{encoding:"utf-8",timeout:2e3,env:{...process.env,LC_ALL:"C",LANG:"C"}});if(e.status!==0)return null;let r=e.stdout.trim();return r.length>0?r:null}catch(e){return a.debug("SYSTEM","captureProcessStartToken: ps exec failed",{pid:t,error:e instanceof Error?e.message:String(e)}),null}}function Qn(t){if(!t||!Z(t.pid))return!1;if(!t.startToken)return!0;let e=Qi(t.pid);if(e===null)return!0;let r=e===t.startToken;return r||a.debug("SYSTEM","verifyPidFileOwnership: start-token mismatch (PID reused)",{pid:t.pid,stored:t.startToken,current:e}),r}function bt(){return hr||(hr=new Fr),hr}var Xi,zi,qi,Zi,Fr,hr,Mt=m(()=>{"use strict";L();zn();Xi=5e3,zi=1e3,qi=At.join(Vi(),".claude-mem"),Zi=At.join(qi,"supervisor.json");Fr=class{registryPath;entries=new Map;runtimeProcesses=new Map;initialized=!1;constructor(e=Zi){this.registryPath=e}initialize(){if(this.initialized)return;if(this.initialized=!0,qn(At.dirname(this.registryPath),{recursive:!0}),!Ji(this.registryPath)){this.persist();return}try{let o=JSON.parse(Zn(this.registryPath,"utf-8")).processes??{};for(let[s,i]of Object.entries(o))this.entries.set(s,i)}catch(r){r instanceof Error?a.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath},r):a.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath,error:String(r)}),this.entries.clear()}let e=this.pruneDeadEntries();e>0&&a.info("SYSTEM","Removed dead processes from supervisor registry",{removed:e}),this.persist()}register(e,r,o){this.initialize(),this.entries.set(e,r),o&&this.runtimeProcesses.set(e,o),this.persist()}unregister(e){this.initialize(),this.entries.delete(e),this.runtimeProcesses.delete(e),this.persist()}clear(){this.entries.clear(),this.runtimeProcesses.clear(),this.persist()}getAll(){return this.initialize(),Array.from(this.entries.entries()).map(([e,r])=>({id:e,...r})).sort((e,r)=>{let o=Date.parse(e.startedAt),s=Date.parse(r.startedAt);return(Number.isNaN(o)?0:o)-(Number.isNaN(s)?0:s)})}getBySession(e){let r=String(e);return this.getAll().filter(o=>o.sessionId!==void 0&&String(o.sessionId)===r)}getRuntimeProcess(e){return this.runtimeProcesses.get(e)}getByPid(e){return this.getAll().filter(r=>r.pid===e)}pruneDeadEntries(){this.initialize();let e=0;for(let[r,o]of this.entries)Z(o.pid)||(this.entries.delete(r),this.runtimeProcesses.delete(r),e+=1);return e>0&&this.persist(),e}async reapSession(e){this.initialize();let r=this.getBySession(e);if(r.length===0)return 0;let o=typeof e=="number"?e:Number(e)||void 0;a.info("SYSTEM",`Reaping ${r.length} process(es) for session ${e}`,{sessionId:o,pids:r.map(u=>u.pid)});let s=r.filter(u=>Z(u.pid));for(let u of s)try{typeof u.pgid=="number"&&process.platform!=="win32"?process.kill(-u.pgid,"SIGTERM"):process.kill(u.pid,"SIGTERM")}catch(c){c instanceof Error?c.code!=="ESRCH"&&a.debug("SYSTEM",`Failed to SIGTERM session process PID ${u.pid}`,{pid:u.pid,pgid:u.pgid},c):a.warn("SYSTEM",`Failed to SIGTERM session process PID ${u.pid} (non-Error)`,{pid:u.pid,pgid:u.pgid,error:String(c)})}let i=Date.now()+Xi;for(;Date.now()<i&&s.filter(c=>Z(c.pid)).length!==0;)await new Promise(c=>setTimeout(c,100));let n=s.filter(u=>Z(u.pid));for(let u of n){a.warn("SYSTEM",`Session process PID ${u.pid} did not exit after SIGTERM, sending SIGKILL`,{pid:u.pid,pgid:u.pgid,sessionId:o});try{typeof u.pgid=="number"&&process.platform!=="win32"?process.kill(-u.pgid,"SIGKILL"):process.kill(u.pid,"SIGKILL")}catch(c){c instanceof Error?c.code!=="ESRCH"&&a.debug("SYSTEM",`Failed to SIGKILL session process PID ${u.pid}`,{pid:u.pid,pgid:u.pgid},c):a.warn("SYSTEM",`Failed to SIGKILL session process PID ${u.pid} (non-Error)`,{pid:u.pid,pgid:u.pgid,error:String(c)})}}if(n.length>0){let u=Date.now()+zi;for(;Date.now()<u&&n.filter(D=>Z(D.pid)).length!==0;)await new Promise(D=>setTimeout(D,100))}for(let u of r)this.entries.delete(u.id),this.runtimeProcesses.delete(u.id);return this.persist(),a.info("SYSTEM",`Reaped ${r.length} process(es) for session ${e}`,{sessionId:o,reaped:r.length}),r.length}persist(){let e={processes:Object.fromEntries(this.entries.entries())};qn(At.dirname(this.registryPath),{recursive:!0}),Yi(this.registryPath,JSON.stringify(e,null,2))}},hr=null});import{execFile as eu}from"child_process";import{rmSync as tu}from"fs";import{homedir as ru}from"os";import ro from"path";import{promisify as nu}from"util";async function no(t){let e=t.currentPid??process.pid,r=t.pidFilePath??iu,o=t.registry.getAll(),s=[...o].filter(n=>n.pid!==e).sort((n,u)=>Date.parse(u.startedAt)-Date.parse(n.startedAt));for(let n of s){if(!Z(n.pid)){t.registry.unregister(n.id);continue}try{await to(n,"SIGTERM")}catch(u){u instanceof Error?a.debug("SYSTEM","Failed to send SIGTERM to child process",{pid:n.pid,pgid:n.pgid,type:n.type},u):a.warn("SYSTEM","Failed to send SIGTERM to child process (non-Error)",{pid:n.pid,pgid:n.pgid,type:n.type,error:String(u)})}}await eo(s,5e3);let i=s.filter(n=>Z(n.pid));for(let n of i)try{await to(n,"SIGKILL")}catch(u){u instanceof Error?a.debug("SYSTEM","Failed to force kill child process",{pid:n.pid,pgid:n.pgid,type:n.type},u):a.warn("SYSTEM","Failed to force kill child process (non-Error)",{pid:n.pid,pgid:n.pgid,type:n.type,error:String(u)})}await eo(i,1e3);for(let n of s)t.registry.unregister(n.id);for(let n of o.filter(u=>u.pid===e))t.registry.unregister(n.id);try{tu(r,{force:!0})}catch(n){n instanceof Error?a.debug("SYSTEM","Failed to remove PID file during shutdown",{pidFilePath:r},n):a.warn("SYSTEM","Failed to remove PID file during shutdown (non-Error)",{pidFilePath:r,error:String(n)})}t.registry.pruneDeadEntries()}async function eo(t,e){let r=Date.now()+e;for(;Date.now()<r;){if(t.filter(s=>Z(s.pid)).length===0)return;await new Promise(s=>setTimeout(s,100))}}async function to(t,e){let{pid:r,pgid:o}=t;if(process.platform!=="win32"){try{typeof o=="number"?process.kill(-o,e):process.kill(r,e)}catch(n){if(n instanceof Error&&n.code==="ESRCH")return;throw n}return}if(e==="SIGTERM"){try{process.kill(r,e)}catch(n){if(n instanceof Error&&n.code==="ESRCH")return;throw n}return}let s=await uu();if(s){await new Promise((n,u)=>{s(r,e,c=>{if(!c){n();return}if(c.code==="ESRCH"){n();return}u(c)})});return}let i=["/PID",String(r),"/T"];e==="SIGKILL"&&i.push("/F"),await ou("taskkill",i,{timeout:Ye.POWERSHELL_COMMAND,windowsHide:!0})}async function uu(){let t="tree-kill";try{let e=await import(t);return e.default??e}catch(e){return a.debug("SYSTEM","tree-kill module not available, using fallback",{},e instanceof Error?e:void 0),null}}var ou,su,iu,oo=m(()=>{"use strict";L();Er();Mt();ou=nu(eu),su=ro.join(ru(),".claude-mem"),iu=ro.join(su,"worker.pid")});function au(){let e=bt().pruneDeadEntries();e>0&&a.info("SYSTEM",`Health check: pruned ${e} dead process(es) from registry`)}function io(){we===null&&(we=setInterval(au,so),we.unref(),a.debug("SYSTEM","Health checker started",{intervalMs:so}))}function uo(){we!==null&&(clearInterval(we),we=null,a.debug("SYSTEM","Health checker stopped"))}var so,we,ao=m(()=>{"use strict";L();Mt();so=3e4,we=null});import{existsSync as cu,readFileSync as lu,rmSync as co}from"fs";import{homedir as Du}from"os";import lo from"path";function Do(t={}){let e=t.pidFilePath??pu;if(!cu(e))return"missing";let r=null;try{r=JSON.parse(lu(e,"utf-8"))}catch(s){return s instanceof Error?a.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:e},s):a.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:e,error:String(s)}),co(e,{force:!0}),"invalid"}return Qn(r)&&r?((t.logAlive??!0)&&a.info("SYSTEM","Worker already running (PID alive)",{existingPid:r.pid,existingPort:r.port,startedAt:r.startedAt}),"alive"):(a.info("SYSTEM","Removing stale PID file (worker process is dead or PID has been reused)",{pid:r?.pid,port:r?.port,startedAt:r?.startedAt}),co(e,{force:!0}),"stale")}var du,pu,Sr,CD,po=m(()=>{"use strict";L();Mt();oo();ao();du=lo.join(Du(),".claude-mem"),pu=lo.join(du,"worker.pid"),Sr=class{registry;started=!1;stopPromise=null;signalHandlersRegistered=!1;shutdownInitiated=!1;shutdownHandler=null;constructor(e){this.registry=e}async start(){if(this.started)return;if(this.registry.initialize(),Do({logAlive:!1})==="alive")throw new Error("Worker already running");this.started=!0,io()}configureSignalHandlers(e){if(this.shutdownHandler=e,this.signalHandlersRegistered)return;this.signalHandlersRegistered=!0;let r=async o=>{if(this.shutdownInitiated){a.warn("SYSTEM",`Received ${o} but shutdown already in progress`);return}this.shutdownInitiated=!0,a.info("SYSTEM",`Received ${o}, shutting down...`);try{this.shutdownHandler?await this.shutdownHandler():await this.stop()}catch(s){s instanceof Error?a.error("SYSTEM","Error during shutdown",{},s):a.error("SYSTEM","Error during shutdown (non-Error)",{error:String(s)});try{await this.stop()}catch(i){i instanceof Error?a.debug("SYSTEM","Supervisor shutdown fallback failed",{},i):a.debug("SYSTEM","Supervisor shutdown fallback failed",{error:String(i)})}}process.exit(0)};process.on("SIGTERM",()=>{r("SIGTERM")}),process.on("SIGINT",()=>{r("SIGINT")}),process.platform!=="win32"&&(process.argv.includes("--daemon")?process.on("SIGHUP",()=>{a.debug("SYSTEM","Ignoring SIGHUP in daemon mode")}):process.on("SIGHUP",()=>{r("SIGHUP")}))}async stop(){if(this.stopPromise){await this.stopPromise;return}uo(),this.stopPromise=no({registry:this.registry,currentPid:process.pid}).finally(()=>{this.started=!1,this.stopPromise=null}),await this.stopPromise}assertCanSpawn(e){if(this.stopPromise!==null)throw new Error(`Supervisor is shutting down, refusing to spawn ${e}`)}registerProcess(e,r,o){this.registry.register(e,r,o)}unregisterProcess(e){this.registry.unregister(e)}getRegistry(){return this.registry}},CD=new Sr(bt())});import mo from"path";import{readFileSync as wD,existsSync as vD,writeFileSync as _D,renameSync as xD,mkdirSync as kD}from"fs";import{spawn as bD,execSync as MD}from"child_process";function gu(t,e={},r){return new Promise((o,s)=>{let i=setTimeout(()=>s(new Error(`Request timed out after ${r}ms`)),r);fetch(t,e).then(n=>{clearTimeout(i),o(n)},n=>{clearTimeout(i),s(n)})})}function Xe(){if(It!==null)return It;let t=mo.join(x.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),e=x.loadFromFile(t);return It=parseInt(e.CLAUDE_MEM_WORKER_PORT,10),It}function fu(){if($t!==null)return $t;let t=mo.join(x.get("CLAUDE_MEM_DATA_DIR"),"settings.json");return $t=x.loadFromFile(t).CLAUDE_MEM_WORKER_HOST,$t}function Cu(t){return`http://${fu()}:${Xe()}${t}`}function Rt(t,e={}){let r=e.method??"GET",o=e.timeoutMs??mu,s=Cu(t),i={method:r};return e.headers&&(i.headers=e.headers),e.body&&(i.body=e.body),o>0?gu(s,i,o):fetch(s,i)}var mu,It,$t,Pt=m(()=>{"use strict";L();Er();me();Ve();Xn();po();mu=(()=>{let t=process.env.CLAUDE_MEM_HEALTH_TIMEOUT_MS;if(t){let e=parseInt(t,10);if(Number.isFinite(e)&&e>=500&&e<=3e5)return e;a.warn("SYSTEM","Invalid CLAUDE_MEM_HEALTH_TIMEOUT_MS, using default",{value:t,min:500,max:3e5})}return Yn(Ye.HEALTH_CHECK)})();It=null,$t=null});import{existsSync as Eu,readFileSync as hu,writeFileSync as go,mkdirSync as fo,renameSync as Fu}from"fs";import{join as yr,basename as jD}from"path";function Co(t){try{return Eu(t)?JSON.parse(hu(t,"utf-8")):{}}catch(e){return a.error("CONFIG","Failed to read Cursor registry, using empty registry",{file:t,error:e instanceof Error?e.message:String(e)}),{}}}function Eo(t,e){let r=yr(t,"..");fo(r,{recursive:!0}),go(t,JSON.stringify(e,null,2))}function wr(t,e){let r=yr(t,".cursor","rules"),o=yr(r,"claude-mem-context.mdc"),s=`${o}.tmp`;fo(r,{recursive:!0});let i=`---
|
|
71
63
|
alwaysApply: true
|
|
72
64
|
description: "Claude-mem context from past sessions (auto-updated)"
|
|
73
65
|
---
|
|
@@ -76,17 +68,17 @@ description: "Claude-mem context from past sessions (auto-updated)"
|
|
|
76
68
|
|
|
77
69
|
The following context is from claude-mem, a persistent memory system that tracks your coding sessions.
|
|
78
70
|
|
|
79
|
-
${
|
|
71
|
+
${e}
|
|
80
72
|
|
|
81
73
|
---
|
|
82
74
|
*Updated after last session. Use claude-mem's MCP search tools for more detailed queries.*
|
|
83
|
-
`;
|
|
84
|
-
Installing Claude-Mem Cursor hooks (${
|
|
85
|
-
`);let
|
|
86
|
-
Installation failed: ${
|
|
75
|
+
`;go(s,i),Fu(s,o)}var ho=m(()=>{"use strict";L()});var Ao={};q(Ao,{checkCursorHooksStatus:()=>ko,configureCursorMcp:()=>xu,detectClaudeCode:()=>Iu,detectPlatform:()=>yo,findBunPath:()=>_e,findMcpServerPath:()=>ze,findWorkerServicePath:()=>ve,getScriptExtension:()=>vu,getTargetDir:()=>Lt,handleCursorCommand:()=>$u,installCursorHooks:()=>_o,readCursorRegistry:()=>Ot,registerCursorProject:()=>wo,uninstallCursorHooks:()=>xo,unregisterCursorProject:()=>vo,updateCursorContextForProject:()=>_u,writeCursorRegistry:()=>kr});import f from"path";import{homedir as Tt}from"os";import{existsSync as G,readFileSync as Fo,writeFileSync as _r,unlinkSync as vr,mkdirSync as xr}from"fs";import{exec as Su}from"child_process";import{promisify as yu}from"util";function yo(){return process.platform==="win32"?"windows":"unix"}function vu(){return yo()==="windows"?".ps1":".sh"}function Ot(){return Co(So)}function kr(t){Eo(So,t)}function wo(t,e){let r=Ot();r[t]={workspacePath:e,installedAt:new Date().toISOString()},kr(r),a.info("CURSOR","Registered project for auto-context updates",{projectName:t,workspacePath:e})}function vo(t){let e=Ot();e[t]&&(delete e[t],kr(e),a.info("CURSOR","Unregistered project",{projectName:t}))}async function _u(t,e){let o=Ot()[t];if(o)try{let s=await Rt(`/api/context/inject?project=${encodeURIComponent(t)}`);if(!s.ok)return;let i=await s.text();if(!i||!i.trim())return;wr(o.workspacePath,i),a.debug("CURSOR","Updated context file",{projectName:t,workspacePath:o.workspacePath})}catch(s){s instanceof Error?a.error("WORKER","Failed to update context file",{projectName:t},s):a.error("WORKER","Failed to update context file",{projectName:t},new Error(String(s)))}}function ze(){let t=[f.join(kt,"plugin","scripts","mcp-server.cjs"),f.join(process.cwd(),"plugin","scripts","mcp-server.cjs")];for(let e of t)if(G(e))return e;return null}function ve(){let t=[f.join(kt,"plugin","scripts","worker-service.cjs"),f.join(process.cwd(),"plugin","scripts","worker-service.cjs")];for(let e of t)if(G(e))return e;return null}function _e(){let t=[f.join(Tt(),".bun","bin","bun"),"/usr/local/bin/bun","/usr/bin/bun",...process.platform==="win32"?[f.join(Tt(),".bun","bin","bun.exe"),f.join(process.env.LOCALAPPDATA||"","bun","bun.exe")]:[]];for(let e of t)if(e&&G(e))return e;return"bun"}function Lt(t){switch(t){case"project":return f.join(process.cwd(),".cursor");case"user":return f.join(Tt(),".cursor");case"enterprise":return process.platform==="darwin"?"/Library/Application Support/Cursor":process.platform==="linux"?"/etc/cursor":process.platform==="win32"?f.join(process.env.ProgramData||"C:\\ProgramData","Cursor"):null;default:return null}}function xu(t){let e=ze();if(!e)return console.error("Could not find MCP server script"),console.error(" Expected at: ~/.claude/plugins/marketplaces/thedotmack/plugin/scripts/mcp-server.cjs"),1;let r=Lt(t);if(!r)return console.error(`Invalid target: ${t}. Use: project or user`),1;let o=f.join(r,"mcp.json");try{xr(r,{recursive:!0});let s={mcpServers:{}};if(G(o))try{s=JSON.parse(Fo(o,"utf-8")),s.mcpServers||(s.mcpServers={})}catch(i){i instanceof Error?a.error("WORKER","Corrupt mcp.json, creating new config",{path:o},i):a.error("WORKER","Corrupt mcp.json, creating new config",{path:o},new Error(String(i))),s={mcpServers:{}}}return s.mcpServers["claude-mem"]={command:"node",args:[e]},_r(o,JSON.stringify(s,null,2)),console.log(` Configured MCP server in ${t==="user"?"~/.cursor":".cursor"}/mcp.json`),console.log(` Server path: ${e}`),0}catch(s){return console.error(`Failed to configure MCP: ${s.message}`),1}}async function _o(t){console.log(`
|
|
76
|
+
Installing Claude-Mem Cursor hooks (${t} level)...
|
|
77
|
+
`);let e=Lt(t);if(!e)return console.error(`Invalid target: ${t}. Use: project, user, or enterprise`),1;let r=ve();if(!r)return console.error("Could not find worker-service.cjs"),console.error(" Expected at: ~/.claude/plugins/marketplaces/thedotmack/plugin/scripts/worker-service.cjs"),1;let o=process.cwd(),s=f.join(e,"hooks.json"),i=_e(),n=i.replace(/\\/g,"\\\\"),u=r.replace(/\\/g,"\\\\"),c=d=>`"${n}" "${u}" hook cursor ${d}`;console.log(` Using Bun runtime: ${i}`);let D={version:1,hooks:{beforeSubmitPrompt:[{command:c("session-init")},{command:c("context")}],afterMCPExecution:[{command:c("observation")}],afterShellExecution:[{command:c("observation")}],afterFileEdit:[{command:c("file-edit")}],stop:[{command:c("summarize")}]}};try{return xr(e,{recursive:!0}),await ku(s,D,r,t,e,o),0}catch(d){let p=d instanceof Error?d.message:String(d);return console.error(`
|
|
78
|
+
Installation failed: ${p}`),t==="enterprise"&&console.error(" Tip: Enterprise installation may require sudo/admin privileges"),1}}async function ku(t,e,r,o,s,i){_r(t,JSON.stringify(e,null,2)),console.log(" Created hooks.json (unified CLI mode)"),console.log(` Worker service: ${r}`),o==="project"&&await Au(s,i),console.log(`
|
|
87
79
|
Installation complete!
|
|
88
80
|
|
|
89
|
-
Hooks installed to: ${
|
|
81
|
+
Hooks installed to: ${s}/hooks.json
|
|
90
82
|
Using unified CLI: bun worker-service.cjs hook cursor <command>
|
|
91
83
|
|
|
92
84
|
Next steps:
|
|
@@ -97,7 +89,7 @@ Next steps:
|
|
|
97
89
|
Context Injection:
|
|
98
90
|
Context from past sessions is stored in .cursor/rules/claude-mem-context.mdc
|
|
99
91
|
and automatically included in every chat. It updates after each session ends.
|
|
100
|
-
`)}async function
|
|
92
|
+
`)}async function Au(t,e){let r=f.join(t,"rules");xr(r,{recursive:!0});let o=f.basename(e),s=!1;console.log(" Generating initial context...");try{s=await bu(o,e)}catch(i){i instanceof Error?a.debug("WORKER","Worker not running during install",{},i):a.debug("WORKER","Worker not running during install",{},new Error(String(i)))}if(!s){let i=f.join(r,"claude-mem-context.mdc");_r(i,`---
|
|
101
93
|
alwaysApply: true
|
|
102
94
|
description: "Claude-mem context from past sessions (auto-updated)"
|
|
103
95
|
---
|
|
@@ -107,15 +99,15 @@ description: "Claude-mem context from past sessions (auto-updated)"
|
|
|
107
99
|
*No context yet. Complete your first session and context will appear here.*
|
|
108
100
|
|
|
109
101
|
Use claude-mem's MCP search tools for manual memory queries.
|
|
110
|
-
`),console.log(" Created placeholder context file (will populate after first session)")}
|
|
111
|
-
Uninstalling Claude-Mem Cursor hooks (${
|
|
112
|
-
`);let
|
|
113
|
-
Uninstallation failed: ${c}`),1}}function
|
|
102
|
+
`),console.log(" Created placeholder context file (will populate after first session)")}wo(o,e),console.log(" Registered for auto-context updates")}async function bu(t,e){if(!(await Rt("/api/readiness")).ok)return!1;let o=await Rt(`/api/context/inject?project=${encodeURIComponent(t)}`);if(!o.ok)return!1;let s=await o.text();return s&&s.trim()?(wr(e,s),console.log(" Generated initial context from existing memory"),!0):!1}function xo(t){console.log(`
|
|
103
|
+
Uninstalling Claude-Mem Cursor hooks (${t} level)...
|
|
104
|
+
`);let e=Lt(t);if(!e)return console.error(`Invalid target: ${t}`),1;let r=f.join(e,"hooks"),o=f.join(e,"hooks.json"),s=["common.sh","session-init.sh","context-inject.sh","save-observation.sh","save-file-edit.sh","session-summary.sh"],i=["common.ps1","session-init.ps1","context-inject.ps1","save-observation.ps1","save-file-edit.ps1","session-summary.ps1"],n=[...s,...i];try{return Mu(r,n,o,t,e),0}catch(u){let c=u instanceof Error?u.message:String(u);return console.error(`
|
|
105
|
+
Uninstallation failed: ${c}`),1}}function Mu(t,e,r,o,s){for(let i of e){let n=f.join(t,i);G(n)&&(vr(n),console.log(` Removed legacy script: ${i}`))}if(G(r)&&(vr(r),console.log(" Removed hooks.json")),o==="project"){let i=f.join(s,"rules","claude-mem-context.mdc");G(i)&&(vr(i),console.log(" Removed context file"));let n=f.basename(process.cwd());vo(n),console.log(" Unregistered from auto-context updates")}console.log(`
|
|
114
106
|
Uninstallation complete!
|
|
115
|
-
`),console.log("Restart Cursor to apply changes.")}function
|
|
107
|
+
`),console.log("Restart Cursor to apply changes.")}function ko(){console.log(`
|
|
116
108
|
Claude-Mem Cursor Hooks Status
|
|
117
|
-
`);let
|
|
118
|
-
`),0}async function
|
|
109
|
+
`);let t=[{name:"Project",dir:f.join(process.cwd(),".cursor")},{name:"User",dir:f.join(Tt(),".cursor")}];process.platform==="darwin"?t.push({name:"Enterprise",dir:"/Library/Application Support/Cursor"}):process.platform==="linux"&&t.push({name:"Enterprise",dir:"/etc/cursor"});let e=!1;for(let r of t){let o=f.join(r.dir,"hooks.json"),s=f.join(r.dir,"hooks");if(G(o)){e=!0,console.log(`${r.name}: Installed`),console.log(` Config: ${o}`);let i=null;try{i=JSON.parse(Fo(o,"utf-8"))}catch(n){n instanceof Error?a.error("WORKER","Unable to parse hooks.json",{path:o},n):a.error("WORKER","Unable to parse hooks.json",{path:o},new Error(String(n))),console.log(" Mode: Unable to parse hooks.json")}if(i){let n=i?.hooks?.beforeSubmitPrompt?.[0]?.command||"";if(n.includes("worker-service.cjs")&&n.includes("hook cursor"))console.log(" Mode: Unified CLI (bun worker-service.cjs)");else{let u=["session-init.sh","context-inject.sh","save-observation.sh"],c=["session-init.ps1","context-inject.ps1","save-observation.ps1"],D=u.some(p=>G(f.join(s,p))),d=c.some(p=>G(f.join(s,p)));D||d?(console.log(" Mode: Legacy shell scripts (consider reinstalling for unified CLI)"),D&&d?console.log(" Platform: Both (bash + PowerShell)"):D?console.log(" Platform: Unix (bash)"):d&&console.log(" Platform: Windows (PowerShell)")):console.log(" Mode: Unknown configuration")}}if(r.name==="Project"){let n=f.join(r.dir,"rules","claude-mem-context.mdc");G(n)?console.log(" Context: Active"):console.log(" Context: Not yet generated (will be created on first prompt)")}}else console.log(`${r.name}: Not installed`);console.log("")}return e||console.log(`No hooks installed. Run: claude-mem cursor install
|
|
110
|
+
`),0}async function Iu(){try{let{stdout:e}=await wu("which claude || where claude",{timeout:5e3});if(e.trim())return!0}catch(e){e instanceof Error?a.debug("WORKER","Claude CLI not in PATH",{},e):a.debug("WORKER","Claude CLI not in PATH",{},new Error(String(e)))}let t=f.join(ye,"plugins");return!!G(t)}async function $u(t,e){switch(t){case"install":{let r=e[0]||"project";return _o(r)}case"uninstall":{let r=e[0]||"project";return xo(r)}case"status":return ko();case"setup":return console.log("Use the main entry point for setup"),0;default:return console.log(`
|
|
119
111
|
Claude-Mem Cursor Integration
|
|
120
112
|
|
|
121
113
|
Usage: claude-mem cursor <command> [options]
|
|
@@ -139,23 +131,23 @@ Examples:
|
|
|
139
131
|
claude-mem cursor status # Check if hooks are installed
|
|
140
132
|
|
|
141
133
|
For more info: https://docs.claude-mem.ai/cursor
|
|
142
|
-
`),0}}var
|
|
143
|
-
`)}function
|
|
134
|
+
`),0}}var wu,So,qe=m(()=>{"use strict";L();Pt();Ve();ho();wu=yu(Su),So=f.join(B,"cursor-projects.json")});var Ir={};q(Ir,{checkGeminiCliHooksStatus:()=>Ro,handleGeminiCliCommand:()=>Uu,installGeminiCliHooks:()=>Io,uninstallGeminiCliHooks:()=>$o});import Ar from"path";import{homedir as Ru}from"os";import{existsSync as xe,readFileSync as Bt,writeFileSync as br,mkdirSync as bo}from"fs";function Tu(t,e,r){let o=ke[r];if(!o)throw new Error(`Unknown Gemini CLI event: ${r}`);let s=t.replace(/\\/g,"\\\\"),i=e.replace(/\\/g,"\\\\");return`"${s}" "${i}" hook gemini-cli ${o}`}function Ou(t){return{matcher:"*",hooks:[{name:Ze,type:"command",command:t,timeout:Pu}]}}function Mr(){if(!xe(P))return{};let t=Bt(P,"utf-8");try{return JSON.parse(t)}catch(e){throw e instanceof Error?a.error("WORKER","Corrupt JSON in Gemini settings",{path:P},e):a.error("WORKER","Corrupt JSON in Gemini settings",{path:P},new Error(String(e))),new Error(`Corrupt JSON in ${P}, refusing to overwrite user settings`)}}function Mo(t){bo(Nt,{recursive:!0}),br(P,JSON.stringify(t,null,2)+`
|
|
135
|
+
`)}function Lu(t,e){let r={...t};r.hooks||(r.hooks={});for(let[o,s]of Object.entries(e)){let i=r.hooks[o]??[];for(let n of s){let u=i.findIndex(c=>c.hooks.some(D=>D.name===Ze));if(u>=0){let c=i[u],D=c.hooks.findIndex(d=>d.name===Ze);D>=0?c.hooks[D]=n.hooks[0]:c.hooks.push(n.hooks[0])}else i.push(n)}r.hooks[o]=i}return r}function Bu(){let t="<claude-mem-context>",r=`${t}
|
|
144
136
|
# Memory Context from Past Sessions
|
|
145
137
|
|
|
146
138
|
*No context yet. Complete your first session and context will appear here.*
|
|
147
|
-
</claude-mem-context>`,
|
|
139
|
+
</claude-mem-context>`,o="";if(xe(z)&&(o=Bt(z,"utf-8")),o.includes(t))return;let s=o.length>0&&!o.endsWith(`
|
|
148
140
|
`)?`
|
|
149
141
|
|
|
150
|
-
`:
|
|
151
|
-
`:"",
|
|
152
|
-
`;
|
|
142
|
+
`:o.length>0?`
|
|
143
|
+
`:"",i=o+s+r+`
|
|
144
|
+
`;bo(Nt,{recursive:!0}),br(z,i)}async function Io(){console.log(`
|
|
153
145
|
Installing Claude-Mem Gemini CLI hooks...
|
|
154
|
-
`);let
|
|
155
|
-
Installation failed: ${
|
|
146
|
+
`);let t=ve();if(!t)return console.error("Could not find worker-service.cjs"),console.error(" Expected at: ~/.claude/plugins/marketplaces/thedotmack/plugin/scripts/worker-service.cjs"),1;let e=_e();console.log(` Using Bun runtime: ${e}`),console.log(` Worker service: ${t}`);try{let r={};for(let i of Object.keys(ke)){let n=Tu(e,t,i);r[i]=[Ou(n)]}let o=Mr(),s=Lu(o,r);return Nu(s),0}catch(r){let o=r instanceof Error?r.message:String(r);return console.error(`
|
|
147
|
+
Installation failed: ${o}`),1}}function Nu(t){Mo(t),console.log(` Merged hooks into ${P}`),Bu(),console.log(` Setup context injection in ${z}`);let e=Object.keys(ke);console.log(` Registered ${e.length} hook events:`);for(let r of e){let o=ke[r];console.log(` ${r} \u2192 ${o}`)}console.log(`
|
|
156
148
|
Installation complete!
|
|
157
149
|
|
|
158
|
-
Hooks installed to: ${
|
|
150
|
+
Hooks installed to: ${P}
|
|
159
151
|
Using unified CLI: bun worker-service.cjs hook gemini-cli <event>
|
|
160
152
|
|
|
161
153
|
Next steps:
|
|
@@ -166,21 +158,21 @@ Next steps:
|
|
|
166
158
|
Context Injection:
|
|
167
159
|
Context from past sessions is injected via ~/.gemini/GEMINI.md
|
|
168
160
|
and automatically included in Gemini CLI conversations.
|
|
169
|
-
`)}function
|
|
161
|
+
`)}function $o(){if(console.log(`
|
|
170
162
|
Uninstalling Claude-Mem Gemini CLI hooks...
|
|
171
|
-
`),!
|
|
172
|
-
Uninstallation failed: ${
|
|
163
|
+
`),!xe(P))return console.log(" No Gemini CLI settings found \u2014 nothing to uninstall."),0;try{let t=Mr();if(!t.hooks)return console.log(" No hooks found in Gemini CLI settings \u2014 nothing to uninstall."),0;let e=0;for(let[r,o]of Object.entries(t.hooks)){let s=o.map(i=>{let n=i.hooks.filter(u=>u.name!==Ze);return e+=i.hooks.length-n.length,{...i,hooks:n}}).filter(i=>i.hooks.length>0);s.length>0?t.hooks[r]=s:delete t.hooks[r]}return Object.keys(t.hooks).length===0&&delete t.hooks,ju(t,e),0}catch(t){let e=t instanceof Error?t.message:String(t);return console.error(`
|
|
164
|
+
Uninstallation failed: ${e}`),1}}function ju(t,e){if(Mo(t),console.log(` Removed ${e} claude-mem hook(s) from ${P}`),xe(z)){let r=Bt(z,"utf-8"),o=/\n?<claude-mem-context>[\s\S]*?<\/claude-mem-context>\n?/;o.test(r)&&(r=r.replace(o,""),br(z,r),console.log(` Removed context section from ${z}`))}console.log(`
|
|
173
165
|
Uninstallation complete!
|
|
174
|
-
`),console.log("Restart Gemini CLI to apply changes.")}function
|
|
166
|
+
`),console.log("Restart Gemini CLI to apply changes.")}function Ro(){if(console.log(`
|
|
175
167
|
Claude-Mem Gemini CLI Hooks Status
|
|
176
|
-
`),!
|
|
168
|
+
`),!xe(P))return console.log("Gemini CLI settings: Not found"),console.log(` Expected at: ${P}
|
|
177
169
|
`),console.log(`No hooks installed. Run: claude-mem install --ide gemini-cli
|
|
178
|
-
`),0;let
|
|
179
|
-
`),0}if(!
|
|
170
|
+
`),0;let t;try{t=Mr()}catch(r){let o=r instanceof Error?r.message:String(r);return r instanceof Error?a.error("WORKER","Failed to read Gemini CLI settings",{path:P},r):a.error("WORKER","Failed to read Gemini CLI settings",{path:P},new Error(String(r))),console.log(`Gemini CLI settings: ${o}
|
|
171
|
+
`),0}if(!t.hooks)return console.log(`Gemini CLI settings: Found, but no hooks configured
|
|
180
172
|
`),console.log(`No hooks installed. Run: claude-mem install --ide gemini-cli
|
|
181
|
-
`),0;let
|
|
173
|
+
`),0;let e=[];for(let[r,o]of Object.entries(t.hooks))o.some(i=>i.hooks.some(n=>n.name===Ze))&&e.push(r);if(e.length===0)return console.log(`Gemini CLI settings: Found, but no claude-mem hooks
|
|
182
174
|
`),console.log(`Run: claude-mem install --ide gemini-cli
|
|
183
|
-
`),0;console.log(`Settings: ${
|
|
175
|
+
`),0;console.log(`Settings: ${P}`),console.log("Mode: Unified CLI (bun worker-service.cjs hook gemini-cli)"),console.log(`Events: ${e.length} of ${Object.keys(ke).length} mapped`);for(let r of e){let o=ke[r]??"unknown";console.log(` ${r} \u2192 ${o}`)}return xe(z)?Bt(z,"utf-8").includes("<claude-mem-context>")?console.log(`Context: Active (${z})`):console.log("Context: GEMINI.md exists but missing claude-mem section"):console.log("Context: No GEMINI.md found"),console.log(""),0}async function Uu(t,e){switch(t){case"install":return Io();case"uninstall":return $o();case"status":return Ro();default:return console.log(`
|
|
184
176
|
Claude-Mem Gemini CLI Integration
|
|
185
177
|
|
|
186
178
|
Usage: claude-mem gemini-cli <command>
|
|
@@ -196,53 +188,53 @@ Examples:
|
|
|
196
188
|
claude-mem gemini-cli uninstall # Remove hooks
|
|
197
189
|
|
|
198
190
|
For more info: https://docs.claude-mem.ai/usage/gemini-provider
|
|
199
|
-
`),0}}var
|
|
200
|
-
${
|
|
201
|
-
${
|
|
202
|
-
|
|
203
|
-
`+
|
|
204
|
-
`,
|
|
205
|
-
|
|
206
|
-
${
|
|
207
|
-
`,"utf-8"):
|
|
208
|
-
`,"utf-8")}var
|
|
209
|
-
`,"utf-8"),console.log(" Cleaned context from AGENTS.md"))}function
|
|
210
|
-
`+
|
|
191
|
+
`),0}}var Nt,P,z,Ze,Pu,ke,$r=m(()=>{"use strict";L();qe();Nt=Ar.join(Ru(),".gemini"),P=Ar.join(Nt,"settings.json"),z=Ar.join(Nt,"GEMINI.md"),Ze="claude-mem",Pu=1e4,ke={SessionStart:"context",BeforeAgent:"session-init",AfterAgent:"observation",BeforeTool:"observation",AfterTool:"observation",PreCompress:"summarize",Notification:"observation"}});import Wu from"path";import{existsSync as Gu,readFileSync as Hu,writeFileSync as Rr,mkdirSync as Ku}from"fs";function jt(t,e,r){let o=Wu.dirname(t);Ku(o,{recursive:!0});let s=`${Qe}
|
|
192
|
+
${e}
|
|
193
|
+
${Ae}`;if(Gu(t)){let i=Hu(t,"utf-8"),n=i.indexOf(Qe),u=i.indexOf(Ae);n!==-1&&u!==-1?i=i.slice(0,n)+s+i.slice(u+Ae.length):i=i.trimEnd()+`
|
|
194
|
+
|
|
195
|
+
`+s+`
|
|
196
|
+
`,Rr(t,i,"utf-8")}else r?Rr(t,`${r}
|
|
197
|
+
|
|
198
|
+
${s}
|
|
199
|
+
`,"utf-8"):Rr(t,s+`
|
|
200
|
+
`,"utf-8")}var Qe,Ae,Pr=m(()=>{"use strict";Qe="<claude-mem-context>",Ae="</claude-mem-context>"});var Lr={};q(Lr,{checkOpenCodeStatus:()=>ta,findBuiltPluginPath:()=>Lo,getInstalledPluginPath:()=>tt,getOpenCodeAgentsMdPath:()=>et,getOpenCodeConfigDirectory:()=>Ut,getOpenCodePluginsDirectory:()=>Tr,injectContextIntoAgentsMd:()=>Or,installOpenCodeIntegration:()=>ra,installOpenCodePlugin:()=>Bo,syncContextToAgentsMd:()=>zu,uninstallOpenCodePlugin:()=>ea});import ae from"path";import{homedir as Po}from"os";import{fileURLToPath as Ju}from"url";import{existsSync as be,readFileSync as To,writeFileSync as Yu,mkdirSync as Vu,copyFileSync as Xu,unlinkSync as Oo}from"fs";function Ut(){return process.env.OPENCODE_CONFIG_DIR?process.env.OPENCODE_CONFIG_DIR:ae.join(Po(),".config","opencode")}function Tr(){return ae.join(Ut(),"plugins")}function et(){return ae.join(Ut(),"AGENTS.md")}function tt(){return ae.join(Tr(),"claude-mem.js")}function Lo(){let t=[ae.join(process.env.CLAUDE_CONFIG_DIR||ae.join(Po(),".claude"),"plugins","marketplaces","thedotmack","dist","opencode-plugin","index.js"),ae.join(ae.dirname(Ju(import.meta.url)),"..","..","..","dist","opencode-plugin","index.js")];for(let e of t)if(be(e))return e;return null}function Bo(){let t=Lo();if(!t)return console.error("Could not find built OpenCode plugin bundle."),console.error(" Expected at: dist/opencode-plugin/index.js"),console.error(" Run the build first: npm run build"),1;let e=Tr(),r=tt();try{return Vu(e,{recursive:!0}),Xu(t,r),console.log(` Plugin installed to: ${r}`),a.info("OPENCODE","Plugin installed",{destination:r}),0}catch(o){let s=o instanceof Error?o.message:String(o);return console.error(`Failed to install OpenCode plugin: ${s}`),1}}function Or(t){let e=et();try{return jt(e,t,"# Claude-Mem Memory Context"),a.info("OPENCODE","Context injected into AGENTS.md",{path:e}),0}catch(r){let o=r instanceof Error?r.message:String(r);return console.error(`Failed to inject context into AGENTS.md: ${o}`),1}}async function zu(t,e){try{await Zu(t,e)}catch(r){r instanceof Error?a.debug("WORKER","Worker not available during context sync",{},r):a.debug("WORKER","Worker not available during context sync",{},new Error(String(r)))}}async function qu(){let t=Xe();if(!(await fetch(`http://127.0.0.1:${t}/api/readiness`)).ok)return null;let r=await fetch(`http://127.0.0.1:${t}/api/context/inject?project=opencode`);if(!r.ok)return null;let o=await r.text();return o&&o.trim()?o:null}async function Zu(t,e){let r=await fetch(`http://127.0.0.1:${t}/api/context/inject?project=${encodeURIComponent(e)}`);if(!r.ok)return;let o=await r.text();o&&o.trim()&&Or(o)!==0&&a.warn("OPENCODE","Failed to inject context into AGENTS.md during sync")}function Qu(t,e){e.length===0||e==="# Claude-Mem Memory Context"?(Oo(t),console.log(" Removed empty AGENTS.md")):(Yu(t,e+`
|
|
201
|
+
`,"utf-8"),console.log(" Cleaned context from AGENTS.md"))}function ea(){let t=!1,e=tt();if(be(e))try{Oo(e),console.log(` Removed plugin: ${e}`)}catch(o){let s=o instanceof Error?o.message:String(o);console.error(` Failed to remove plugin: ${s}`),t=!0}let r=et();if(be(r)){let o;try{o=To(r,"utf-8")}catch(n){let u=n instanceof Error?n.message:String(n);console.error(` Failed to read AGENTS.md: ${u}`),t=!0,o=""}let s=o.indexOf(Qe),i=o.indexOf(Ae);if(s!==-1&&i!==-1){o=o.slice(0,s).trimEnd()+`
|
|
202
|
+
`+o.slice(i+Ae.length).trimStart();let n=o.trim();try{Qu(r,n)}catch(u){let c=u instanceof Error?u.message:String(u);console.error(` Failed to clean AGENTS.md: ${c}`),t=!0}}}return t?1:0}function ta(){console.log(`
|
|
211
203
|
Claude-Mem OpenCode Integration Status
|
|
212
|
-
`);let
|
|
204
|
+
`);let t=Ut(),e=tt(),r=et();if(console.log(`Config directory: ${t}`),console.log(` Exists: ${be(t)?"yes":"no"}`),console.log(""),console.log(`Plugin: ${e}`),console.log(` Installed: ${be(e)?"yes":"no"}`),console.log(""),console.log(`Context (AGENTS.md): ${r}`),be(r)){let s=To(r,"utf-8").includes(Qe);console.log(" Exists: yes"),console.log(` Has claude-mem context: ${s?"yes":"no"}`)}else console.log(" Exists: no");return console.log(""),0}async function ra(){console.log(`
|
|
213
205
|
Installing Claude-Mem for OpenCode...
|
|
214
|
-
`);let
|
|
206
|
+
`);let t=Bo();if(t!==0)return t;let r=`# Memory Context from Past Sessions
|
|
215
207
|
|
|
216
208
|
*No context yet. Complete your first session and context will appear here.*
|
|
217
209
|
|
|
218
|
-
Use claude-mem search tools for manual memory queries.`,
|
|
210
|
+
Use claude-mem search tools for manual memory queries.`,o="placeholder";try{let i=await qu();i&&(r=i,o="existing memory")}catch(i){i instanceof Error?a.debug("WORKER","Worker not available during OpenCode install",{},i):a.debug("WORKER","Worker not available during OpenCode install",{},new Error(String(i)))}return Or(r)!==0?a.warn("OPENCODE",`Failed to inject ${o} context into AGENTS.md during install`):console.log(o==="existing memory"?" Context injected from existing memory":" Placeholder context created (worker not running)"),console.log(`
|
|
219
211
|
Installation complete!
|
|
220
212
|
|
|
221
|
-
Plugin installed to: ${
|
|
222
|
-
Context file: ${
|
|
213
|
+
Plugin installed to: ${tt()}
|
|
214
|
+
Context file: ${et()}
|
|
223
215
|
|
|
224
216
|
Next steps:
|
|
225
217
|
1. Start claude-mem worker: npx claude-mem start
|
|
226
218
|
2. Restart OpenCode to load the plugin
|
|
227
219
|
3. Memory capture is automatic from then on
|
|
228
|
-
`),0}var
|
|
220
|
+
`),0}var Br=m(()=>{"use strict";L();Pr();Pt()});var Ur={};q(Ur,{checkWindsurfHooksStatus:()=>Jo,handleWindsurfCommand:()=>pa,installWindsurfHooks:()=>Ho,readWindsurfRegistry:()=>Kt,registerWindsurfProject:()=>Wo,uninstallWindsurfHooks:()=>Ko,unregisterWindsurfProject:()=>Go,updateWindsurfContextForProject:()=>sa,writeWindsurfContextFile:()=>jr,writeWindsurfRegistry:()=>Nr});import H from"path";import{homedir as na}from"os";import{existsSync as Ie,readFileSync as Gt,writeFileSync as rt,unlinkSync as jo,mkdirSync as Ht,renameSync as oa}from"fs";function Kt(){try{return Ie(Me)?JSON.parse(Gt(Me,"utf-8")):{}}catch(t){return t instanceof Error?a.error("WORKER","Failed to read registry, using empty",{file:Me},t):a.error("WORKER","Failed to read registry, using empty",{file:Me},new Error(String(t))),{}}}function Nr(t){let e=H.dirname(Me);Ht(e,{recursive:!0}),rt(Me,JSON.stringify(t,null,2))}function Wo(t){let e=Kt();e[t]={installedAt:new Date().toISOString()},Nr(e),a.info("WINDSURF","Registered project for auto-context updates",{workspacePath:t})}function Go(t){let e=Kt();e[t]&&(delete e[t],Nr(e),a.info("WINDSURF","Unregistered project",{workspacePath:t}))}async function sa(t,e,r){if(Kt()[e])try{let i=await fetch(`http://127.0.0.1:${r}/api/context/inject?project=${encodeURIComponent(t)}`);if(!i.ok)return;let n=await i.text();if(!n||!n.trim())return;jr(e,n),a.debug("WINDSURF","Updated context file",{projectName:t,workspacePath:e})}catch(i){i instanceof Error?a.error("WORKER","Failed to update context file",{projectName:t,workspacePath:e},i):a.error("WORKER","Failed to update context file",{projectName:t,workspacePath:e},new Error(String(i)))}}function jr(t,e){let r=H.join(t,".windsurf","rules"),o=H.join(r,"claude-mem-context.md"),s=`${o}.tmp`;Ht(r,{recursive:!0});let i=`# Memory Context from Past Sessions
|
|
229
221
|
|
|
230
222
|
The following context is from claude-mem, a persistent memory system that tracks your coding sessions.
|
|
231
223
|
|
|
232
|
-
${
|
|
224
|
+
${e}
|
|
233
225
|
|
|
234
226
|
---
|
|
235
227
|
*Auto-updated by claude-mem after each session. Use MCP search tools for detailed queries.*
|
|
236
|
-
`;
|
|
228
|
+
`;i.length>No&&(i=i.slice(0,No-50)+`
|
|
237
229
|
|
|
238
230
|
*[Truncated \u2014 use MCP search for full history]*
|
|
239
|
-
`),
|
|
231
|
+
`),rt(s,i),oa(s,o)}function ia(t,e,r){let s={pre_user_prompt:"session-init",post_write_code:"file-edit",post_run_command:"observation",post_mcp_tool_use:"observation",post_cascade_response:"observation"}[r]??"observation";return`"${t}" "${e}" hook windsurf ${s}`}function ua(t,e,r){Ht(Uo,{recursive:!0});let o={hooks:{}};if(Ie(k))try{o=JSON.parse(Gt(k,"utf-8")),o.hooks||(o.hooks={})}catch(s){throw s instanceof Error?a.error("WORKER","Corrupt hooks.json, refusing to overwrite",{path:k},s):a.error("WORKER","Corrupt hooks.json, refusing to overwrite",{path:k},new Error(String(s))),new Error(`Corrupt hooks.json at ${k}, refusing to overwrite`)}for(let s of Wt){let n={command:ia(t,e,s),show_output:!1,working_directory:r},u=(o.hooks[s]??[]).filter(c=>!c.command.includes("worker-service")||!c.command.includes("windsurf"));o.hooks[s]=[...u,n]}rt(k,JSON.stringify(o,null,2))}async function Ho(){console.log(`
|
|
240
232
|
Installing Claude-Mem Windsurf hooks (user level)...
|
|
241
|
-
`);let
|
|
242
|
-
Installation failed: ${
|
|
233
|
+
`);let t=ve();if(!t)return console.error("Could not find worker-service.cjs"),console.error(" Expected at: ~/.claude/plugins/marketplaces/thedotmack/plugin/scripts/worker-service.cjs"),1;let e=_e();if(!e)return console.error("Could not find Bun runtime"),console.error(" Install Bun: curl -fsSL https://bun.sh/install | bash"),1;let r=H.dirname(t);console.log(` Using Bun runtime: ${e}`),console.log(` Worker service: ${t}`);let o=process.cwd();try{return await aa(e,t,r,o),0}catch(s){let i=s instanceof Error?s.message:String(s);return console.error(`
|
|
234
|
+
Installation failed: ${i}`),1}}async function aa(t,e,r,o){ua(t,e,r),console.log(" Created/merged hooks.json"),await ca(o),console.log(`
|
|
243
235
|
Installation complete!
|
|
244
236
|
|
|
245
|
-
Hooks installed to: ${
|
|
237
|
+
Hooks installed to: ${k}
|
|
246
238
|
Using unified CLI: bun worker-service.cjs hook windsurf <command>
|
|
247
239
|
|
|
248
240
|
Events registered:
|
|
@@ -256,21 +248,21 @@ Next steps:
|
|
|
256
248
|
1. Start claude-mem worker: claude-mem start
|
|
257
249
|
2. Restart Windsurf to load the hooks
|
|
258
250
|
3. Context is injected via .windsurf/rules/claude-mem-context.md (workspace-level)
|
|
259
|
-
`)}async function
|
|
251
|
+
`)}async function ca(t){let e=Xe(),r=H.basename(t),o=!1;console.log(" Generating initial context...");try{o=await la(e,r,t)}catch(s){s instanceof Error?a.debug("WORKER","Worker not running during install",{},s):a.debug("WORKER","Worker not running during install",{},new Error(String(s)))}if(!o){let s=H.join(t,".windsurf","rules");Ht(s,{recursive:!0});let i=H.join(s,"claude-mem-context.md");rt(i,`# Memory Context from Past Sessions
|
|
260
252
|
|
|
261
253
|
*No context yet. Complete your first session and context will appear here.*
|
|
262
254
|
|
|
263
255
|
Use claude-mem's MCP search tools for manual memory queries.
|
|
264
|
-
`),console.log(" Created placeholder context file (will populate after first session)")}
|
|
256
|
+
`),console.log(" Created placeholder context file (will populate after first session)")}Wo(t),console.log(" Registered for auto-context updates")}async function la(t,e,r){if(!(await fetch(`http://127.0.0.1:${t}/api/readiness`)).ok)return!1;let s=await fetch(`http://127.0.0.1:${t}/api/context/inject?project=${encodeURIComponent(e)}`);if(!s.ok)return!1;let i=await s.text();return i&&i.trim()?(jr(r,i),console.log(" Generated initial context from existing memory"),!0):!1}function Ko(){if(console.log(`
|
|
265
257
|
Uninstalling Claude-Mem Windsurf hooks...
|
|
266
|
-
`),
|
|
267
|
-
Uninstallation failed: ${r}`),1}}function
|
|
258
|
+
`),Ie(k))try{Da()}catch(e){e instanceof Error?a.error("WORKER","Could not parse hooks.json during uninstall",{path:k},e):a.error("WORKER","Could not parse hooks.json during uninstall",{path:k},new Error(String(e))),console.log(" Warning: could not parse hooks.json \u2014 leaving file intact to preserve other hooks")}else console.log(" No hooks.json found");let t=process.cwd();try{return da(t),0}catch(e){let r=e instanceof Error?e.message:String(e);return console.error(`
|
|
259
|
+
Uninstallation failed: ${r}`),1}}function Da(){let e={hooks:JSON.parse(Gt(k,"utf-8")).hooks??{}};for(let r of Wt){let o=e.hooks[r]??[];o.length>0&&(e.hooks[r]=o.filter(s=>!s.command.includes("worker-service")||!s.command.includes("windsurf")),e.hooks[r].length===0&&delete e.hooks[r])}Object.keys(e.hooks).length===0?(jo(k),console.log(" Removed hooks.json (no hooks remaining)")):(rt(k,JSON.stringify(e,null,2)),console.log(" Removed claude-mem entries from hooks.json (other hooks preserved)"))}function da(t){let e=H.join(t,".windsurf","rules","claude-mem-context.md");Ie(e)&&(jo(e),console.log(" Removed context file")),Go(t),console.log(" Unregistered from auto-context updates"),console.log(`
|
|
268
260
|
Uninstallation complete!
|
|
269
|
-
`),console.log("Restart Windsurf to apply changes.")}function
|
|
261
|
+
`),console.log("Restart Windsurf to apply changes.")}function Jo(){if(console.log(`
|
|
270
262
|
Claude-Mem Windsurf Hooks Status
|
|
271
|
-
`),
|
|
263
|
+
`),Ie(k)){console.log("User-level: Installed"),console.log(` Config: ${k}`);let t=null;try{t=JSON.parse(Gt(k,"utf-8"))}catch(r){let o=r instanceof Error?r:new Error(String(r));a.error("WORKER","Unable to parse hooks.json",{path:k},o),console.log(" Mode: Unable to parse hooks.json")}if(t){let r=Wt.filter(o=>(t?.hooks?.[o]??[]).some(s=>s.command.includes("worker-service")&&s.command.includes("windsurf")));console.log(` Events: ${r.length}/${Wt.length} registered`);for(let o of r)console.log(` - ${o}`)}let e=H.join(process.cwd(),".windsurf","rules","claude-mem-context.md");Ie(e)?console.log(" Context: Active (current workspace)"):console.log(" Context: Not yet generated for this workspace")}else console.log("User-level: Not installed"),console.log(`
|
|
272
264
|
No hooks installed. Run: claude-mem windsurf install
|
|
273
|
-
`);return console.log(""),0}async function
|
|
265
|
+
`);return console.log(""),0}async function pa(t,e){switch(t){case"install":return Ho();case"uninstall":return Ko();case"status":return Jo();default:return console.log(`
|
|
274
266
|
Claude-Mem Windsurf Integration
|
|
275
267
|
|
|
276
268
|
Usage: claude-mem windsurf <command>
|
|
@@ -286,33 +278,33 @@ Examples:
|
|
|
286
278
|
claude-mem windsurf status # Check if hooks are installed
|
|
287
279
|
|
|
288
280
|
For more info: https://docs.claude-mem.ai/windsurf
|
|
289
|
-
`),0}}var
|
|
290
|
-
`,"utf-8")}function
|
|
291
|
-
`,"utf-8");let
|
|
281
|
+
`),0}}var Uo,k,No,Me,Wt,Wr=m(()=>{"use strict";L();Pt();Ve();qe();Uo=H.join(na(),".codeium","windsurf"),k=H.join(Uo,"hooks.json"),No=6e3,Me=H.join(B,"windsurf-projects.json"),Wt=["pre_user_prompt","post_write_code","post_run_command","post_mcp_tool_use","post_cascade_response"]});var Kr={};q(Kr,{checkOpenClawStatus:()=>Fa,findPluginManifestPath:()=>qo,findPluginSkillsDirectory:()=>Zo,findPreBuiltPluginDirectory:()=>zo,getOpenClawClaudeMemExtensionDirectory:()=>ot,getOpenClawConfigDirectory:()=>nt,getOpenClawConfigFilePath:()=>$e,getOpenClawExtensionsDirectory:()=>Xo,installOpenClawIntegration:()=>Sa,installOpenClawPlugin:()=>es,uninstallOpenClawPlugin:()=>ha});import v from"path";import{homedir as Jt}from"os";import{existsSync as Q,readFileSync as ma,writeFileSync as Yo,mkdirSync as Vo,cpSync as Gr,rmSync as ga}from"fs";function nt(){return v.join(Jt(),".openclaw")}function Xo(){return v.join(nt(),"extensions")}function ot(){return v.join(Xo(),"claude-mem")}function $e(){return v.join(nt(),"openclaw.json")}function zo(){let t=[v.join(process.env.CLAUDE_CONFIG_DIR||v.join(Jt(),".claude"),"plugins","marketplaces","thedotmack"),process.cwd()];for(let e of t){let r=v.join(e,"openclaw","dist"),o=v.join(r,"index.js");if(Q(o))return r}return null}function qo(){let t=[v.join(process.env.CLAUDE_CONFIG_DIR||v.join(Jt(),".claude"),"plugins","marketplaces","thedotmack"),process.cwd()];for(let e of t){let r=v.join(e,"openclaw","openclaw.plugin.json");if(Q(r))return r}return null}function Zo(){let t=[v.join(process.env.CLAUDE_CONFIG_DIR||v.join(Jt(),".claude"),"plugins","marketplaces","thedotmack"),process.cwd()];for(let e of t){let r=v.join(e,"openclaw","skills");if(Q(r))return r}return null}function Hr(){let t=$e();if(!Q(t))return{};try{return JSON.parse(ma(t,"utf-8"))}catch(e){let r=e instanceof Error?e:new Error(String(e));throw a.error("WORKER","Failed to parse openclaw.json",{path:t},r),r}}function Qo(t){let e=nt();Vo(e,{recursive:!0}),Yo($e(),JSON.stringify(t,null,2)+`
|
|
282
|
+
`,"utf-8")}function fa(t,e="openclaw",r=!0){let o=Hr();if(o.plugins||(o.plugins={}),o.plugins.slots||(o.plugins.slots={}),o.plugins.entries||(o.plugins.entries={}),o.plugins.slots.memory="claude-mem",!o.plugins.entries["claude-mem"])o.plugins.entries["claude-mem"]={enabled:!0,config:{workerPort:t,project:e,syncMemoryFile:r}};else{o.plugins.entries["claude-mem"].enabled=!0,o.plugins.entries["claude-mem"].config||(o.plugins.entries["claude-mem"].config={});let s=o.plugins.entries["claude-mem"].config;s.workerPort===void 0&&(s.workerPort=t),s.project===void 0&&(s.project=e),s.syncMemoryFile===void 0&&(s.syncMemoryFile=r)}Qo(o)}function Ca(){let t=$e();if(!Q(t))return;let e=Hr();e.plugins?.entries?.["claude-mem"]&&delete e.plugins.entries["claude-mem"],e.plugins?.slots?.memory==="claude-mem"&&delete e.plugins.slots.memory,Qo(e)}function es(){let t=zo();if(!t)return console.error("Could not find pre-built OpenClaw plugin bundle."),console.error(" Expected at: openclaw/dist/index.js"),console.error(" Ensure the npm package includes the openclaw directory."),1;let e=ot(),r=v.join(e,"dist"),o=qo(),s=Zo(),i={name:"claude-mem",version:"1.0.0",type:"module",main:"dist/index.js",openclaw:{extensions:["./dist/index.js"]}};try{return Vo(r,{recursive:!0}),Ea(t,r,e,o,s,i),0}catch(n){let u=n instanceof Error?n.message:String(n);return console.error(`Failed to install OpenClaw plugin: ${u}`),1}}function Ea(t,e,r,o,s,i){if(Gr(t,e,{recursive:!0,force:!0}),console.log(` Plugin dist copied to: ${e}`),o){let u=v.join(r,"openclaw.plugin.json");Gr(o,u,{force:!0}),console.log(` Plugin manifest copied to: ${u}`)}if(s){let u=v.join(r,"skills");Gr(s,u,{recursive:!0,force:!0}),console.log(` Skills copied to: ${u}`)}Yo(v.join(r,"package.json"),JSON.stringify(i,null,2)+`
|
|
283
|
+
`,"utf-8");let n=x.getInt("CLAUDE_MEM_WORKER_PORT");fa(n),console.log(" Registered in openclaw.json"),a.info("OPENCLAW","Plugin installed",{destination:r})}function ha(){let t=!1,e=ot();if(Q(e))try{ga(e,{recursive:!0,force:!0}),console.log(` Removed extension: ${e}`)}catch(r){let o=r instanceof Error?r.message:String(r);console.error(` Failed to remove extension directory: ${o}`),t=!0}try{Ca(),console.log(" Unregistered from openclaw.json")}catch(r){let o=r instanceof Error?r.message:String(r);console.error(` Failed to update openclaw.json: ${o}`),t=!0}return t?1:0}function Fa(){console.log(`
|
|
292
284
|
Claude-Mem OpenClaw Integration Status
|
|
293
|
-
`);let
|
|
285
|
+
`);let t=nt(),e=ot(),r=$e(),o=v.join(e,"dist","index.js");if(console.log(`Config directory: ${t}`),console.log(` Exists: ${Q(t)?"yes":"no"}`),console.log(""),console.log(`Extension directory: ${e}`),console.log(` Exists: ${Q(e)?"yes":"no"}`),console.log(` Plugin entry: ${Q(o)?"yes":"no"}`),console.log(""),console.log(`Config (openclaw.json): ${r}`),Q(r)){let s=Hr(),i=s.plugins?.entries?.["claude-mem"]!==void 0,n=s.plugins?.entries?.["claude-mem"]?.enabled===!0,u=s.plugins?.slots?.memory==="claude-mem";if(console.log(" Exists: yes"),console.log(` Registered: ${i?"yes":"no"}`),console.log(` Enabled: ${n?"yes":"no"}`),console.log(` Memory slot: ${u?"yes":"no"}`),i){let c=s.plugins.entries["claude-mem"].config;c&&(console.log(` Worker port: ${c.workerPort??"default"}`),console.log(` Project: ${c.project??"default"}`),console.log(` Sync MEMORY.md: ${c.syncMemoryFile??"default"}`))}}else console.log(" Exists: no");return console.log(""),0}async function Sa(){console.log(`
|
|
294
286
|
Installing Claude-Mem for OpenClaw...
|
|
295
|
-
`);let
|
|
287
|
+
`);let t=es();if(t!==0)return t;let e=ot();return console.log(`
|
|
296
288
|
Installation complete!
|
|
297
289
|
|
|
298
|
-
Plugin installed to: ${
|
|
299
|
-
Config updated: ${
|
|
290
|
+
Plugin installed to: ${e}
|
|
291
|
+
Config updated: ${$e()}
|
|
300
292
|
|
|
301
293
|
Next steps:
|
|
302
294
|
1. Start claude-mem worker: npx claude-mem start
|
|
303
295
|
2. Restart OpenClaw to load the plugin
|
|
304
296
|
3. Memory capture is automatic from then on
|
|
305
|
-
`),0}var
|
|
306
|
-
`)}function
|
|
297
|
+
`),0}var Jr=m(()=>{"use strict";L();me()});import{existsSync as Ad,readFileSync as bd,writeFileSync as Md,mkdirSync as Id}from"fs";import{homedir as ts}from"os";import{join as rs,dirname as Pd}from"path";var ge,st,ya,Yt,ns=m(()=>{"use strict";ge=rs(ts(),".claude-mem","transcript-watch.json"),st=rs(ts(),".claude-mem","transcript-watch-state.json"),ya={name:"codex",version:"0.3",description:"Schema for Codex session JSONL files under ~/.codex/sessions.",events:[{name:"session-meta",match:{path:"type",equals:"session_meta"},action:"session_context",fields:{sessionId:"payload.id",cwd:"payload.cwd"}},{name:"turn-context",match:{path:"type",equals:"turn_context"},action:"session_context",fields:{cwd:"payload.cwd"}},{name:"user-message",match:{path:"payload.type",equals:"user_message"},action:"session_init",fields:{prompt:"payload.message"}},{name:"assistant-message",match:{path:"payload.type",equals:"agent_message"},action:"assistant_message",fields:{message:"payload.message"}},{name:"tool-use",match:{path:"payload.type",in:["function_call","custom_tool_call","web_search_call","exec_command"]},action:"tool_use",fields:{toolId:"payload.call_id",toolName:{coalesce:["payload.name","payload.type",{value:"web_search"}]},toolInput:{coalesce:["payload.arguments","payload.input","payload.command","payload.action"]}}},{name:"tool-result",match:{path:"payload.type",in:["function_call_output","custom_tool_call_output","exec_command_output"]},action:"tool_result",fields:{toolId:"payload.call_id",toolResponse:"payload.output"}},{name:"session-end",match:{path:"payload.type",in:["turn_aborted","turn_completed"]},action:"session_end"}]},Yt={version:1,schemas:{codex:ya},watches:[{name:"codex",path:"~/.codex/sessions/**/*.jsonl",schema:"codex",startAtEnd:!0,context:{mode:"agents",updateOn:["session_start","session_end"]}}],stateFile:st}});var zr={};q(zr,{installCodexCli:()=>ba,uninstallCodexCli:()=>Ia});import Vr from"path";import{homedir as os}from"os";import{existsSync as Xr,readFileSync as Yr,writeFileSync as Vt,mkdirSync as wa}from"fs";function ss(){let t=ge;if(!Xr(t))return{version:1,schemas:{},watches:[],stateFile:st};try{let e=Yr(t,"utf-8"),r=JSON.parse(e);return r.version||(r.version=1),r.watches||(r.watches=[]),r.schemas||(r.schemas={}),r.stateFile||(r.stateFile=st),r}catch(e){e instanceof Error?a.error("WORKER","Corrupt transcript-watch.json, creating backup",{path:t},e):a.error("WORKER","Corrupt transcript-watch.json, creating backup",{path:t},new Error(String(e)));let r=`${t}.backup.${Date.now()}`;return Vt(r,Yr(t)),console.warn(` Backed up corrupt transcript-watch.json to ${r}`),{version:1,schemas:{},watches:[],stateFile:st}}}function xa(t){let e={...t};e.schemas={...e.schemas};let r=Yt.schemas?.[Re];r&&(e.schemas[Re]=r);let o=Yt.watches.find(s=>s.name===Re);if(o){let s=e.watches.findIndex(i=>i.name===Re);s!==-1?e.watches[s]=o:e.watches.push(o)}return e}function is(t){wa(_a,{recursive:!0}),Vt(ge,JSON.stringify(t,null,2)+`
|
|
298
|
+
`)}function ka(){if(!Xr(it))return;let t="<claude-mem-context>",e="</claude-mem-context>";try{Aa(t,e)}catch(r){let o=r instanceof Error?r.message:String(r);a.warn("WORKER","Failed to clean AGENTS.md context",{error:o})}}function Aa(t,e){let r=Yr(it,"utf-8"),o=r.indexOf(t),s=r.indexOf(e);if(o===-1||s===-1)return;let i=r.substring(0,o).replace(/\n+$/,""),n=r.substring(s+e.length).replace(/^\n+/,""),u=(i+(n?`
|
|
307
299
|
|
|
308
|
-
`+
|
|
309
|
-
`):
|
|
300
|
+
`+n:"")).trim();u?Vt(it,u+`
|
|
301
|
+
`):Vt(it,""),console.log(` Removed legacy global context from ${it}`)}async function ba(){console.log(`
|
|
310
302
|
Installing Claude-Mem for Codex CLI (transcript watching)...
|
|
311
|
-
`);let
|
|
312
|
-
Installation failed: ${
|
|
303
|
+
`);let t=ss(),e=xa(t);try{return Ma(e),0}catch(r){let o=r instanceof Error?r.message:String(r);return console.error(`
|
|
304
|
+
Installation failed: ${o}`),1}}function Ma(t){is(t),console.log(` Updated ${ge}`),console.log(" Watch path: ~/.codex/sessions/**/*.jsonl"),console.log(` Schema: codex (v${Yt.schemas?.codex?.version??"?"})`),us(),console.log(`
|
|
313
305
|
Installation complete!
|
|
314
306
|
|
|
315
|
-
Transcript watch config: ${
|
|
307
|
+
Transcript watch config: ${ge}
|
|
316
308
|
Context files: <workspace>/AGENTS.md
|
|
317
309
|
|
|
318
310
|
How it works:
|
|
@@ -323,33 +315,33 @@ How it works:
|
|
|
323
315
|
Next steps:
|
|
324
316
|
1. Start claude-mem worker: npx claude-mem start
|
|
325
317
|
2. Use Codex CLI as usual -- memory capture is automatic!
|
|
326
|
-
`)}function
|
|
318
|
+
`)}function Ia(){if(console.log(`
|
|
327
319
|
Uninstalling Claude-Mem Codex CLI integration...
|
|
328
|
-
`),
|
|
329
|
-
Uninstallation failed: ${r}`),1}}else console.log(" No transcript-watch.json found -- nothing to remove.");return
|
|
320
|
+
`),Xr(ge)){let t=ss();t.watches=t.watches.filter(e=>e.name!==Re),t.schemas&&delete t.schemas[Re];try{is(t),console.log(` Removed codex watch from ${ge}`)}catch(e){let r=e instanceof Error?e.message:String(e);return console.error(`
|
|
321
|
+
Uninstallation failed: ${r}`),1}}else console.log(" No transcript-watch.json found -- nothing to remove.");return us(),console.log(`
|
|
330
322
|
Uninstallation complete!`),console.log(`Restart claude-mem worker to apply changes.
|
|
331
|
-
`),0}var
|
|
332
|
-
`)}function
|
|
333
|
-
Installing Claude-Mem MCP integration for ${
|
|
334
|
-
`);let
|
|
335
|
-
Installation failed: ${
|
|
323
|
+
`),0}var va,it,_a,Re,us,qr=m(()=>{"use strict";L();ns();va=Vr.join(os(),".codex"),it=Vr.join(va,"AGENTS.md"),_a=Vr.join(os(),".claude-mem"),Re="codex";us=ka});var ps={};q(ps,{MCP_IDE_INSTALLERS:()=>Ka,installGooseMcpIntegration:()=>ds});import W from"path";import{homedir as ct}from"os";import{existsSync as ls,readFileSync as $a,writeFileSync as at,mkdirSync as Ds}from"fs";function Pa(t){return{command:process.execPath,args:[t]}}function Ta(t,e,r="mcpServers"){let o=W.dirname(t);Ds(o,{recursive:!0});let s=J(t,{});s[r]||(s[r]={}),s[r]["claude-mem"]=Pa(e),at(t,JSON.stringify(s,null,2)+`
|
|
324
|
+
`)}function ut(t){return async()=>{console.log(`
|
|
325
|
+
Installing Claude-Mem MCP integration for ${t.ideLabel}...
|
|
326
|
+
`);let e=ze();if(!e)return console.error("Could not find MCP server script"),console.error(" Expected at: ~/.claude/plugins/marketplaces/thedotmack/plugin/scripts/mcp-server.cjs"),1;let r=t.configPath,o=t.ideId==="warp"&&!ls(W.dirname(r)),s;t.contextFile&&(s=t.contextFile.path);try{return Oa(t,r,e,o,s),0}catch(i){let n=i instanceof Error?i.message:String(i);return console.error(`
|
|
327
|
+
Installation failed: ${n}`),1}}}function Oa(t,e,r,o,s){o?console.log(" Note: ~/.warp/ not found. MCP may need to be configured via Warp Drive UI."):(Ta(e,r,t.configKey),console.log(` MCP config written to: ${e}`)),s&&(jt(s,Ra),console.log(` Context placeholder written to: ${s}`));let i=[`
|
|
336
328
|
Installation complete!
|
|
337
|
-
`];
|
|
338
|
-
`))}function
|
|
339
|
-
`)}function
|
|
340
|
-
`)}async function
|
|
329
|
+
`];i.push(`MCP config: ${e}`),s&&i.push(`Context: ${s}`),i.push(""),i.push("Note: This is an MCP-only integration providing search tools and context."),i.push(`Transcript capture is not available for ${t.ideLabel}.`),t.ideId==="warp"&&i.push("If MCP config via file is not supported, configure MCP through Warp Drive UI."),i.push(""),i.push("Next steps:"),i.push(" 1. Start claude-mem worker: npx claude-mem start"),i.push(` 2. Restart ${t.ideLabel} to pick up the MCP server`),i.push(""),console.log(i.join(`
|
|
330
|
+
`))}function Wa(){return W.join(ct(),".config","goose","config.yaml")}function Ga(t){return t.includes("claude-mem:")&&t.includes("mcpServers:")}function as(t){return["mcpServers:"," claude-mem:",` command: ${process.execPath}`," args:",` - ${t}`].join(`
|
|
331
|
+
`)}function cs(t){return[" claude-mem:",` command: ${process.execPath}`," args:",` - ${t}`].join(`
|
|
332
|
+
`)}async function ds(){console.log(`
|
|
341
333
|
Installing Claude-Mem MCP integration for Goose...
|
|
342
|
-
`);let
|
|
343
|
-
Installation failed: ${
|
|
344
|
-
`;if(!
|
|
345
|
-
`+
|
|
346
|
-
`+
|
|
334
|
+
`);let t=ze();if(!t)return console.error("Could not find MCP server script"),console.error(" Expected at: ~/.claude/plugins/marketplaces/thedotmack/plugin/scripts/mcp-server.cjs"),1;let e=Wa(),r=W.dirname(e);try{return Ds(r,{recursive:!0}),Ha(e,t),0}catch(o){let s=o instanceof Error?o.message:String(o);return console.error(`
|
|
335
|
+
Installation failed: ${s}`),1}}function Ha(t,e){if(ls(t)){let r=$a(t,"utf-8");if(Ga(r)){let o=/( {2}claude-mem:\n(?:.*\n)*?(?= {2}\S|\n\n|^\S|$))/m,s=cs(e)+`
|
|
336
|
+
`;if(!o.test(r))throw new Error("Found mcpServers/claude-mem markers but could not locate a replaceable claude-mem block");r=r.replace(o,s),at(t,r),console.log(` Updated existing claude-mem entry in: ${t}`)}else if(r.includes("mcpServers:")){let s=r.indexOf("mcpServers:")+11,i=`
|
|
337
|
+
`+cs(e);r=r.slice(0,s)+i+r.slice(s),at(t,r),console.log(` Added claude-mem to existing mcpServers in: ${t}`)}else{let o=`
|
|
338
|
+
`+as(e)+`
|
|
347
339
|
`;r=r.trimEnd()+`
|
|
348
|
-
`+
|
|
349
|
-
|
|
340
|
+
`+o,at(t,r),console.log(` Appended mcpServers section to: ${t}`)}}else{let r=as(e)+`
|
|
341
|
+
`;at(t,r),console.log(` Created config with MCP server: ${t}`)}console.log(`
|
|
350
342
|
Installation complete!
|
|
351
343
|
|
|
352
|
-
MCP config: ${
|
|
344
|
+
MCP config: ${t}
|
|
353
345
|
|
|
354
346
|
Note: This is an MCP-only integration providing search tools and context.
|
|
355
347
|
Transcript capture is not available for Goose.
|
|
@@ -357,42 +349,42 @@ Transcript capture is not available for Goose.
|
|
|
357
349
|
Next steps:
|
|
358
350
|
1. Start claude-mem worker: npx claude-mem start
|
|
359
351
|
2. Restart Goose to pick up the MCP server
|
|
360
|
-
`)}var
|
|
352
|
+
`)}var Ra,La,Ba,Na,ja,Ua,Ka,ms=m(()=>{"use strict";qe();Oe();Pr();Ra=`# claude-mem: Cross-Session Memory
|
|
361
353
|
|
|
362
354
|
*No context yet. Complete your first session and context will appear here.*
|
|
363
355
|
|
|
364
|
-
Use claude-mem's MCP search tools for manual memory queries.`;
|
|
365
|
-
`),
|
|
366
|
-
${
|
|
367
|
-
`),"Next Steps"),
|
|
368
|
-
Next Steps`),
|
|
356
|
+
Use claude-mem's MCP search tools for manual memory queries.`;La={ideId:"copilot-cli",ideLabel:"Copilot CLI",configPath:W.join(ct(),".github","copilot","mcp.json"),configKey:"servers",contextFile:{path:W.join(process.cwd(),".github","copilot-instructions.md"),isWorkspaceRelative:!0}},Ba={ideId:"antigravity",ideLabel:"Antigravity",configPath:W.join(ct(),".gemini","antigravity","mcp_config.json"),configKey:"mcpServers",contextFile:{path:W.join(process.cwd(),".agents","rules","claude-mem-context.md"),isWorkspaceRelative:!0}},Na={ideId:"crush",ideLabel:"Crush",configPath:W.join(ct(),".config","crush","mcp.json"),configKey:"mcpServers"},ja={ideId:"roo-code",ideLabel:"Roo Code",configPath:W.join(process.cwd(),".roo","mcp.json"),configKey:"mcpServers",contextFile:{path:W.join(process.cwd(),".roo","rules","claude-mem-context.md"),isWorkspaceRelative:!0}},Ua={ideId:"warp",ideLabel:"Warp",configPath:W.join(ct(),".warp","mcp.json"),configKey:"mcpServers",contextFile:{path:W.join(process.cwd(),"WARP.md"),isWorkspaceRelative:!0}};Ka={"copilot-cli":ut(La),antigravity:ut(Ba),goose:ds,crush:ut(Na),"roo-code":ut(ja),warp:ut(Ua)}});var Xt={};q(Xt,{runInstallCommand:()=>nc});import{execSync as Zr}from"child_process";import{cpSync as gs,existsSync as lt,readFileSync as Ja,rmSync as fs}from"fs";import{join as Pe}from"path";async function Ya(t){if(ce)await vt(t);else for(let e of t){let r=await e.task(o=>console.log(` ${o}`));console.log(` ${r}`)}}function Va(){let t=J(he(),{});t.thedotmack={source:{source:"github",repo:"thedotmack/claude-mem"},installLocation:$(),lastUpdated:new Date().toISOString(),autoUpdate:!0},Ne(De()),se(he(),t)}function Xa(t){let e=J(Fe(),{});e.version||(e.version=2),e.plugins||(e.plugins={});let r=tr(t),o=new Date().toISOString();e.plugins["claude-mem@thedotmack"]=[{scope:"user",installPath:r,version:t,installedAt:o,lastUpdated:o}],se(Fe(),e)}function za(){let t=J(Se(),{});t.enabledPlugins||(t.enabledPlugins={}),t.enabledPlugins["claude-mem@thedotmack"]=!0,se(Se(),t)}async function qa(t){let e=[];for(let r of t)switch(r){case"claude-code":{try{Zr("claude plugin marketplace add thedotmack/claude-mem && claude plugin install claude-mem",{stdio:"inherit"}),C.success("Claude Code: plugin installed via CLI.")}catch(o){console.error("[install] Claude Code plugin install error:",o instanceof Error?o.message:String(o)),C.error("Claude Code: plugin install failed. Is `claude` CLI on your PATH?"),e.push(r)}break}case"cursor":{let{installCursorHooks:o,configureCursorMcp:s}=await Promise.resolve().then(()=>(qe(),Ao));await o("user")===0?s("user")===0?C.success("Cursor: hooks + MCP installed."):C.success("Cursor: hooks installed (MCP setup failed \u2014 run `npx claude-mem cursor mcp` to retry)."):(C.error("Cursor: hook installation failed."),e.push(r));break}case"gemini-cli":{let{installGeminiCliHooks:o}=await Promise.resolve().then(()=>($r(),Ir));await o()===0?C.success("Gemini CLI: hooks installed."):(C.error("Gemini CLI: hook installation failed."),e.push(r));break}case"opencode":{let{installOpenCodeIntegration:o}=await Promise.resolve().then(()=>(Br(),Lr));await o()===0?C.success("OpenCode: plugin installed."):(C.error("OpenCode: plugin installation failed."),e.push(r));break}case"windsurf":{let{installWindsurfHooks:o}=await Promise.resolve().then(()=>(Wr(),Ur));await o()===0?C.success("Windsurf: hooks installed."):(C.error("Windsurf: hook installation failed."),e.push(r));break}case"openclaw":{let{installOpenClawIntegration:o}=await Promise.resolve().then(()=>(Jr(),Kr));await o()===0?C.success("OpenClaw: plugin installed."):(C.error("OpenClaw: plugin installation failed."),e.push(r));break}case"codex-cli":{let{installCodexCli:o}=await Promise.resolve().then(()=>(qr(),zr));await o()===0?C.success("Codex CLI: transcript watching configured."):(C.error("Codex CLI: integration setup failed."),e.push(r));break}case"copilot-cli":case"antigravity":case"goose":case"crush":case"roo-code":case"warp":{let{MCP_IDE_INSTALLERS:o}=await Promise.resolve().then(()=>(ms(),ps)),s=o[r];if(s){let i=await s(),c=Je().find(D=>D.id===r)?.label??r;i===0?C.success(`${c}: MCP integration installed.`):(C.error(`${c}: MCP integration failed.`),e.push(r))}break}default:{let s=Je().find(i=>i.id===r);s&&!s.supported&&C.warn(`Support for ${s.label} coming soon.`);break}}return e}async function Za(){let e=Je().filter(s=>s.detected);if(e.length===0)return C.warn("No supported IDEs detected. Installing for Claude Code by default."),["claude-code"];let r=e.map(s=>({value:s.id,label:s.label,hint:s.supported?s.hint:"coming soon"})),o=await Ln({message:"Which IDEs do you use?",options:r,initialValues:[],required:!0});return ue(o)&&(He("Installation cancelled."),process.exit(0)),o}function Qa(){let t=$(),e=mt();Ne(t);let r=["plugin","package.json","package-lock.json","node_modules","openclaw","dist","LICENSE","README.md","CHANGELOG.md"];for(let o of r){let s=Pe(e,o),i=Pe(t,o);lt(s)&&(lt(i)&&fs(i,{recursive:!0,force:!0}),gs(s,i,{recursive:!0,force:!0}))}}function ec(t){let e=rr(),r=tr(t);fs(r,{recursive:!0,force:!0}),Ne(r),gs(e,r,{recursive:!0,force:!0})}function tc(){let t=$(),e=Pe(t,"package.json");lt(e)&&Zr("npm install --production",{cwd:t,stdio:"pipe",encoding:"utf8",...te?{shell:process.env.ComSpec??"cmd.exe"}:{}})}function rc(){let t=Pe($(),"plugin","scripts","smart-install.js");if(!lt(t))return C.warn("smart-install.js not found \u2014 skipping Bun/uv auto-install."),!1;try{return Zr(`node "${t}"`,{stdio:"inherit",encoding:"utf8",...te?{shell:process.env.ComSpec??"cmd.exe"}:{}}),!0}catch(e){return console.warn("[install] smart-install error:",e instanceof Error?e.message:String(e)),C.warn("smart-install encountered an issue. You may need to install Bun/uv manually."),!1}}async function nc(t={}){let e=Be();ce?wt(E.default.bgCyan(E.default.black(" claude-mem install "))):console.log("claude-mem install"),C.info(`Version: ${E.default.cyan(e)}`),C.info(`Platform: ${process.platform} (${process.arch})`);let r=$();if(lt(Pe(r,"plugin",".claude-plugin","plugin.json"))){try{let g=JSON.parse(Ja(Pe(r,"plugin",".claude-plugin","plugin.json"),"utf-8"));C.warn(`Existing installation detected (v${g.version??"unknown"}).`)}catch(g){console.warn("[install] Failed to read existing plugin version:",g instanceof Error?g.message:String(g)),C.warn("Existing installation detected.")}if(process.stdin.isTTY){let g=await We({message:"Overwrite existing installation?",initialValue:!0});(ue(g)||!g)&&(He("Installation cancelled."),process.exit(0))}}let s;if(t.ide){s=[t.ide];let g=Je(),h=g.find(N=>N.id===t.ide);h&&!h.supported&&(C.error(`Support for ${h.label} coming soon.`),process.exit(1)),h||(C.error(`Unknown IDE: ${t.ide}`),C.info(`Available IDEs: ${g.map(N=>N.id).join(", ")}`),process.exit(1))}else process.stdin.isTTY?s=await Za():s=["claude-code"];if(s.some(g=>g!=="claude-code")){let g=x.get("CLAUDE_MEM_WORKER_PORT");try{(await _t(g,1e4)).workerWasRunning&&C.info("Stopped running worker before overwrite.")}catch(h){console.warn("[install] Pre-overwrite worker shutdown failed:",h instanceof Error?h.message:String(h))}await Ya([{title:"Copying plugin files",task:async h=>(h("Copying to marketplace directory..."),Qa(),`Plugin files copied ${E.default.green("OK")}`)},{title:"Caching plugin version",task:async h=>(h(`Caching v${e}...`),ec(e),`Plugin cached (v${e}) ${E.default.green("OK")}`)},{title:"Registering marketplace",task:async()=>(Va(),`Marketplace registered ${E.default.green("OK")}`)},{title:"Registering plugin",task:async()=>(Xa(e),`Plugin registered ${E.default.green("OK")}`)},{title:"Enabling plugin in Claude settings",task:async()=>(za(),`Plugin enabled ${E.default.green("OK")}`)},{title:"Installing dependencies",task:async h=>{h("Running npm install...");try{return tc(),`Dependencies installed ${E.default.green("OK")}`}catch(N){return console.warn("[install] npm install error:",N instanceof Error?N.message:String(N)),`Dependencies may need manual install ${E.default.yellow("!")}`}}},{title:"Setting up Bun and uv",task:async h=>(h("Running smart-install..."),rc()?`Runtime dependencies ready ${E.default.green("OK")}`:`Runtime setup may need attention ${E.default.yellow("!")}`)}])}let n=await qa(s),u=n.length>0?"Installation Partial":"Installation Complete",c=[`Version: ${E.default.cyan(e)}`,`Plugin dir: ${E.default.cyan(r)}`,`IDEs: ${E.default.cyan(s.join(", "))}`];n.length>0&&c.push(`Failed: ${E.default.red(n.join(", "))}`),ce?Ge(c.join(`
|
|
357
|
+
`),u):(console.log(`
|
|
358
|
+
${u}`),c.forEach(g=>console.log(` ${g}`)));let D=x.get("CLAUDE_MEM_WORKER_PORT"),d=D,p=!1;try{let g=await fetch(`http://127.0.0.1:${D}/api/health`,{signal:AbortSignal.timeout(3e3)});if(g.ok){p=!0;try{let h=await g.json();h&&(typeof h.port=="number"||typeof h.port=="string")&&(d=h.port)}catch{}}}catch{}let _=["Open Claude Code and start a conversation -- memory is automatic!",p?`Worker port: ${E.default.cyan(String(d))}`:`Worker port: ${E.default.cyan(String(D))} (worker not yet ready -- still starting up; check ${E.default.bold("claude-mem status")} later)`,`View your memories: ${E.default.underline(`http://localhost:${d}`)}`,`Search past work: use ${E.default.bold("/mem-search")} in Claude Code`,`Start worker: ${E.default.bold("npx claude-mem start")}`,`Note: Close all Claude Code sessions before uninstalling, or ${E.default.cyan("~/.claude-mem")} will be recreated by active hooks.`];ce?(Ge(_.join(`
|
|
359
|
+
`),"Next Steps"),n.length>0?pe(E.default.yellow("claude-mem installed with some IDE setup failures.")):pe(E.default.green("claude-mem installed successfully!"))):(console.log(`
|
|
360
|
+
Next Steps`),_.forEach(g=>console.log(` ${g}`)),n.length>0?(console.log(`
|
|
369
361
|
claude-mem installed with some IDE setup failures.`),process.exitCode=1):console.log(`
|
|
370
|
-
claude-mem installed successfully!`))}var
|
|
371
|
-
`),i
|
|
372
|
-
`)),console.error(`Removed legacy claude-mem alias from ${
|
|
373
|
-
`),"Note")
|
|
374
|
-
${
|
|
375
|
-
|
|
376
|
-
${
|
|
377
|
-
${
|
|
378
|
-
${
|
|
379
|
-
${
|
|
380
|
-
${
|
|
381
|
-
${
|
|
382
|
-
${
|
|
383
|
-
|
|
384
|
-
${
|
|
385
|
-
${
|
|
386
|
-
${
|
|
387
|
-
${
|
|
388
|
-
${
|
|
389
|
-
${
|
|
390
|
-
${
|
|
391
|
-
${
|
|
392
|
-
${
|
|
393
|
-
|
|
394
|
-
${
|
|
362
|
+
claude-mem installed successfully!`))}var E,ce,C,zt=m(()=>{"use strict";mr();E=le(Ee(),1);de();Oe();me();gr();Hn();ce=process.stdin.isTTY===!0;C={info:t=>ce?R.info(t):console.log(` ${t}`),success:t=>ce?R.success(t):console.log(` ${t}`),warn:t=>ce?R.warn(t):console.warn(` ${t}`),error:t=>ce?R.error(t):console.error(` ${t}`)}});var Es={};q(Es,{runUninstallCommand:()=>pc});import{existsSync as fe,readFileSync as oc,readdirSync as Qr,rmSync as Dt,writeFileSync as sc}from"fs";import{homedir as Cs}from"os";import{join as ee}from"path";function ic(){let t=$();return fe(t)?(Dt(t,{recursive:!0,force:!0}),!0):!1}function uc(){let t=ee(De(),"cache","thedotmack","claude-mem");return fe(t)?(Dt(t,{recursive:!0,force:!0}),!0):!1}function ac(){let t=J(he(),{});t.thedotmack&&(delete t.thedotmack,se(he(),t))}function cc(){let t=J(Fe(),{});t.plugins?.["claude-mem@thedotmack"]&&(delete t.plugins["claude-mem@thedotmack"],se(Fe(),t))}function lc(){let t=Cs(),e=[ee(t,".bashrc"),ee(t,".zshrc"),ee(t,"Documents","PowerShell","Microsoft.PowerShell_profile.ps1")],r=/^\s*alias\s+claude-mem\s*=/;for(let o of e){if(!fe(o))continue;let s;try{s=oc(o,"utf-8")}catch(u){console.warn(`[uninstall] Could not read ${o}:`,u instanceof Error?u.message:String(u));continue}let i=s.split(`
|
|
363
|
+
`),n=i.filter(u=>!r.test(u));if(n.length!==i.length)try{sc(o,n.join(`
|
|
364
|
+
`)),console.error(`Removed legacy claude-mem alias from ${o}`)}catch(u){console.warn(`[uninstall] Could not rewrite ${o}:`,u instanceof Error?u.message:String(u))}}}function Dc(){let t=J(Se(),{});t.enabledPlugins?.["claude-mem@thedotmack"]!==void 0&&(delete t.enabledPlugins["claude-mem@thedotmack"],se(Se(),t))}function dc(){let t=Cs(),e=0,r=ee(t,".npm","_npx");if(fe(r)){let i=[];try{i=Qr(r)}catch(n){console.warn(`[uninstall] Could not read ${r}:`,n instanceof Error?n.message:String(n))}for(let n of i){let u=ee(r,n,"node_modules","claude-mem");if(fe(u))try{Dt(u,{recursive:!0,force:!0}),e++}catch(c){console.warn(`[uninstall] Could not remove ${u}:`,c instanceof Error?c.message:String(c))}}}let o=ee(t,".cache","claude-cli-nodejs");if(fe(o)){let i=[];try{i=Qr(o)}catch(n){console.warn(`[uninstall] Could not read ${o}:`,n instanceof Error?n.message:String(n))}for(let n of i){let u=ee(o,n),c=[];try{c=Qr(u)}catch(D){console.warn(`[uninstall] Could not read ${u}:`,D instanceof Error?D.message:String(D));continue}for(let D of c){if(!D.startsWith("mcp-logs-plugin-claude-mem-"))continue;let d=ee(u,D);try{Dt(d,{recursive:!0,force:!0}),e++}catch(p){console.warn(`[uninstall] Could not remove ${d}:`,p instanceof Error?p.message:String(p))}}}}let s=ee(t,".claude","plugins","data","claude-mem-thedotmack");if(fe(s))try{Dt(s,{recursive:!0,force:!0}),e++}catch(i){console.warn(`[uninstall] Could not remove ${s}:`,i instanceof Error?i.message:String(i))}return e}async function pc(){if(wt(T.default.bgRed(T.default.white(" claude-mem uninstall "))),gt()){if(process.stdin.isTTY){let r=await We({message:"Are you sure you want to uninstall claude-mem?",initialValue:!1});if(ue(r)||!r){He("Uninstall cancelled.");return}}}else if(R.warn("claude-mem does not appear to be installed."),process.stdin.isTTY){let r=await We({message:"Clean up any remaining registration data anyway?",initialValue:!1});if(ue(r)||!r){pe("Nothing to do.");return}}else{pe("Nothing to do.");return}let t=x.get("CLAUDE_MEM_WORKER_PORT");try{(await _t(t,1e4)).workerWasRunning&&R.info("Worker service stopped.")}catch(r){console.warn("[uninstall] Worker shutdown attempt failed:",r instanceof Error?r.message:String(r))}await vt([{title:"Removing marketplace directory",task:async()=>ic()?`Marketplace directory removed ${T.default.green("OK")}`:`Marketplace directory not found ${T.default.dim("skipped")}`},{title:"Removing cache directory",task:async()=>uc()?`Cache directory removed ${T.default.green("OK")}`:`Cache directory not found ${T.default.dim("skipped")}`},{title:"Removing marketplace registration",task:async()=>(ac(),`Marketplace registration removed ${T.default.green("OK")}`)},{title:"Removing plugin registration",task:async()=>(cc(),`Plugin registration removed ${T.default.green("OK")}`)},{title:"Removing from Claude settings",task:async()=>(Dc(),`Claude settings updated ${T.default.green("OK")}`)},{title:"Removing legacy claude-mem shell alias",task:async()=>(lc(),`Legacy alias check complete ${T.default.green("OK")}`)},{title:"Removing stray claude-mem caches and logs",task:async()=>{let r=dc();return r>0?`Stray paths removed: ${r} ${T.default.green("OK")}`:`No stray paths found ${T.default.dim("skipped")}`}}]);let e=[{label:"Gemini CLI hooks",fn:async()=>{let{uninstallGeminiCliHooks:r}=await Promise.resolve().then(()=>($r(),Ir));return r()}},{label:"Windsurf hooks",fn:async()=>{let{uninstallWindsurfHooks:r}=await Promise.resolve().then(()=>(Wr(),Ur));return r()}},{label:"OpenCode plugin",fn:async()=>{let{uninstallOpenCodePlugin:r}=await Promise.resolve().then(()=>(Br(),Lr));return r()}},{label:"OpenClaw plugin",fn:async()=>{let{uninstallOpenClawPlugin:r}=await Promise.resolve().then(()=>(Jr(),Kr));return r()}},{label:"Codex CLI",fn:async()=>{let{uninstallCodexCli:r}=await Promise.resolve().then(()=>(qr(),zr));return r()}}];for(let{label:r,fn:o}of e)try{await o()===0&&R.info(`${r}: removed.`)}catch(s){console.warn(`[uninstall] ${r} cleanup failed:`,s instanceof Error?s.message:String(s))}Ge([`Your data directory at ${T.default.cyan("~/.claude-mem")} was preserved.`,"To remove it manually: rm -rf ~/.claude-mem"].join(`
|
|
365
|
+
`),"Note"),pe(T.default.green("claude-mem has been uninstalled."))}var T,hs=m(()=>{"use strict";mr();T=le(Ee(),1);de();Oe();me();gr()});import{spawnSync as mc}from"child_process";import{existsSync as gc}from"fs";import{homedir as en}from"os";import{join as tn}from"path";function fc(){return te?[tn(en(),".bun","bin","bun.exe"),tn(process.env.USERPROFILE||en(),".bun","bin","bun.exe")]:[tn(en(),".bun","bin","bun"),"/usr/local/bin/bun","/opt/homebrew/bin/bun","/home/linuxbrew/.linuxbrew/bin/bun"]}function Fs(){let e=mc(te?"where":"which",["bun"],{encoding:"utf-8",stdio:["pipe","pipe","pipe"],shell:te});if(e.status===0&&e.stdout.trim())return"bun";for(let r of fc())if(gc(r))return r;return null}var Ss=m(()=>{"use strict";de()});var re={};q(re,{runAdoptCommand:()=>Sc,runCleanupCommand:()=>yc,runRestartCommand:()=>hc,runSearchCommand:()=>wc,runStartCommand:()=>Cc,runStatusCommand:()=>Fc,runStopCommand:()=>Ec,runTranscriptWatchCommand:()=>vc});import{spawn as rn}from"child_process";import{existsSync as nn}from"fs";import{join as ys}from"path";function qt(){gt()||(console.error(A.default.red("claude-mem is not installed.")),console.error(`Run: ${A.default.bold("npx claude-mem install")}`),process.exit(1))}function on(){let t=Fs();return t||(console.error(A.default.red("Bun not found.")),console.error("Install Bun: https://bun.sh"),console.error("After installation, restart your terminal."),process.exit(1)),t}function ws(){return ys($(),"plugin","scripts","worker-service.cjs")}function Te(t,e=[]){qt();let r=on(),o=ws();nn(o)||(console.error(A.default.red(`Worker script not found at: ${o}`)),console.error("The installation may be corrupted. Try: npx claude-mem install"),process.exit(1));let s=[o,t,...e],i=rn(r,s,{stdio:"inherit",cwd:$(),env:process.env});i.on("error",n=>{console.error(A.default.red(`Failed to start Bun: ${n.message}`)),process.exit(1)}),i.on("close",n=>{process.exit(n??0)})}function Cc(){Te("start")}function Ec(){Te("stop")}function hc(){Te("restart")}function Fc(){Te("status")}function Sc(t=[]){qt();let e=on(),r=ws();nn(r)||(console.error(A.default.red(`Worker script not found at: ${r}`)),console.error("The installation may be corrupted. Try: npx claude-mem install"),process.exit(1));let o=process.cwd(),s=[r,"adopt","--cwd",o,...t],i=rn(e,s,{stdio:"inherit",cwd:$(),env:process.env});i.on("error",n=>{console.error(A.default.red(`Failed to start Bun: ${n.message}`)),process.exit(1)}),i.on("close",n=>{process.exit(n??0)})}function yc(t=[]){Te("cleanup",t)}async function wc(t){qt();let e=t.join(" ").trim();e||(console.error(A.default.red("Usage: npx claude-mem search <query>")),process.exit(1));let o=`http://127.0.0.1:${x.get("CLAUDE_MEM_WORKER_PORT")}/api/search?query=${encodeURIComponent(e)}`,s;try{s=await fetch(o)}catch(n){let u=n instanceof Error?n.message:String(n);((n instanceof Error?n.cause:void 0)?.code==="ECONNREFUSED"||u.includes("ECONNREFUSED"))&&(console.error(A.default.red("Worker is not running.")),console.error(`Start it with: ${A.default.bold("npx claude-mem start")}`),process.exit(1)),console.error(A.default.red(`Search failed: ${u}`)),process.exit(1)}s.ok||(s.status===404&&(console.error(A.default.red("Search endpoint not found. Is the worker running?")),console.error(`Try: ${A.default.bold("npx claude-mem start")}`),process.exit(1)),console.error(A.default.red(`Search failed: HTTP ${s.status}`)),process.exit(1));let i;try{i=await s.json()}catch(n){let u=n instanceof Error?n.message:String(n);console.error(A.default.red(`Search failed: invalid JSON response (${u})`)),process.exit(1)}console.log(typeof i=="object"&&i!==null?JSON.stringify(i,null,2):i)}function vc(){qt();let t=on(),e=ys($(),"plugin","scripts","transcript-watcher.cjs");if(!nn(e)){Te("transcript",["watch"]);return}let r=rn(t,[e,"watch"],{stdio:"inherit",cwd:$(),env:process.env});r.on("error",o=>{console.error(A.default.red(`Failed to start transcript watcher: ${o.message}`)),process.exit(1)}),r.on("close",o=>{process.exit(o??0)})}var A,ne=m(()=>{"use strict";A=le(Ee(),1);Ss();de();me()});var S=le(Ee(),1);de();var Ce=process.argv.slice(2),vs=Ce[0]?.toLowerCase()??"";function _c(){let t=Be();console.log(`
|
|
366
|
+
${S.default.bold("claude-mem")} v${t} \u2014 persistent memory for AI coding assistants
|
|
367
|
+
|
|
368
|
+
${S.default.bold("Install Commands")} (no Bun required):
|
|
369
|
+
${S.default.cyan("npx claude-mem")} Interactive install
|
|
370
|
+
${S.default.cyan("npx claude-mem install")} Interactive install
|
|
371
|
+
${S.default.cyan("npx claude-mem install --ide <id>")} Install for specific IDE
|
|
372
|
+
${S.default.cyan("npx claude-mem update")} Update to latest version
|
|
373
|
+
${S.default.cyan("npx claude-mem uninstall")} Remove plugin and configs
|
|
374
|
+
${S.default.cyan("npx claude-mem version")} Print version
|
|
375
|
+
|
|
376
|
+
${S.default.bold("Runtime Commands")} (requires Bun, delegates to installed plugin):
|
|
377
|
+
${S.default.cyan("npx claude-mem start")} Start worker service
|
|
378
|
+
${S.default.cyan("npx claude-mem stop")} Stop worker service
|
|
379
|
+
${S.default.cyan("npx claude-mem restart")} Restart worker service
|
|
380
|
+
${S.default.cyan("npx claude-mem status")} Show worker status
|
|
381
|
+
${S.default.cyan("npx claude-mem search <query>")} Search observations
|
|
382
|
+
${S.default.cyan("npx claude-mem adopt [--dry-run] [--branch <name>]")} Stamp merged worktrees into parent project
|
|
383
|
+
${S.default.cyan("npx claude-mem cleanup [--dry-run]")} Run one-time v12.4.3 pollution cleanup (or preview counts)
|
|
384
|
+
${S.default.cyan("npx claude-mem transcript watch")} Start transcript watcher
|
|
385
|
+
|
|
386
|
+
${S.default.bold("IDE Identifiers")}:
|
|
395
387
|
claude-code, cursor, gemini-cli, opencode, openclaw,
|
|
396
388
|
windsurf, codex-cli, copilot-cli, antigravity, goose,
|
|
397
389
|
crush, roo-code, warp
|
|
398
|
-
`)}async function
|
|
390
|
+
`)}async function xc(){switch(vs){case"":{let{runInstallCommand:t}=await Promise.resolve().then(()=>(zt(),Xt));await t();break}case"install":{let t=Ce.indexOf("--ide"),e=t!==-1?Ce[t+1]:void 0,{runInstallCommand:r}=await Promise.resolve().then(()=>(zt(),Xt));await r({ide:e});break}case"update":case"upgrade":{let{runInstallCommand:t}=await Promise.resolve().then(()=>(zt(),Xt));await t();break}case"uninstall":case"remove":{let{runUninstallCommand:t}=await Promise.resolve().then(()=>(hs(),Es));await t();break}case"version":case"--version":case"-v":{console.log(Be());break}case"help":case"--help":case"-h":{_c();break}case"start":{let{runStartCommand:t}=await Promise.resolve().then(()=>(ne(),re));t();break}case"stop":{let{runStopCommand:t}=await Promise.resolve().then(()=>(ne(),re));t();break}case"restart":{let{runRestartCommand:t}=await Promise.resolve().then(()=>(ne(),re));t();break}case"status":{let{runStatusCommand:t}=await Promise.resolve().then(()=>(ne(),re));t();break}case"search":{let{runSearchCommand:t}=await Promise.resolve().then(()=>(ne(),re));await t(Ce.slice(1));break}case"adopt":{let{runAdoptCommand:t}=await Promise.resolve().then(()=>(ne(),re));t(Ce.slice(1));break}case"cleanup":{let{runCleanupCommand:t}=await Promise.resolve().then(()=>(ne(),re));t(Ce.slice(1));break}case"transcript":{let t=Ce[1]?.toLowerCase();if(t==="watch"){let{runTranscriptWatchCommand:e}=await Promise.resolve().then(()=>(ne(),re));e()}else console.error(S.default.red(`Unknown transcript subcommand: ${t??"(none)"}`)),console.error("Usage: npx claude-mem transcript watch"),process.exit(1);break}default:console.error(S.default.red(`Unknown command: ${vs}`)),console.error(`Run ${S.default.bold("npx claude-mem --help")} for usage information.`),process.exit(1)}}xc().catch(t=>{console.error(S.default.red("Fatal error:"),t.message||t),process.exit(1)});
|