claude-mem 12.4.2 → 12.4.3
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 +181 -189
- 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/context-generator.cjs +1 -1
- package/plugin/scripts/mcp-server.cjs +37 -37
- package/plugin/scripts/worker-service.cjs +429 -436
- 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(o);this.output.write(
|
|
16
|
-
`)),this._prevFrame=e;return}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
${
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
${
|
|
24
|
-
|
|
25
|
-
|
|
2
|
+
var ys=Object.create;var Jt=Object.defineProperty;var ws=Object.getOwnPropertyDescriptor;var vs=Object.getOwnPropertyNames;var _s=Object.getPrototypeOf,xs=Object.prototype.hasOwnProperty;var ks=(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 Qr=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Y=(t,e)=>{for(var r in e)Jt(t,r,{get:e[r],enumerable:!0})},As=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of vs(e))!xs.call(t,s)&&s!==r&&Jt(t,s,{get:()=>e[s],enumerable:!(o=ws(e,s))||o.enumerable});return t};var ie=(t,e,r)=>(r=t!=null?ys(_s(t)):{},As(e||!t||!t.__esModule?Jt(r,"default",{value:t,enumerable:!0}):r,t));var de=Qr((hc,Yt)=>{var at=process||{},en=at.argv||[],ut=at.env||{},bs=!(ut.NO_COLOR||en.includes("--no-color"))&&(!!ut.FORCE_COLOR||en.includes("--color")||at.platform==="win32"||(at.stdout||{}).isTTY&&ut.TERM!=="dumb"||!!ut.CI),Ms=(t,e,r=t)=>o=>{let s=""+o,i=s.indexOf(e,t.length);return~i?t+Is(s,e,r,i)+e:t+s+e},Is=(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)},tn=(t=bs)=>{let e=t?Ms:()=>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")}};Yt.exports=tn();Yt.exports.createColors=tn});import{existsSync as $s,readFileSync as Ts}from"fs";function G(t,e){if(!$s(t))return e;try{return JSON.parse(Ts(t,"utf-8"))}catch(r){throw new Error(`Corrupt JSON file, refusing to overwrite: ${t}: ${r instanceof Error?r.message:String(r)}`)}}var Ie=m(()=>{"use strict"});import{existsSync as $e,mkdirSync as Rs,readFileSync as rn,writeFileSync as Ps}from"fs";import{homedir as Os}from"os";import{dirname as nn,join as P}from"path";import{fileURLToPath as Ls}from"url";function Vt(){return process.env.CLAUDE_CONFIG_DIR||P(Os(),".claude")}function b(){return P(Vt(),"plugins","marketplaces","thedotmack")}function ue(){return P(Vt(),"plugins")}function pe(){return P(ue(),"known_marketplaces.json")}function me(){return P(ue(),"installed_plugins.json")}function ge(){return P(Vt(),"settings.json")}function Xt(t){return P(ue(),"cache","thedotmack","claude-mem",t)}function ct(){let t=Ls(import.meta.url),e=P(nn(t),"..","..");if(!$e(P(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 zt(){return P(ct(),"plugin")}function Te(){let t=P(zt(),".claude-plugin","plugin.json");if($e(t))try{let r=JSON.parse(rn(t,"utf-8"));if(r.version)return r.version}catch{}let e=P(ct(),"package.json");if($e(e))try{let r=JSON.parse(rn(e,"utf-8"));if(r.version)return r.version}catch{}return"0.0.0"}function lt(){let t=b();return $e(P(t,"plugin",".claude-plugin","plugin.json"))}function Re(t){$e(t)||Rs(t,{recursive:!0})}function Z(t,e){Re(nn(t)),Ps(t,JSON.stringify(e,null,2)+`
|
|
3
|
+
`,"utf-8")}var z,ae=m(()=>{"use strict";Ie();z=process.platform==="win32"});var Zt=Qr((Ac,on)=>{"use strict";var qt={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"},Bs={up:(t=1)=>"\x1B[S".repeat(t),down:(t=1)=>"\x1B[T".repeat(t)},Ns={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?qt.up():"");return t&&(e+=qt.left),e}};on.exports={cursor:qt,scroll:Bs,erase:Ns,beep:"\x07"}});import{stdin as mn,stdout as gn}from"node:process";import*as Q from"node:readline";import sn from"node:readline";import{WriteStream as js}from"node:tty";function Us({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 fn(t){if(typeof t!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(Gs,"")}function Cn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Pe(t,e={}){if(typeof t!="string"||t.length===0||(e={ambiguousIsNarrow:!0,...e},t=fn(t),t.length===0))return 0;t=t.replace(Js()," ");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(Hs.eastAsianWidth(s)){case"F":case"W":o+=2;break;case"A":o+=r;break;default:o+=1}}return o}function Xs(){let t=new Map;for(let[e,r]of Object.entries(C)){for(let[o,s]of Object.entries(r))C[o]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},r[o]=C[o],t.set(s[0],s[1]);Object.defineProperty(C,e,{value:r,enumerable:!1})}return Object.defineProperty(C,"codes",{value:t,enumerable:!1}),C.color.close="\x1B[39m",C.bgColor.close="\x1B[49m",C.color.ansi=un(),C.color.ansi256=an(),C.color.ansi16m=cn(),C.bgColor.ansi=un(Qt),C.bgColor.ansi256=an(Qt),C.bgColor.ansi16m=cn(Qt),Object.defineProperties(C,{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=>C.rgbToAnsi256(...C.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)=>C.ansi256ToAnsi(C.rgbToAnsi256(e,r,o)),enumerable:!1},hexToAnsi:{value:e=>C.ansi256ToAnsi(C.hexToAnsi256(e)),enumerable:!1}}),C}function dn(t,e,r){return String(t).normalize().replace(/\r\n/g,`
|
|
4
|
+
`).split(`
|
|
5
|
+
`).map(o=>ti(o,e,r)).join(`
|
|
6
|
+
`)}function or(t,e){if(typeof t=="string")return dt.aliases.get(t)===e;for(let r of t)if(r!==void 0&&or(r,e))return!0;return!1}function ni(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 ee(t){return t===tr}function Dt(t,e){let r=t;r.isTTY&&r.setRawMode(e)}function Sn({input:t=mn,output:e=gn,overwrite:r=!0,hideCursor:o=!0}={}){let s=Q.createInterface({input:t,output:e,prompt:"",tabSize:1});Q.emitKeypressEvents(t,s),t.isTTY&&t.setRawMode(!0);let i=(n,{name:u,sequence:c})=>{let d=String(n);if(or([d,u,c],"cancel")){o&&e.write(k.cursor.show),process.exit(0);return}if(!r)return;Q.moveCursor(e,u==="return"?0:-1,u==="return"?-1:0,()=>{Q.clearLine(e,1,()=>{t.once("keypress",i)})})};return o&&e.write(k.cursor.hide),t.once("keypress",i),()=>{t.off("keypress",i),o&&e.write(k.cursor.show),t.isTTY&&!oi&&t.setRawMode(!1),s.terminal=!1,s.close()}}var k,Gs,En,Ws,Hs,Ks,Js,Qt,un,an,cn,C,Ys,Vs,zs,gt,qs,rr,hn,Zs,Fn,nr,ln,Dn,Qs,er,ei,ti,ri,dt,oi,tr,si,ii,O,pt,mt,ui,ai,pn,yn,sr=m(()=>{k=ie(Zt(),1);Gs=Us();En={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 p=c[d],D=e.length(p);if(u>=s-(D==2?1:0))if(u+D<=i)n+=p;else break;u+=D}return n}})(En);Ws=En.exports,Hs=Cn(Ws),Ks=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},Js=Cn(Ks);Qt=10,un=(t=0)=>e=>`\x1B[${e+t}m`,an=(t=0)=>e=>`\x1B[${38+t};5;${e}m`,cn=(t=0)=>(e,r,o)=>`\x1B[${38+t};2;${e};${r};${o}m`,C={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(C.modifier);Ys=Object.keys(C.color),Vs=Object.keys(C.bgColor);[...Ys,...Vs];zs=Xs(),gt=new Set(["\x1B","\x9B"]),qs=39,rr="\x07",hn="[",Zs="]",Fn="m",nr=`${Zs}8;;`,ln=t=>`${gt.values().next().value}${hn}${t}${Fn}`,Dn=t=>`${gt.values().next().value}${nr}${t}${rr}`,Qs=t=>t.split(" ").map(e=>Pe(e)),er=(t,e,r)=>{let o=[...e],s=!1,i=!1,n=Pe(fn(t[t.length-1]));for(let[u,c]of o.entries()){let d=Pe(c);if(n+d<=r?t[t.length-1]+=c:(t.push(c),n=0),gt.has(c)&&(s=!0,i=o.slice(u+1).join("").startsWith(nr)),s){i?c===rr&&(s=!1,i=!1):c===Fn&&(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())},ei=t=>{let e=t.split(" "),r=e.length;for(;r>0&&!(Pe(e[r-1])>0);)r--;return r===e.length?t:e.slice(0,r).join(" ")+e.slice(r).join("")},ti=(t,e,r={})=>{if(r.trim!==!1&&t.trim()==="")return"";let o="",s,i,n=Qs(t),u=[""];for(let[d,p]of t.split(" ").entries()){r.trim!==!1&&(u[u.length-1]=u[u.length-1].trimStart());let D=Pe(u[u.length-1]);if(d!==0&&(D>=e&&(r.wordWrap===!1||r.trim===!1)&&(u.push(""),D=0),(D>0||r.trim===!1)&&(u[u.length-1]+=" ",D++)),r.hard&&n[d]>e){let E=e-D,v=1+Math.floor((n[d]-E-1)/e);Math.floor((n[d]-1)/e)<v&&u.push(""),er(u,p,e);continue}if(D+n[d]>e&&D>0&&n[d]>0){if(r.wordWrap===!1&&D<e){er(u,p,e);continue}u.push("")}if(D+n[d]>e&&r.wordWrap===!1){er(u,p,e);continue}u[u.length-1]+=p}r.trim!==!1&&(u=u.map(d=>ei(d)));let c=[...u.join(`
|
|
9
|
+
`)];for(let[d,p]of c.entries()){if(o+=p,gt.has(p)){let{groups:E}=new RegExp(`(?:\\${hn}(?<code>\\d+)m|\\${nr}(?<uri>.*)${rr})`).exec(c.slice(d).join(""))||{groups:{}};if(E.code!==void 0){let v=Number.parseFloat(E.code);s=v===qs?void 0:v}else E.uri!==void 0&&(i=E.uri.length===0?void 0:E.uri)}let D=zs.codes.get(Number(s));c[d+1]===`
|
|
10
|
+
`?(i&&(o+=Dn("")),s&&D&&(o+=ln(D))):p===`
|
|
11
|
+
`&&(s&&D&&(o+=ln(s)),i&&(o+=Dn(i)))}return o};ri=["up","down","left","right","space","enter","cancel"],dt={actions:new Set(ri),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]])};oi=globalThis.process.platform.startsWith("win"),tr=Symbol("clack:cancel");si=Object.defineProperty,ii=(t,e,r)=>e in t?si(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,O=(t,e,r)=>(ii(t,typeof e!="symbol"?e+"":e,r),r),pt=class{constructor(e,r=!0){O(this,"input"),O(this,"output"),O(this,"_abortSignal"),O(this,"rl"),O(this,"opts"),O(this,"_render"),O(this,"_track",!1),O(this,"_prevFrame",""),O(this,"_subscribers",new Map),O(this,"_cursor",0),O(this,"state","initial"),O(this,"error",""),O(this,"value");let{input:o=mn,output:s=gn,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(tr);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}let o=new js(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=sn.createInterface({input:this.input,output:o,tabSize:2,prompt:"",escapeCodeTimeout:50}),sn.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),Dt(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(k.cursor.show),this.output.off("resize",this.render),Dt(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(k.cursor.show),this.output.off("resize",this.render),Dt(this.input,!1),e(tr)})})}onKeypress(e,r){if(this.state==="error"&&(this.state="active"),r?.name&&(!this._track&&dt.aliases.has(r.name)&&this.emit("cursor",dt.aliases.get(r.name)),dt.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")}or([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
|
+
`),Dt(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=dn(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
|
|
13
|
+
`).length-1;this.output.write(k.cursor.move(-999,e*-1))}render(){let e=dn(this._render(this)??"",process.stdout.columns,{hard:!0});if(e!==this._prevFrame){if(this.state==="initial")this.output.write(k.cursor.hide);else{let r=ni(this._prevFrame,e);if(this.restoreCursor(),r&&r?.length===1){let o=r[0];this.output.write(k.cursor.move(0,o)),this.output.write(k.erase.lines(1));let s=e.split(`
|
|
14
|
+
`);this.output.write(s[o]),this._prevFrame=e,this.output.write(k.cursor.move(0,s.length-o-1));return}if(r&&r?.length>1){let o=r[0];this.output.write(k.cursor.move(0,o)),this.output.write(k.erase.down());let s=e.split(`
|
|
15
|
+
`).slice(o);this.output.write(s.join(`
|
|
16
|
+
`)),this._prevFrame=e;return}this.output.write(k.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}},mt=class extends pt{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(k.cursor.move(0,-1)),this.value=r,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}},ui=Object.defineProperty,ai=(t,e,r)=>e in t?ui(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,pn=(t,e,r)=>(ai(t,typeof e!="symbol"?e+"":e,r),r),yn=class extends pt{constructor(t){super(t,!1),pn(this,"options"),pn(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 ir}from"node:util";import W from"node:process";function ci(){return W.platform!=="win32"?W.env.TERM!=="linux":!!W.env.CI||!!W.env.WT_SESSION||!!W.env.TERMINUS_SUBLIME||W.env.ConEmuTask==="{cmd::Cmder}"||W.env.TERM_PROGRAM==="Terminus-Sublime"||W.env.TERM_PROGRAM==="vscode"||W.env.TERM==="xterm-256color"||W.env.TERM==="alacritty"||W.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var l,ft,ur,y,li,An,bn,Ct,Di,S,Oe,wn,vn,di,_n,pi,Wc,xn,mi,gi,fi,Ci,Ei,hi,Fi,Mn,kn,Le,In,Be,Ne,Et,ce,M,Si,ht,ar=m(()=>{sr();sr();l=ie(de(),1),ft=ie(Zt(),1);ur=ci(),y=(t,e)=>ur?t:e,li=y("\u25C6","*"),An=y("\u25A0","x"),bn=y("\u25B2","x"),Ct=y("\u25C7","o"),Di=y("\u250C","T"),S=y("\u2502","|"),Oe=y("\u2514","\u2014"),wn=y("\u25CF",">"),vn=y("\u25CB"," "),di=y("\u25FB","[\u2022]"),_n=y("\u25FC","[+]"),pi=y("\u25FB","[ ]"),Wc=y("\u25AA","\u2022"),xn=y("\u2500","-"),mi=y("\u256E","+"),gi=y("\u251C","+"),fi=y("\u256F","+"),Ci=y("\u25CF","\u2022"),Ei=y("\u25C6","*"),hi=y("\u25B2","!"),Fi=y("\u25A0","x"),Mn=t=>{switch(t){case"initial":case"active":return l.default.cyan(li);case"cancel":return l.default.red(An);case"error":return l.default.yellow(bn);case"submit":return l.default.green(Ct)}},kn=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((p,D,E)=>{let v=D===0&&c,De=D===E.length-1&&d;return v||De?l.default.dim("..."):o(p,D+u===e)})},Le=t=>{let e=t.active??"Yes",r=t.inactive??"No";return new mt({active:e,inactive:r,initialValue:t.initialValue??!0,render(){let o=`${l.default.gray(S)}
|
|
17
|
+
${Mn(this.state)} ${t.message}
|
|
18
|
+
`,s=this.value?e:r;switch(this.state){case"submit":return`${o}${l.default.gray(S)} ${l.default.dim(s)}`;case"cancel":return`${o}${l.default.gray(S)} ${l.default.strikethrough(l.default.dim(s))}
|
|
19
|
+
${l.default.gray(S)}`;default:return`${o}${l.default.cyan(S)} ${this.value?`${l.default.green(wn)} ${e}`:`${l.default.dim(vn)} ${l.default.dim(e)}`} ${l.default.dim("/")} ${this.value?`${l.default.dim(vn)} ${l.default.dim(r)}`:`${l.default.green(wn)} ${r}`}
|
|
20
|
+
${l.default.cyan(Oe)}
|
|
21
|
+
`}}}).prompt()},In=t=>{let e=(r,o)=>{let s=r.label??String(r.value);return o==="active"?`${l.default.cyan(di)} ${s} ${r.hint?l.default.dim(`(${r.hint})`):""}`:o==="selected"?`${l.default.green(_n)} ${l.default.dim(s)}`:o==="cancelled"?`${l.default.strikethrough(l.default.dim(s))}`:o==="active-selected"?`${l.default.green(_n)} ${s} ${r.hint?l.default.dim(`(${r.hint})`):""}`:o==="submitted"?`${l.default.dim(s)}`:`${l.default.dim(pi)} ${l.default.dim(s)}`};return new yn({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(S)}
|
|
23
|
+
${Mn(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(S)} ${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(S)} ${s.trim()?`${s}
|
|
25
|
+
${l.default.gray(S)}`:""}`}case"error":{let s=this.error.split(`
|
|
26
|
+
`).map((i,n)=>n===0?`${l.default.yellow(Oe)} ${l.default.yellow(i)}`:` ${i}`).join(`
|
|
27
|
+
`);return`${r+l.default.yellow(S)} ${kn({options:this.options,cursor:this.cursor,maxItems:t.maxItems,style:o}).join(`
|
|
28
|
+
${l.default.yellow(S)} `)}
|
|
29
|
+
${s}
|
|
30
|
+
`}default:return`${r}${l.default.cyan(S)} ${kn({options:this.options,cursor:this.cursor,maxItems:t.maxItems,style:o}).join(`
|
|
31
|
+
${l.default.cyan(S)} `)}
|
|
32
|
+
${l.default.cyan(Oe)}
|
|
33
|
+
`}}}).prompt()},Be=(t="",e="")=>{let r=`
|
|
34
|
+
${t}
|
|
35
|
+
`.split(`
|
|
36
|
+
`),o=ir(e).length,s=Math.max(r.reduce((n,u)=>{let c=ir(u);return c.length>n?c.length:n},0),o)+2,i=r.map(n=>`${l.default.gray(S)} ${l.default.dim(n)}${" ".repeat(s-ir(n).length)}${l.default.gray(S)}`).join(`
|
|
37
|
+
`);process.stdout.write(`${l.default.gray(S)}
|
|
38
|
+
${l.default.green(Ct)} ${l.default.reset(e)} ${l.default.gray(xn.repeat(Math.max(s-o-1,1))+mi)}
|
|
39
|
+
${i}
|
|
40
|
+
${l.default.gray(gi+xn.repeat(s+2)+fi)}
|
|
41
|
+
`)},Ne=(t="")=>{process.stdout.write(`${l.default.gray(Oe)} ${l.default.red(t)}
|
|
42
|
+
|
|
43
|
+
`)},Et=(t="")=>{process.stdout.write(`${l.default.gray(Di)} ${t}
|
|
44
|
+
`)},ce=(t="")=>{process.stdout.write(`${l.default.gray(S)}
|
|
45
|
+
${l.default.gray(Oe)} ${t}
|
|
46
|
+
|
|
47
|
+
`)},M={message:(t="",{symbol:e=l.default.gray(S)}={})=>{let r=[`${l.default.gray(S)}`];if(t){let[o,...s]=t.split(`
|
|
48
|
+
`);r.push(`${e} ${o}`,...s.map(i=>`${l.default.gray(S)} ${i}`))}process.stdout.write(`${r.join(`
|
|
26
49
|
`)}
|
|
27
|
-
`)},info:
|
|
28
|
-
|
|
29
|
-
`)},
|
|
30
|
-
`)
|
|
31
|
-
${
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
${u("gray",$)}`:""}`}case"error":{let c=n?`${u("yellow",$)} `:"",p=this.error.split(`
|
|
40
|
-
`).map((g,E)=>E===0?`${n?`${u("yellow",et)} `:""}${u("yellow",g)}`:` ${g}`).join(`
|
|
41
|
-
`),m=o.split(`
|
|
42
|
-
`).length,d=p.split(`
|
|
43
|
-
`).length+1;return`${o}${c}${Qn({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:c.length,rowPadding:m+d,style:a}).join(`
|
|
44
|
-
${c}`)}
|
|
45
|
-
${p}
|
|
46
|
-
`}default:{let c=n?`${u("cyan",$)} `:"",p=o.split(`
|
|
47
|
-
`).length,m=n?2:1;return`${o}${c}${Qn({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:c.length,rowPadding:p+m,style:a}).join(`
|
|
48
|
-
${c}`)}
|
|
49
|
-
${n?u("cyan",et):""}
|
|
50
|
-
`}}}}).prompt()},Wi=e=>u("dim",e),Hi=(e,t,r)=>{let n={hard:!0,trim:!1},s=oe(e,t,n).split(`
|
|
51
|
-
`),o=s.reduce((c,p)=>Math.max(W(p),c),0),i=s.map(r).reduce((c,p)=>Math.max(W(p),c),0),a=t-(i-o);return oe(e,a,n)},nt=(e="",t="",r)=>{let n=r?.output??q.stdout,s=r?.withGuide??U.withGuide,o=r?.format??Wi,i=["",...Hi(e,qe(n)-6,o).split(`
|
|
52
|
-
`).map(o),""],a=W(t),c=Math.max(i.reduce((g,E)=>{let f=W(E);return f>g?f:g},0),a)+2,p=i.map(g=>`${u("gray",$)} ${g}${" ".repeat(c-W(g))}${u("gray",$)}`).join(`
|
|
53
|
-
`),m=s?`${u("gray",$)}
|
|
54
|
-
`:"",d=s?Di:Pi;n.write(`${m}${u("green",Lt)} ${u("reset",t)} ${u("gray",Zn.repeat(Math.max(c-a-1,1))+Ri)}
|
|
55
|
-
${p}
|
|
56
|
-
${u("gray",d+Zn.repeat(c+2)+Oi)}
|
|
57
|
-
`)},Bi=e=>u("magenta",e),Ki=({indicator:e="dots",onCancel:t,output:r=process.stdout,cancelMessage:n,errorMessage:s,frames:o=Ar?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:i=Ar?80:120,signal:a,...c}={})=>{let p=Mi(),m,d,g=!1,E=!1,f="",h,T=performance.now(),D=qe(r),P=c?.styleFrame??Bi,I=k=>{let X=k>1?s??U.messages.error:n??U.messages.cancel;E=k===1,g&&(Be(X,k),E&&typeof t=="function"&&t())},R=()=>I(2),w=()=>I(1),A=()=>{process.on("uncaughtExceptionMonitor",R),process.on("unhandledRejection",R),process.on("SIGINT",w),process.on("SIGTERM",w),process.on("exit",I),a&&a.addEventListener("abort",w)},C=()=>{process.removeListener("uncaughtExceptionMonitor",R),process.removeListener("unhandledRejection",R),process.removeListener("SIGINT",w),process.removeListener("SIGTERM",w),process.removeListener("exit",I),a&&a.removeEventListener("abort",w)},x=()=>{if(h===void 0)return;p&&r.write(`
|
|
58
|
-
`);let k=oe(h,D,{hard:!0,trim:!1}).split(`
|
|
59
|
-
`);k.length>1&&r.write(Qe.cursor.up(k.length-1)),r.write(Qe.cursor.to(0)),r.write(Qe.erase.down())},ce=k=>k.replace(/\.+$/,""),ye=k=>{let X=(performance.now()-k)/1e3,le=Math.floor(X/60),ue=Math.floor(X%60);return le>0?`[${le}m ${ue}s]`:`[${ue}s]`},we=c.withGuide??U.withGuide,Vo=(k="")=>{g=!0,m=Kn({output:r}),f=ce(k),T=performance.now(),we&&r.write(`${u("gray",$)}
|
|
60
|
-
`);let X=0,le=0;A(),d=setInterval(()=>{if(p&&f===h)return;x(),h=f;let ue=P(o[X]),$t;if(p)$t=`${ue} ${f}...`;else if(e==="timer")$t=`${ue} ${f} ${ye(T)}`;else{let Yo=".".repeat(Math.floor(le)).slice(0,3);$t=`${ue} ${f}${Yo}`}let Jo=oe($t,D,{hard:!0,trim:!1});r.write(Jo),X=X+1<o.length?X+1:0,le=le<4?le+.125:0},i)},Be=(k="",X=0,le=!1)=>{if(!g)return;g=!1,clearInterval(d),x();let ue=X===0?u("green",Lt):X===1?u("red",es):u("red",ts);f=k??f,le||(e==="timer"?r.write(`${ue} ${f} ${ye(T)}
|
|
61
|
-
`):r.write(`${ue} ${f}
|
|
62
|
-
`)),C(),m()};return{start:Vo,stop:(k="")=>Be(k,0),message:(k="")=>{f=ce(k??f)},cancel:(k="")=>Be(k,1),error:(k="")=>Be(k,2),clear:()=>Be("",0,!0),get isCancelled(){return E}}},Au={light:v("\u2500","-"),heavy:v("\u2501","="),block:v("\u2588","#")},Ru=`${u("gray",$)} `,Ut=async(e,t)=>{for(let r of e){if(r.enabled===!1)continue;let n=Ki(t);n.start(r.title);let s=await r.task(n.message);n.stop(s||r.title)}}});import{execSync as Vi}from"child_process";import{existsSync as te,readdirSync as Ji}from"fs";import{homedir as os}from"os";import{join as re}from"path";function st(e){try{return Vi(`${de?"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 Yi(e){let t=re(os(),".vscode","extensions");if(!te(t))return!1;try{return Ji(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 ot(){let e=os();return[{id:"claude-code",label:"Claude Code",detected:te(re(e,".claude")),supported:!0,hint:"recommended"},{id:"gemini-cli",label:"Gemini CLI",detected:te(re(e,".gemini")),supported:!0},{id:"opencode",label:"OpenCode",detected:te(re(e,".config","opencode"))||st("opencode"),supported:!0,hint:"plugin-based integration"},{id:"openclaw",label:"OpenClaw",detected:te(re(e,".openclaw")),supported:!0,hint:"plugin-based integration"},{id:"windsurf",label:"Windsurf",detected:te(re(e,".codeium","windsurf")),supported:!0},{id:"codex-cli",label:"Codex CLI",detected:te(re(e,".codex")),supported:!0,hint:"transcript-based integration"},{id:"cursor",label:"Cursor",detected:te(re(e,".cursor")),supported:!0,hint:"hooks + MCP integration"},{id:"copilot-cli",label:"Copilot CLI",detected:st("copilot"),supported:!0,hint:"MCP-based integration"},{id:"antigravity",label:"Antigravity",detected:te(re(e,".gemini","antigravity")),supported:!0,hint:"MCP-based integration"},{id:"goose",label:"Goose",detected:te(re(e,".config","goose"))||st("goose"),supported:!0,hint:"MCP-based integration"},{id:"crush",label:"Crush",detected:st("crush"),supported:!0,hint:"MCP-based integration"},{id:"roo-code",label:"Roo Code",detected:Yi("roo-code"),supported:!0,hint:"MCP-based integration"},{id:"warp",label:"Warp",detected:te(re(e,".warp"))||st("warp"),supported:!0,hint:"MCP-based integration"}]}var is=S(()=>{"use strict";_e()});import{appendFileSync as Xi,existsSync as as,mkdirSync as qi,readFileSync as zi}from"fs";import{join as jt}from"path";import{homedir as Zi}from"os";var Dr,cs,Or,l,K=S(()=>{"use strict";Dr=(o=>(o[o.DEBUG=0]="DEBUG",o[o.INFO=1]="INFO",o[o.WARN=2]="WARN",o[o.ERROR=3]="ERROR",o[o.SILENT=4]="SILENT",o))(Dr||{}),cs=jt(Zi(),".claude-mem"),Or=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=jt(cs,"logs");as(t)||qi(t,{recursive:!0});let r=new Date().toISOString().split("T")[0];this.logFilePath=jt(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=jt(cs,"settings.json");if(as(t)){let r=zi(t,"utf-8"),s=(JSON.parse(r).CLAUDE_MEM_LOG_LEVEL||"INFO").toUpperCase();this.level=Dr[s]??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"),s=String(t.getDate()).padStart(2,"0"),o=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}-${s} ${o}:${i}:${a}.${c}`}log(t,r,n,s,o){if(t<this.getLevel())return;this.ensureLogFileInitialized();let i=this.formatTimestamp(new Date),a=Dr[t].padEnd(5),c=r.padEnd(6),p="";s?.correlationId?p=`[${s.correlationId}] `:s?.sessionId&&(p=`[session-${s.sessionId}] `);let m="";o!=null&&(o instanceof Error?m=this.getLevel()===0?`
|
|
64
|
-
${o.message}
|
|
65
|
-
${o.stack}`:` ${o.message}`:this.getLevel()===0&&typeof o=="object"?m=`
|
|
66
|
-
`+JSON.stringify(o,null,2):m=" "+this.formatData(o));let d="";if(s){let{sessionId:E,memorySessionId:f,correlationId:h,...T}=s;Object.keys(T).length>0&&(d=` {${Object.entries(T).map(([P,I])=>`${P}=${I}`).join(", ")}}`)}let g=`[${i}] [${a}] [${c}] ${p}${n}${d}${m}`;if(this.logFilePath)try{Xi(this.logFilePath,g+`
|
|
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(g+`
|
|
69
|
-
`)}debug(t,r,n,s){this.log(0,t,r,n,s)}info(t,r,n,s){this.log(1,t,r,n,s)}warn(t,r,n,s){this.log(2,t,r,n,s)}error(t,r,n,s){this.log(3,t,r,n,s)}dataIn(t,r,n,s){this.info(t,`\u2192 ${r}`,n,s)}dataOut(t,r,n,s){this.info(t,`\u2190 ${r}`,n,s)}success(t,r,n,s){this.info(t,`\u2713 ${r}`,n,s)}failure(t,r,n,s){this.error(t,`\u2717 ${r}`,n,s)}timing(t,r,n,s){this.info(t,`\u23F1 ${r}`,s,{duration:`${n}ms`})}happyPathError(t,r,n,s,o=""){let p=((new Error().stack||"").split(`
|
|
70
|
-
`)[2]||"").match(/at\s+(?:.*\s+)?\(?([^:]+):(\d+):(\d+)\)?/),m=p?`${p[1].split("/").pop()}:${p[2]}`:"unknown",d={...n,location:m};return this.warn(t,`[HAPPY-PATH] ${r}`,d,s),o}},l=new Or});function ls(e){return process.platform==="win32"?Math.round(e*it.WINDOWS_MULTIPLIER):e}var it,Pr=S(()=>{"use strict";it={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{readFileSync as Qi,writeFileSync as us,existsSync as ds,mkdirSync as ea}from"fs";import{join as ps,dirname as ta}from"path";import{homedir as ms}from"os";var fe,Fr=S(()=>{"use strict";fe=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:ps(ms(),".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:ps(ms(),".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(!ds(t)){let i=this.getAllDefaults();try{let a=ta(t);ds(a)||ea(a,{recursive:!0}),us(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),s=n;if(n.env&&typeof n.env=="object"){s=n.env;try{us(t,JSON.stringify(s,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 o={...this.DEFAULTS};for(let i of Object.keys(this.DEFAULTS))s[i]!==void 0&&(o[i]=s[i]);return this.applyEnvOverrides(o)}catch(r){return console.warn("[SETTINGS] Failed to load settings, using defaults:",t,r instanceof Error?r.message:String(r)),this.applyEnvOverrides(this.getAllDefaults())}}}});import{join as j,dirname as ra,basename as na}from"path";import{homedir as gs}from"os";import{existsSync as sa,mkdirSync as Qu}from"fs";import{execSync as td}from"child_process";import{fileURLToPath as oa}from"url";function ia(){return typeof __dirname<"u"?__dirname:ra(oa(import.meta.url))}function aa(){if(process.env.CLAUDE_MEM_DATA_DIR)return process.env.CLAUDE_MEM_DATA_DIR;let e=j(gs(),".claude-mem"),t=j(e,"settings.json");try{if(sa(t)){let{readFileSync:r}=ei("fs"),n=JSON.parse(r(t,"utf-8")),s=n.env??n;if(s.CLAUDE_MEM_DATA_DIR)return s.CLAUDE_MEM_DATA_DIR}}catch{}return e}var sd,V,Te,Gt,od,id,ad,cd,ld,ca,ud,dd,la,pd,md,gd,fd,at=S(()=>{"use strict";K();sd=ia();V=aa(),Te=process.env.CLAUDE_CONFIG_DIR||j(gs(),".claude"),Gt=j(Te,"plugins","marketplaces","thedotmack"),od=j(V,"archives"),id=j(V,"logs"),ad=j(V,"trash"),cd=j(V,"backups"),ld=j(V,"modes"),ca=j(V,"settings.json"),ud=j(V,"claude-mem.db"),dd=j(V,"vector-db"),la=j(V,"observer-sessions"),pd=na(la),md=j(Te,"settings.json"),gd=j(Te,"commands"),fd=j(Te,"CLAUDE.md")});var fs=S(()=>{"use strict";Fr();at()});var hs=S(()=>{"use strict"});import{spawn as xd,spawnSync as ua}from"child_process";import{existsSync as da,mkdirSync as Es,readFileSync as Ss,writeFileSync as pa}from"fs";import{homedir as ma}from"os";import Wt from"path";function ie(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 Sa(e){if(!Number.isInteger(e)||e<=0)return null;if(process.platform==="linux")try{let t=Ss(`/proc/${e}/stat`,"utf-8"),r=t.lastIndexOf(") ");if(r<0)return null;let s=t.slice(r+2).split(" ")[19];return s&&/^\d+$/.test(s)?s: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=ua("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 Cs(e){if(!e||!ie(e.pid))return!1;if(!e.startToken)return!0;let t=Sa(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 Ht(){return Lr||(Lr=new Nr),Lr}var ga,fa,ha,Ea,Nr,Lr,Bt=S(()=>{"use strict";K();hs();ga=5e3,fa=1e3,ha=Wt.join(ma(),".claude-mem"),Ea=Wt.join(ha,"supervisor.json");Nr=class{registryPath;entries=new Map;runtimeProcesses=new Map;initialized=!1;constructor(t=Ea){this.registryPath=t}initialize(){if(this.initialized)return;if(this.initialized=!0,Es(Wt.dirname(this.registryPath),{recursive:!0}),!da(this.registryPath)){this.persist();return}try{let n=JSON.parse(Ss(this.registryPath,"utf-8")).processes??{};for(let[s,o]of Object.entries(n))this.entries.set(s,o)}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),s=Date.parse(r.startedAt);return(Number.isNaN(n)?0:n)-(Number.isNaN(s)?0:s)})}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)ie(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 s=r.filter(a=>ie(a.pid));for(let a of s)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 o=Date.now()+ga;for(;Date.now()<o&&s.filter(c=>ie(c.pid)).length!==0;)await new Promise(c=>setTimeout(c,100));let i=s.filter(a=>ie(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()+fa;for(;Date.now()<a&&i.filter(p=>ie(p.pid)).length!==0;)await new Promise(p=>setTimeout(p,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())};Es(Wt.dirname(this.registryPath),{recursive:!0}),pa(this.registryPath,JSON.stringify(t,null,2))}},Lr=null});import{execFile as Ca}from"child_process";import{rmSync as ya}from"fs";import{homedir as wa}from"os";import vs from"path";import{promisify as va}from"util";async function _s(e){let t=e.currentPid??process.pid,r=e.pidFilePath??$a,n=e.registry.getAll(),s=[...n].filter(i=>i.pid!==t).sort((i,a)=>Date.parse(a.startedAt)-Date.parse(i.startedAt));for(let i of s){if(!ie(i.pid)){e.registry.unregister(i.id);continue}try{await ws(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 ys(s,5e3);let o=s.filter(i=>ie(i.pid));for(let i of o)try{await ws(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 ys(o,1e3);for(let i of s)e.registry.unregister(i.id);for(let i of n.filter(a=>a.pid===t))e.registry.unregister(i.id);try{ya(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 ys(e,t){let r=Date.now()+t;for(;Date.now()<r;){if(e.filter(s=>ie(s.pid)).length===0)return;await new Promise(s=>setTimeout(s,100))}}async function ws(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 s=await Ia();if(s){await new Promise((i,a)=>{s(r,t,c=>{if(!c){i();return}if(c.code==="ESRCH"){i();return}a(c)})});return}let o=["/PID",String(r),"/T"];t==="SIGKILL"&&o.push("/F"),await _a("taskkill",o,{timeout:it.POWERSHELL_COMMAND,windowsHide:!0})}async function Ia(){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 _a,xa,$a,xs=S(()=>{"use strict";K();Pr();Bt();_a=va(Ca),xa=vs.join(wa(),".claude-mem"),$a=vs.join(xa,"worker.pid")});function ka(){let t=Ht().pruneDeadEntries();t>0&&l.info("SYSTEM",`Health check: pruned ${t} dead process(es) from registry`)}function Is(){Ae===null&&(Ae=setInterval(ka,$s),Ae.unref(),l.debug("SYSTEM","Health checker started",{intervalMs:$s}))}function ks(){Ae!==null&&(clearInterval(Ae),Ae=null,l.debug("SYSTEM","Health checker stopped"))}var $s,Ae,Ms=S(()=>{"use strict";K();Bt();$s=3e4,Ae=null});import{existsSync as Ma,readFileSync as ba,rmSync as bs}from"fs";import{homedir as Ta}from"os";import Ts from"path";function As(e={}){let t=e.pidFilePath??Ra;if(!Ma(t))return"missing";let r=null;try{r=JSON.parse(ba(t,"utf-8"))}catch(s){return s instanceof Error?l.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:t},s):l.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:t,error:String(s)}),bs(t,{force:!0}),"invalid"}return Cs(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}),bs(t,{force:!0}),"stale")}var Aa,Ra,Ur,qd,Rs=S(()=>{"use strict";K();Bt();xs();Ms();Aa=Ts.join(Ta(),".claude-mem"),Ra=Ts.join(Aa,"worker.pid"),Ur=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(),As({logAlive:!1})==="alive")throw new Error("Worker already running");this.started=!0,Is()}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(s){s instanceof Error?l.error("SYSTEM","Error during shutdown",{},s):l.error("SYSTEM","Error during shutdown (non-Error)",{error:String(s)});try{await this.stop()}catch(o){o instanceof Error?l.debug("SYSTEM","Supervisor shutdown fallback failed",{},o):l.debug("SYSTEM","Supervisor shutdown fallback failed",{error:String(o)})}}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}ks(),this.stopPromise=_s({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}},qd=new Ur(Ht())});import Ds from"path";import{readFileSync as rp,existsSync as np,writeFileSync as sp,renameSync as op,mkdirSync as ip}from"fs";import{spawn as cp,execSync as lp}from"child_process";function Oa(e,t={},r){return new Promise((n,s)=>{let o=setTimeout(()=>s(new Error(`Request timed out after ${r}ms`)),r);fetch(e,t).then(i=>{clearTimeout(o),n(i)},i=>{clearTimeout(o),s(i)})})}function ct(){if(Kt!==null)return Kt;let e=Ds.join(fe.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),t=fe.loadFromFile(e);return Kt=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),Kt}function Pa(){if(Vt!==null)return Vt;let e=Ds.join(fe.get("CLAUDE_MEM_DATA_DIR"),"settings.json");return Vt=fe.loadFromFile(e).CLAUDE_MEM_WORKER_HOST,Vt}function Fa(e){return`http://${Pa()}:${ct()}${e}`}function Jt(e,t={}){let r=t.method??"GET",n=t.timeoutMs??Da,s=Fa(e),o={method:r};return t.headers&&(o.headers=t.headers),t.body&&(o.body=t.body),n>0?Oa(s,o,n):fetch(s,o)}var Da,Kt,Vt,Yt=S(()=>{"use strict";K();Pr();Fr();at();fs();Rs();Da=(()=>{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 ls(it.HEALTH_CHECK)})();Kt=null,Vt=null});import{existsSync as La,readFileSync as Na,writeFileSync as Os,mkdirSync as Ps,renameSync as Ua}from"fs";import{join as jr,basename as Cp}from"path";function Fs(e){try{return La(e)?JSON.parse(Na(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 Ls(e,t){let r=jr(e,"..");Ps(r,{recursive:!0}),Os(e,JSON.stringify(t,null,2))}function Gr(e,t){let r=jr(e,".cursor","rules"),n=jr(r,"claude-mem-context.mdc"),s=`${n}.tmp`;Ps(r,{recursive:!0});let o=`---
|
|
50
|
+
`)},info:t=>{M.message(t,{symbol:l.default.blue(Ci)})},success:t=>{M.message(t,{symbol:l.default.green(Ei)})},step:t=>{M.message(t,{symbol:l.default.green(Ct)})},warn:t=>{M.message(t,{symbol:l.default.yellow(hi)})},warning:t=>{M.warn(t)},error:t=>{M.message(t,{symbol:l.default.red(Fi)})}},Si=()=>{let t=ur?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],e=ur?80:120,r=process.env.CI==="true",o,s,i=!1,n="",u,c=$=>{let U=$>1?"Something went wrong":"Canceled";i&&Me(U,$)},d=()=>c(2),p=()=>c(1),D=()=>{process.on("uncaughtExceptionMonitor",d),process.on("unhandledRejection",d),process.on("SIGINT",p),process.on("SIGTERM",p),process.on("exit",c)},E=()=>{process.removeListener("uncaughtExceptionMonitor",d),process.removeListener("unhandledRejection",d),process.removeListener("SIGINT",p),process.removeListener("SIGTERM",p),process.removeListener("exit",c)},v=()=>{if(u===void 0)return;r&&process.stdout.write(`
|
|
51
|
+
`);let $=u.split(`
|
|
52
|
+
`);process.stdout.write(ft.cursor.move(-999,$.length-1)),process.stdout.write(ft.erase.down($.length))},De=$=>$.replace(/\.+$/,""),Zr=($="")=>{i=!0,o=Sn(),n=De($),process.stdout.write(`${l.default.gray(S)}
|
|
53
|
+
`);let U=0,q=0;D(),s=setInterval(()=>{if(r&&n===u)return;v(),u=n;let Fs=l.default.magenta(t[U]),Ss=r?"...":".".repeat(Math.floor(q)).slice(0,3);process.stdout.write(`${Fs} ${n}${Ss}`),U=U+1<t.length?U+1:0,q=q<t.length?q+.125:0},e)},Me=($="",U=0)=>{i=!1,clearInterval(s),v();let q=U===0?l.default.green(Ct):U===1?l.default.red(An):l.default.red(bn);n=De($??n),process.stdout.write(`${q} ${n}
|
|
54
|
+
`),E(),o()};return{start:Zr,stop:Me,message:($="")=>{n=De($??n)}}},ht=async t=>{for(let e of t){if(e.enabled===!1)continue;let r=Si();r.start(e.title);let o=await e.task(r.message);r.stop(o||e.title)}}});import{execSync as yi}from"child_process";import{existsSync as H,readdirSync as wi}from"fs";import{homedir as Tn}from"os";import{join as K}from"path";function je(t){try{return yi(`${z?"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 vi(t){let e=K(Tn(),".vscode","extensions");if(!H(e))return!1;try{return wi(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 Ue(){let t=Tn();return[{id:"claude-code",label:"Claude Code",detected:H(K(t,".claude")),supported:!0,hint:"recommended"},{id:"gemini-cli",label:"Gemini CLI",detected:H(K(t,".gemini")),supported:!0},{id:"opencode",label:"OpenCode",detected:H(K(t,".config","opencode"))||je("opencode"),supported:!0,hint:"plugin-based integration"},{id:"openclaw",label:"OpenClaw",detected:H(K(t,".openclaw")),supported:!0,hint:"plugin-based integration"},{id:"windsurf",label:"Windsurf",detected:H(K(t,".codeium","windsurf")),supported:!0},{id:"codex-cli",label:"Codex CLI",detected:H(K(t,".codex")),supported:!0,hint:"transcript-based integration"},{id:"cursor",label:"Cursor",detected:H(K(t,".cursor")),supported:!0,hint:"hooks + MCP integration"},{id:"copilot-cli",label:"Copilot CLI",detected:je("copilot"),supported:!0,hint:"MCP-based integration"},{id:"antigravity",label:"Antigravity",detected:H(K(t,".gemini","antigravity")),supported:!0,hint:"MCP-based integration"},{id:"goose",label:"Goose",detected:H(K(t,".config","goose"))||je("goose"),supported:!0,hint:"MCP-based integration"},{id:"crush",label:"Crush",detected:je("crush"),supported:!0,hint:"MCP-based integration"},{id:"roo-code",label:"Roo Code",detected:vi("roo-code"),supported:!0,hint:"MCP-based integration"},{id:"warp",label:"Warp",detected:H(K(t,".warp"))||je("warp"),supported:!0,hint:"MCP-based integration"}]}var Rn=m(()=>{"use strict";ae()});import{appendFileSync as _i,existsSync as Pn,mkdirSync as xi,readFileSync as ki}from"fs";import{join as Ft}from"path";import{homedir as Ai}from"os";var cr,On,lr,a,T=m(()=>{"use strict";cr=(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))(cr||{}),On=Ft(Ai(),".claude-mem"),lr=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=Ft(On,"logs");Pn(e)||xi(e,{recursive:!0});let r=new Date().toISOString().split("T")[0];this.logFilePath=Ft(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=Ft(On,"settings.json");if(Pn(e)){let r=ki(e,"utf-8"),s=(JSON.parse(r).CLAUDE_MEM_LOG_LEVEL||"INFO").toUpperCase();this.level=cr[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=cr[e].padEnd(5),c=r.padEnd(6),d="";s?.correlationId?d=`[${s.correlationId}] `:s?.sessionId&&(d=`[session-${s.sessionId}] `);let p="";i!=null&&(i instanceof Error?p=this.getLevel()===0?`
|
|
56
|
+
${i.message}
|
|
57
|
+
${i.stack}`:` ${i.message}`:this.getLevel()===0&&typeof i=="object"?p=`
|
|
58
|
+
`+JSON.stringify(i,null,2):p=" "+this.formatData(i));let D="";if(s){let{sessionId:v,memorySessionId:De,correlationId:Zr,...Me}=s;Object.keys(Me).length>0&&(D=` {${Object.entries(Me).map(([U,q])=>`${U}=${q}`).join(", ")}}`)}let E=`[${n}] [${u}] [${c}] ${d}${o}${D}${p}`;if(this.logFilePath)try{_i(this.logFilePath,E+`
|
|
59
|
+
`,"utf8")}catch(v){process.stderr.write(`[LOGGER] Failed to write to log file: ${v instanceof Error?v.message:String(v)}
|
|
60
|
+
`)}else process.stderr.write(E+`
|
|
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+)\)?/),p=d?`${d[1].split("/").pop()}:${d[2]}`:"unknown",D={...o,location:p};return this.warn(e,`[HAPPY-PATH] ${r}`,D,s),i}},a=new lr});function Ln(t){return process.platform==="win32"?Math.round(t*Ge.WINDOWS_MULTIPLIER):t}var Ge,Dr=m(()=>{"use strict";Ge={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{readFileSync as bi,writeFileSync as Bn,existsSync as Nn,mkdirSync as Mi}from"fs";import{join as jn,dirname as Ii}from"path";import{homedir as Un}from"os";var te,dr=m(()=>{"use strict";te=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:jn(Un(),".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:jn(Un(),".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(!Nn(e)){let n=this.getAllDefaults();try{let u=Ii(e);Nn(u)||Mi(u,{recursive:!0}),Bn(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=bi(e,"utf-8"),o=JSON.parse(r),s=o;if(o.env&&typeof o.env=="object"){s=o.env;try{Bn(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())}}}});import{join as A,dirname as $i,basename as Ti}from"path";import{homedir as Gn}from"os";import{existsSync as Ri,mkdirSync as ll}from"fs";import{execSync as dl}from"child_process";import{fileURLToPath as Pi}from"url";function Oi(){return typeof __dirname<"u"?__dirname:$i(Pi(import.meta.url))}function Li(){if(process.env.CLAUDE_MEM_DATA_DIR)return process.env.CLAUDE_MEM_DATA_DIR;let t=A(Gn(),".claude-mem"),e=A(t,"settings.json");try{if(Ri(e)){let{readFileSync:r}=ks("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 gl,R,fe,St,fl,Cl,El,hl,Fl,Bi,Sl,yl,Ni,wl,vl,_l,xl,We=m(()=>{"use strict";T();gl=Oi();R=Li(),fe=process.env.CLAUDE_CONFIG_DIR||A(Gn(),".claude"),St=A(fe,"plugins","marketplaces","thedotmack"),fl=A(R,"archives"),Cl=A(R,"logs"),El=A(R,"trash"),hl=A(R,"backups"),Fl=A(R,"modes"),Bi=A(R,"settings.json"),Sl=A(R,"claude-mem.db"),yl=A(R,"vector-db"),Ni=A(R,"observer-sessions"),wl=Ti(Ni),vl=A(fe,"settings.json"),_l=A(fe,"commands"),xl=A(fe,"CLAUDE.md")});var Wn=m(()=>{"use strict";dr();We()});var Hn=m(()=>{"use strict"});import{spawn as Pl,spawnSync as ji}from"child_process";import{existsSync as Ui,mkdirSync as Kn,readFileSync as Jn,writeFileSync as Gi}from"fs";import{homedir as Wi}from"os";import yt from"path";function V(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 Vi(t){if(!Number.isInteger(t)||t<=0)return null;if(process.platform==="linux")try{let e=Jn(`/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=ji("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 Yn(t){if(!t||!V(t.pid))return!1;if(!t.startToken)return!0;let e=Vi(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 wt(){return pr||(pr=new mr),pr}var Hi,Ki,Ji,Yi,mr,pr,vt=m(()=>{"use strict";T();Hn();Hi=5e3,Ki=1e3,Ji=yt.join(Wi(),".claude-mem"),Yi=yt.join(Ji,"supervisor.json");mr=class{registryPath;entries=new Map;runtimeProcesses=new Map;initialized=!1;constructor(e=Yi){this.registryPath=e}initialize(){if(this.initialized)return;if(this.initialized=!0,Kn(yt.dirname(this.registryPath),{recursive:!0}),!Ui(this.registryPath)){this.persist();return}try{let o=JSON.parse(Jn(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)V(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=>V(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()+Hi;for(;Date.now()<i&&s.filter(c=>V(c.pid)).length!==0;)await new Promise(c=>setTimeout(c,100));let n=s.filter(u=>V(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()+Ki;for(;Date.now()<u&&n.filter(d=>V(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())};Kn(yt.dirname(this.registryPath),{recursive:!0}),Gi(this.registryPath,JSON.stringify(e,null,2))}},pr=null});import{execFile as Xi}from"child_process";import{rmSync as zi}from"fs";import{homedir as qi}from"os";import zn from"path";import{promisify as Zi}from"util";async function qn(t){let e=t.currentPid??process.pid,r=t.pidFilePath??tu,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(!V(n.pid)){t.registry.unregister(n.id);continue}try{await Xn(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 Vn(s,5e3);let i=s.filter(n=>V(n.pid));for(let n of i)try{await Xn(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 Vn(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{zi(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 Vn(t,e){let r=Date.now()+e;for(;Date.now()<r;){if(t.filter(s=>V(s.pid)).length===0)return;await new Promise(s=>setTimeout(s,100))}}async function Xn(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 ru();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 Qi("taskkill",i,{timeout:Ge.POWERSHELL_COMMAND,windowsHide:!0})}async function ru(){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 Qi,eu,tu,Zn=m(()=>{"use strict";T();Dr();vt();Qi=Zi(Xi),eu=zn.join(qi(),".claude-mem"),tu=zn.join(eu,"worker.pid")});function nu(){let e=wt().pruneDeadEntries();e>0&&a.info("SYSTEM",`Health check: pruned ${e} dead process(es) from registry`)}function eo(){Ce===null&&(Ce=setInterval(nu,Qn),Ce.unref(),a.debug("SYSTEM","Health checker started",{intervalMs:Qn}))}function to(){Ce!==null&&(clearInterval(Ce),Ce=null,a.debug("SYSTEM","Health checker stopped"))}var Qn,Ce,ro=m(()=>{"use strict";T();vt();Qn=3e4,Ce=null});import{existsSync as ou,readFileSync as su,rmSync as no}from"fs";import{homedir as iu}from"os";import oo from"path";function so(t={}){let e=t.pidFilePath??au;if(!ou(e))return"missing";let r=null;try{r=JSON.parse(su(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)}),no(e,{force:!0}),"invalid"}return Yn(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}),no(e,{force:!0}),"stale")}var uu,au,gr,uD,io=m(()=>{"use strict";T();vt();Zn();ro();uu=oo.join(iu(),".claude-mem"),au=oo.join(uu,"worker.pid"),gr=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(),so({logAlive:!1})==="alive")throw new Error("Worker already running");this.started=!0,eo()}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}to(),this.stopPromise=qn({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}},uD=new gr(wt())});import uo from"path";import{readFileSync as pD,existsSync as mD,writeFileSync as gD,renameSync as fD,mkdirSync as CD}from"fs";import{spawn as hD,execSync as FD}from"child_process";function lu(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 He(){if(_t!==null)return _t;let t=uo.join(te.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),e=te.loadFromFile(t);return _t=parseInt(e.CLAUDE_MEM_WORKER_PORT,10),_t}function Du(){if(xt!==null)return xt;let t=uo.join(te.get("CLAUDE_MEM_DATA_DIR"),"settings.json");return xt=te.loadFromFile(t).CLAUDE_MEM_WORKER_HOST,xt}function du(t){return`http://${Du()}:${He()}${t}`}function kt(t,e={}){let r=e.method??"GET",o=e.timeoutMs??cu,s=du(t),i={method:r};return e.headers&&(i.headers=e.headers),e.body&&(i.body=e.body),o>0?lu(s,i,o):fetch(s,i)}var cu,_t,xt,At=m(()=>{"use strict";T();Dr();dr();We();Wn();io();cu=(()=>{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 Ln(Ge.HEALTH_CHECK)})();_t=null,xt=null});import{existsSync as pu,readFileSync as mu,writeFileSync as ao,mkdirSync as co,renameSync as gu}from"fs";import{join as fr,basename as MD}from"path";function lo(t){try{return pu(t)?JSON.parse(mu(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 Do(t,e){let r=fr(t,"..");co(r,{recursive:!0}),ao(t,JSON.stringify(e,null,2))}function Cr(t,e){let r=fr(t,".cursor","rules"),o=fr(r,"claude-mem-context.mdc"),s=`${o}.tmp`;co(r,{recursive:!0});let i=`---
|
|
71
63
|
alwaysApply: true
|
|
72
64
|
description: "Claude-mem context from past sessions (auto-updated)"
|
|
73
65
|
---
|
|
@@ -76,14 +68,14 @@ 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
|
+
`;ao(s,i),gu(s,o)}var po=m(()=>{"use strict";T()});var yo={};Y(yo,{checkCursorHooksStatus:()=>So,configureCursorMcp:()=>Su,detectClaudeCode:()=>xu,detectPlatform:()=>fo,findBunPath:()=>he,findMcpServerPath:()=>Ke,findWorkerServicePath:()=>Ee,getScriptExtension:()=>hu,getTargetDir:()=>It,handleCursorCommand:()=>ku,installCursorHooks:()=>ho,readCursorRegistry:()=>Mt,registerCursorProject:()=>Co,uninstallCursorHooks:()=>Fo,unregisterCursorProject:()=>Eo,updateCursorContextForProject:()=>Fu,writeCursorRegistry:()=>Sr});import g from"path";import{homedir as bt}from"os";import{existsSync as B,readFileSync as mo,writeFileSync as hr,unlinkSync as Er,mkdirSync as Fr}from"fs";import{exec as fu}from"child_process";import{promisify as Cu}from"util";function fo(){return process.platform==="win32"?"windows":"unix"}function hu(){return fo()==="windows"?".ps1":".sh"}function Mt(){return lo(go)}function Sr(t){Do(go,t)}function Co(t,e){let r=Mt();r[t]={workspacePath:e,installedAt:new Date().toISOString()},Sr(r),a.info("CURSOR","Registered project for auto-context updates",{projectName:t,workspacePath:e})}function Eo(t){let e=Mt();e[t]&&(delete e[t],Sr(e),a.info("CURSOR","Unregistered project",{projectName:t}))}async function Fu(t,e){let o=Mt()[t];if(o)try{let s=await kt(`/api/context/inject?project=${encodeURIComponent(t)}`);if(!s.ok)return;let i=await s.text();if(!i||!i.trim())return;Cr(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 Ke(){let t=[g.join(St,"plugin","scripts","mcp-server.cjs"),g.join(process.cwd(),"plugin","scripts","mcp-server.cjs")];for(let e of t)if(B(e))return e;return null}function Ee(){let t=[g.join(St,"plugin","scripts","worker-service.cjs"),g.join(process.cwd(),"plugin","scripts","worker-service.cjs")];for(let e of t)if(B(e))return e;return null}function he(){let t=[g.join(bt(),".bun","bin","bun"),"/usr/local/bin/bun","/usr/bin/bun",...process.platform==="win32"?[g.join(bt(),".bun","bin","bun.exe"),g.join(process.env.LOCALAPPDATA||"","bun","bun.exe")]:[]];for(let e of t)if(e&&B(e))return e;return"bun"}function It(t){switch(t){case"project":return g.join(process.cwd(),".cursor");case"user":return g.join(bt(),".cursor");case"enterprise":return process.platform==="darwin"?"/Library/Application Support/Cursor":process.platform==="linux"?"/etc/cursor":process.platform==="win32"?g.join(process.env.ProgramData||"C:\\ProgramData","Cursor"):null;default:return null}}function Su(t){let e=Ke();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=It(t);if(!r)return console.error(`Invalid target: ${t}. Use: project or user`),1;let o=g.join(r,"mcp.json");try{Fr(r,{recursive:!0});let s={mcpServers:{}};if(B(o))try{s=JSON.parse(mo(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]},hr(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 ho(t){console.log(`
|
|
76
|
+
Installing Claude-Mem Cursor hooks (${t} level)...
|
|
77
|
+
`);let e=It(t);if(!e)return console.error(`Invalid target: ${t}. Use: project, user, or enterprise`),1;let r=Ee();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=g.join(e,"hooks.json"),i=he(),n=i.replace(/\\/g,"\\\\"),u=r.replace(/\\/g,"\\\\"),c=p=>`"${n}" "${u}" hook cursor ${p}`;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 Fr(e,{recursive:!0}),await yu(s,d,r,t,e,o),0}catch(p){let D=p instanceof Error?p.message:String(p);return console.error(`
|
|
78
|
+
Installation failed: ${D}`),t==="enterprise"&&console.error(" Tip: Enterprise installation may require sudo/admin privileges"),1}}async function yu(t,e,r,o,s,i){hr(t,JSON.stringify(e,null,2)),console.log(" Created hooks.json (unified CLI mode)"),console.log(` Worker service: ${r}`),o==="project"&&await wu(s,i),console.log(`
|
|
87
79
|
Installation complete!
|
|
88
80
|
|
|
89
81
|
Hooks installed to: ${s}/hooks.json
|
|
@@ -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 wu(t,e){let r=g.join(t,"rules");Fr(r,{recursive:!0});let o=g.basename(e),s=!1;console.log(" Generating initial context...");try{s=await vu(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=g.join(r,"claude-mem-context.mdc");hr(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)")}Co(o,e),console.log(" Registered for auto-context updates")}async function vu(t,e){if(!(await kt("/api/readiness")).ok)return!1;let o=await kt(`/api/context/inject?project=${encodeURIComponent(t)}`);if(!o.ok)return!1;let s=await o.text();return s&&s.trim()?(Cr(e,s),console.log(" Generated initial context from existing memory"),!0):!1}function Fo(t){console.log(`
|
|
103
|
+
Uninstalling Claude-Mem Cursor hooks (${t} level)...
|
|
104
|
+
`);let e=It(t);if(!e)return console.error(`Invalid target: ${t}`),1;let r=g.join(e,"hooks"),o=g.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 _u(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 _u(t,e,r,o,s){for(let i of e){let n=g.join(t,i);B(n)&&(Er(n),console.log(` Removed legacy script: ${i}`))}if(B(r)&&(Er(r),console.log(" Removed hooks.json")),o==="project"){let i=g.join(s,"rules","claude-mem-context.mdc");B(i)&&(Er(i),console.log(" Removed context file"));let n=g.basename(process.cwd());Eo(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 So(){console.log(`
|
|
116
108
|
Claude-Mem Cursor Hooks Status
|
|
117
|
-
`);let
|
|
118
|
-
`),0}async function
|
|
109
|
+
`);let t=[{name:"Project",dir:g.join(process.cwd(),".cursor")},{name:"User",dir:g.join(bt(),".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=g.join(r.dir,"hooks.json"),s=g.join(r.dir,"hooks");if(B(o)){e=!0,console.log(`${r.name}: Installed`),console.log(` Config: ${o}`);let i=null;try{i=JSON.parse(mo(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(D=>B(g.join(s,D))),p=c.some(D=>B(g.join(s,D)));d||p?(console.log(" Mode: Legacy shell scripts (consider reinstalling for unified CLI)"),d&&p?console.log(" Platform: Both (bash + PowerShell)"):d?console.log(" Platform: Unix (bash)"):p&&console.log(" Platform: Windows (PowerShell)")):console.log(" Mode: Unknown configuration")}}if(r.name==="Project"){let n=g.join(r.dir,"rules","claude-mem-context.mdc");B(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 xu(){try{let{stdout:e}=await Eu("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=g.join(fe,"plugins");return!!B(t)}async function ku(t,e){switch(t){case"install":{let r=e[0]||"project";return ho(r)}case"uninstall":{let r=e[0]||"project";return Fo(r)}case"status":return So();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 Eu,go,Je=m(()=>{"use strict";T();At();We();po();Eu=Cu(fu),go=g.join(R,"cursor-projects.json")});var _r={};Y(_r,{checkGeminiCliHooksStatus:()=>ko,handleGeminiCliCommand:()=>Ou,installGeminiCliHooks:()=>_o,uninstallGeminiCliHooks:()=>xo});import yr from"path";import{homedir as Au}from"os";import{existsSync as Fe,readFileSync as $t,writeFileSync as wr,mkdirSync as wo}from"fs";function Mu(t,e,r){let o=Se[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 Iu(t){return{matcher:"*",hooks:[{name:Ye,type:"command",command:t,timeout:bu}]}}function vr(){if(!Fe(I))return{};let t=$t(I,"utf-8");try{return JSON.parse(t)}catch(e){throw e instanceof Error?a.error("WORKER","Corrupt JSON in Gemini settings",{path:I},e):a.error("WORKER","Corrupt JSON in Gemini settings",{path:I},new Error(String(e))),new Error(`Corrupt JSON in ${I}, refusing to overwrite user settings`)}}function vo(t){wo(Tt,{recursive:!0}),wr(I,JSON.stringify(t,null,2)+`
|
|
135
|
+
`)}function $u(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===Ye));if(u>=0){let c=i[u],d=c.hooks.findIndex(p=>p.name===Ye);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 Tu(){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(Fe(J)&&(o=$t(J,"utf-8")),o.includes(t))return;let s=o.length>0&&!o.endsWith(`
|
|
148
140
|
`)?`
|
|
149
141
|
|
|
150
|
-
`:
|
|
151
|
-
`:"",o
|
|
152
|
-
`;
|
|
142
|
+
`:o.length>0?`
|
|
143
|
+
`:"",i=o+s+r+`
|
|
144
|
+
`;wo(Tt,{recursive:!0}),wr(J,i)}async function _o(){console.log(`
|
|
153
145
|
Installing Claude-Mem Gemini CLI hooks...
|
|
154
|
-
`);let
|
|
155
|
-
Installation failed: ${
|
|
146
|
+
`);let t=Ee();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=he();console.log(` Using Bun runtime: ${e}`),console.log(` Worker service: ${t}`);try{let r={};for(let i of Object.keys(Se)){let n=Mu(e,t,i);r[i]=[Iu(n)]}let o=vr(),s=$u(o,r);return Ru(s),0}catch(r){let o=r instanceof Error?r.message:String(r);return console.error(`
|
|
147
|
+
Installation failed: ${o}`),1}}function Ru(t){vo(t),console.log(` Merged hooks into ${I}`),Tu(),console.log(` Setup context injection in ${J}`);let e=Object.keys(Se);console.log(` Registered ${e.length} hook events:`);for(let r of e){let o=Se[r];console.log(` ${r} \u2192 ${o}`)}console.log(`
|
|
156
148
|
Installation complete!
|
|
157
149
|
|
|
158
|
-
Hooks installed to: ${
|
|
150
|
+
Hooks installed to: ${I}
|
|
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 xo(){if(console.log(`
|
|
170
162
|
Uninstalling Claude-Mem Gemini CLI hooks...
|
|
171
|
-
`),!
|
|
172
|
-
Uninstallation failed: ${
|
|
163
|
+
`),!Fe(I))return console.log(" No Gemini CLI settings found \u2014 nothing to uninstall."),0;try{let t=vr();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!==Ye);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,Pu(t,e),0}catch(t){let e=t instanceof Error?t.message:String(t);return console.error(`
|
|
164
|
+
Uninstallation failed: ${e}`),1}}function Pu(t,e){if(vo(t),console.log(` Removed ${e} claude-mem hook(s) from ${I}`),Fe(J)){let r=$t(J,"utf-8"),o=/\n?<claude-mem-context>[\s\S]*?<\/claude-mem-context>\n?/;o.test(r)&&(r=r.replace(o,""),wr(J,r),console.log(` Removed context section from ${J}`))}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 ko(){if(console.log(`
|
|
175
167
|
Claude-Mem Gemini CLI Hooks Status
|
|
176
|
-
`),!
|
|
168
|
+
`),!Fe(I))return console.log("Gemini CLI settings: Not found"),console.log(` Expected at: ${I}
|
|
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=vr()}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:I},r):a.error("WORKER","Failed to read Gemini CLI settings",{path:I},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===Ye))&&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: ${I}`),console.log("Mode: Unified CLI (bun worker-service.cjs hook gemini-cli)"),console.log(`Events: ${e.length} of ${Object.keys(Se).length} mapped`);for(let r of e){let o=Se[r]??"unknown";console.log(` ${r} \u2192 ${o}`)}return Fe(J)?$t(J,"utf-8").includes("<claude-mem-context>")?console.log(`Context: Active (${J})`):console.log("Context: GEMINI.md exists but missing claude-mem section"):console.log("Context: No GEMINI.md found"),console.log(""),0}async function Ou(t,e){switch(t){case"install":return _o();case"uninstall":return xo();case"status":return ko();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
|
-
${
|
|
191
|
+
`),0}}var Tt,I,J,Ye,bu,Se,xr=m(()=>{"use strict";T();Je();Tt=yr.join(Au(),".gemini"),I=yr.join(Tt,"settings.json"),J=yr.join(Tt,"GEMINI.md"),Ye="claude-mem",bu=1e4,Se={SessionStart:"context",BeforeAgent:"session-init",AfterAgent:"observation",BeforeTool:"observation",AfterTool:"observation",PreCompress:"summarize",Notification:"observation",SessionEnd:"session-complete"}});import Lu from"path";import{existsSync as Bu,readFileSync as Nu,writeFileSync as kr,mkdirSync as ju}from"fs";function Rt(t,e,r){let o=Lu.dirname(t);ju(o,{recursive:!0});let s=`${Ve}
|
|
192
|
+
${e}
|
|
193
|
+
${ye}`;if(Bu(t)){let i=Nu(t,"utf-8"),n=i.indexOf(Ve),u=i.indexOf(ye);n!==-1&&u!==-1?i=i.slice(0,n)+s+i.slice(u+ye.length):i=i.trimEnd()+`
|
|
202
194
|
|
|
203
195
|
`+s+`
|
|
204
|
-
`,
|
|
196
|
+
`,kr(t,i,"utf-8")}else r?kr(t,`${r}
|
|
205
197
|
|
|
206
198
|
${s}
|
|
207
|
-
`,"utf-8"):
|
|
208
|
-
`,"utf-8")}var
|
|
209
|
-
`,"utf-8"),console.log(" Cleaned context from AGENTS.md"))}function
|
|
210
|
-
`+
|
|
199
|
+
`,"utf-8"):kr(t,s+`
|
|
200
|
+
`,"utf-8")}var Ve,ye,Ar=m(()=>{"use strict";Ve="<claude-mem-context>",ye="</claude-mem-context>"});var Ir={};Y(Ir,{checkOpenCodeStatus:()=>zu,findBuiltPluginPath:()=>Io,getInstalledPluginPath:()=>ze,getOpenCodeAgentsMdPath:()=>Xe,getOpenCodeConfigDirectory:()=>Pt,getOpenCodePluginsDirectory:()=>br,injectContextIntoAgentsMd:()=>Mr,installOpenCodeIntegration:()=>qu,installOpenCodePlugin:()=>$o,syncContextToAgentsMd:()=>Ku,uninstallOpenCodePlugin:()=>Xu});import re from"path";import{homedir as Ao}from"os";import{fileURLToPath as Uu}from"url";import{existsSync as we,readFileSync as bo,writeFileSync as Gu,mkdirSync as Wu,copyFileSync as Hu,unlinkSync as Mo}from"fs";function Pt(){return process.env.OPENCODE_CONFIG_DIR?process.env.OPENCODE_CONFIG_DIR:re.join(Ao(),".config","opencode")}function br(){return re.join(Pt(),"plugins")}function Xe(){return re.join(Pt(),"AGENTS.md")}function ze(){return re.join(br(),"claude-mem.js")}function Io(){let t=[re.join(process.env.CLAUDE_CONFIG_DIR||re.join(Ao(),".claude"),"plugins","marketplaces","thedotmack","dist","opencode-plugin","index.js"),re.join(re.dirname(Uu(import.meta.url)),"..","..","..","dist","opencode-plugin","index.js")];for(let e of t)if(we(e))return e;return null}function $o(){let t=Io();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=br(),r=ze();try{return Wu(e,{recursive:!0}),Hu(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 Mr(t){let e=Xe();try{return Rt(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 Ku(t,e){try{await Yu(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 Ju(){let t=He();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 Yu(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()&&Mr(o)!==0&&a.warn("OPENCODE","Failed to inject context into AGENTS.md during sync")}function Vu(t,e){e.length===0||e==="# Claude-Mem Memory Context"?(Mo(t),console.log(" Removed empty AGENTS.md")):(Gu(t,e+`
|
|
201
|
+
`,"utf-8"),console.log(" Cleaned context from AGENTS.md"))}function Xu(){let t=!1,e=ze();if(we(e))try{Mo(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=Xe();if(we(r)){let o;try{o=bo(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(Ve),i=o.indexOf(ye);if(s!==-1&&i!==-1){o=o.slice(0,s).trimEnd()+`
|
|
202
|
+
`+o.slice(i+ye.length).trimStart();let n=o.trim();try{Vu(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 zu(){console.log(`
|
|
211
203
|
Claude-Mem OpenCode Integration Status
|
|
212
|
-
`);let
|
|
204
|
+
`);let t=Pt(),e=ze(),r=Xe();if(console.log(`Config directory: ${t}`),console.log(` Exists: ${we(t)?"yes":"no"}`),console.log(""),console.log(`Plugin: ${e}`),console.log(` Installed: ${we(e)?"yes":"no"}`),console.log(""),console.log(`Context (AGENTS.md): ${r}`),we(r)){let s=bo(r,"utf-8").includes(Ve);console.log(" Exists: yes"),console.log(` Has claude-mem context: ${s?"yes":"no"}`)}else console.log(" Exists: no");return console.log(""),0}async function qu(){console.log(`
|
|
213
205
|
Installing Claude-Mem for OpenCode...
|
|
214
|
-
`);let
|
|
206
|
+
`);let t=$o();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 Ju();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 Mr(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: ${ze()}
|
|
214
|
+
Context file: ${Xe()}
|
|
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 $r=m(()=>{"use strict";T();Ar();At()});var Pr={};Y(Pr,{checkWindsurfHooksStatus:()=>jo,handleWindsurfCommand:()=>aa,installWindsurfHooks:()=>Bo,readWindsurfRegistry:()=>Nt,registerWindsurfProject:()=>Oo,uninstallWindsurfHooks:()=>No,unregisterWindsurfProject:()=>Lo,updateWindsurfContextForProject:()=>ea,writeWindsurfContextFile:()=>Rr,writeWindsurfRegistry:()=>Tr});import N from"path";import{homedir as Zu}from"os";import{existsSync as _e,readFileSync as Lt,writeFileSync as qe,unlinkSync as Ro,mkdirSync as Bt,renameSync as Qu}from"fs";function Nt(){try{return _e(ve)?JSON.parse(Lt(ve,"utf-8")):{}}catch(t){return t instanceof Error?a.error("WORKER","Failed to read registry, using empty",{file:ve},t):a.error("WORKER","Failed to read registry, using empty",{file:ve},new Error(String(t))),{}}}function Tr(t){let e=N.dirname(ve);Bt(e,{recursive:!0}),qe(ve,JSON.stringify(t,null,2))}function Oo(t){let e=Nt();e[t]={installedAt:new Date().toISOString()},Tr(e),a.info("WINDSURF","Registered project for auto-context updates",{workspacePath:t})}function Lo(t){let e=Nt();e[t]&&(delete e[t],Tr(e),a.info("WINDSURF","Unregistered project",{workspacePath:t}))}async function ea(t,e,r){if(Nt()[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;Rr(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 Rr(t,e){let r=N.join(t,".windsurf","rules"),o=N.join(r,"claude-mem-context.md"),s=`${o}.tmp`;Bt(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>To&&(i=i.slice(0,To-50)+`
|
|
237
229
|
|
|
238
230
|
*[Truncated \u2014 use MCP search for full history]*
|
|
239
|
-
`),
|
|
231
|
+
`),qe(s,i),Qu(s,o)}function ta(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 ra(t,e,r){Bt(Po,{recursive:!0});let o={hooks:{}};if(_e(_))try{o=JSON.parse(Lt(_,"utf-8")),o.hooks||(o.hooks={})}catch(s){throw s instanceof Error?a.error("WORKER","Corrupt hooks.json, refusing to overwrite",{path:_},s):a.error("WORKER","Corrupt hooks.json, refusing to overwrite",{path:_},new Error(String(s))),new Error(`Corrupt hooks.json at ${_}, refusing to overwrite`)}for(let s of Ot){let n={command:ta(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]}qe(_,JSON.stringify(o,null,2))}async function Bo(){console.log(`
|
|
240
232
|
Installing Claude-Mem Windsurf hooks (user level)...
|
|
241
|
-
`);let
|
|
242
|
-
Installation failed: ${
|
|
233
|
+
`);let t=Ee();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=he();if(!e)return console.error("Could not find Bun runtime"),console.error(" Install Bun: curl -fsSL https://bun.sh/install | bash"),1;let r=N.dirname(t);console.log(` Using Bun runtime: ${e}`),console.log(` Worker service: ${t}`);let o=process.cwd();try{return await na(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 na(t,e,r,o){ra(t,e,r),console.log(" Created/merged hooks.json"),await oa(o),console.log(`
|
|
243
235
|
Installation complete!
|
|
244
236
|
|
|
245
|
-
Hooks installed to: ${
|
|
237
|
+
Hooks installed to: ${_}
|
|
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 oa(t){let e=He(),r=N.basename(t),o=!1;console.log(" Generating initial context...");try{o=await sa(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=N.join(t,".windsurf","rules");Bt(s,{recursive:!0});let i=N.join(s,"claude-mem-context.md");qe(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)")}Oo(t),console.log(" Registered for auto-context updates")}async function sa(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()?(Rr(r,i),console.log(" Generated initial context from existing memory"),!0):!1}function No(){if(console.log(`
|
|
265
257
|
Uninstalling Claude-Mem Windsurf hooks...
|
|
266
|
-
`),
|
|
267
|
-
Uninstallation failed: ${r}`),1}}function
|
|
258
|
+
`),_e(_))try{ia()}catch(e){e instanceof Error?a.error("WORKER","Could not parse hooks.json during uninstall",{path:_},e):a.error("WORKER","Could not parse hooks.json during uninstall",{path:_},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 ua(t),0}catch(e){let r=e instanceof Error?e.message:String(e);return console.error(`
|
|
259
|
+
Uninstallation failed: ${r}`),1}}function ia(){let e={hooks:JSON.parse(Lt(_,"utf-8")).hooks??{}};for(let r of Ot){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?(Ro(_),console.log(" Removed hooks.json (no hooks remaining)")):(qe(_,JSON.stringify(e,null,2)),console.log(" Removed claude-mem entries from hooks.json (other hooks preserved)"))}function ua(t){let e=N.join(t,".windsurf","rules","claude-mem-context.md");_e(e)&&(Ro(e),console.log(" Removed context file")),Lo(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
|
+
`),_e(_)){console.log("User-level: Installed"),console.log(` Config: ${_}`);let t=null;try{t=JSON.parse(Lt(_,"utf-8"))}catch(r){let o=r instanceof Error?r:new Error(String(r));a.error("WORKER","Unable to parse hooks.json",{path:_},o),console.log(" Mode: Unable to parse hooks.json")}if(t){let r=Ot.filter(o=>(t?.hooks?.[o]??[]).some(s=>s.command.includes("worker-service")&&s.command.includes("windsurf")));console.log(` Events: ${r.length}/${Ot.length} registered`);for(let o of r)console.log(` - ${o}`)}let e=N.join(process.cwd(),".windsurf","rules","claude-mem-context.md");_e(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 aa(t,e){switch(t){case"install":return Bo();case"uninstall":return No();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"),
|
|
281
|
+
`),0}}var Po,_,To,ve,Ot,Or=m(()=>{"use strict";T();At();We();Je();Po=N.join(Zu(),".codeium","windsurf"),_=N.join(Po,"hooks.json"),To=6e3,ve=N.join(R,"windsurf-projects.json"),Ot=["pre_user_prompt","post_write_code","post_run_command","post_mcp_tool_use","post_cascade_response"]});var Nr={};Y(Nr,{checkOpenClawStatus:()=>ga,findPluginManifestPath:()=>Ko,findPluginSkillsDirectory:()=>Jo,findPreBuiltPluginDirectory:()=>Ho,getOpenClawClaudeMemExtensionDirectory:()=>Qe,getOpenClawConfigDirectory:()=>Ze,getOpenClawConfigFilePath:()=>xe,getOpenClawExtensionsDirectory:()=>Wo,installOpenClawIntegration:()=>fa,installOpenClawPlugin:()=>Vo,uninstallOpenClawPlugin:()=>ma});import w from"path";import{homedir as jt}from"os";import{existsSync as X,readFileSync as ca,writeFileSync as Uo,mkdirSync as Go,cpSync as Lr,rmSync as la}from"fs";function Ze(){return w.join(jt(),".openclaw")}function Wo(){return w.join(Ze(),"extensions")}function Qe(){return w.join(Wo(),"claude-mem")}function xe(){return w.join(Ze(),"openclaw.json")}function Ho(){let t=[w.join(process.env.CLAUDE_CONFIG_DIR||w.join(jt(),".claude"),"plugins","marketplaces","thedotmack"),process.cwd()];for(let e of t){let r=w.join(e,"openclaw","dist"),o=w.join(r,"index.js");if(X(o))return r}return null}function Ko(){let t=[w.join(process.env.CLAUDE_CONFIG_DIR||w.join(jt(),".claude"),"plugins","marketplaces","thedotmack"),process.cwd()];for(let e of t){let r=w.join(e,"openclaw","openclaw.plugin.json");if(X(r))return r}return null}function Jo(){let t=[w.join(process.env.CLAUDE_CONFIG_DIR||w.join(jt(),".claude"),"plugins","marketplaces","thedotmack"),process.cwd()];for(let e of t){let r=w.join(e,"openclaw","skills");if(X(r))return r}return null}function Br(){let t=xe();if(!X(t))return{};try{return JSON.parse(ca(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 Yo(t){let e=Ze();Go(e,{recursive:!0}),Uo(xe(),JSON.stringify(t,null,2)+`
|
|
282
|
+
`,"utf-8")}function Da(t=37777,e="openclaw",r=!0){let o=Br();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)}Yo(o)}function da(){let t=xe();if(!X(t))return;let e=Br();e.plugins?.entries?.["claude-mem"]&&delete e.plugins.entries["claude-mem"],e.plugins?.slots?.memory==="claude-mem"&&delete e.plugins.slots.memory,Yo(e)}function Vo(){let t=Ho();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=Qe(),r=w.join(e,"dist"),o=Ko(),s=Jo(),i={name:"claude-mem",version:"1.0.0",type:"module",main:"dist/index.js",openclaw:{extensions:["./dist/index.js"]}};try{return Go(r,{recursive:!0}),pa(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 pa(t,e,r,o,s,i){if(Lr(t,e,{recursive:!0,force:!0}),console.log(` Plugin dist copied to: ${e}`),o){let n=w.join(r,"openclaw.plugin.json");Lr(o,n,{force:!0}),console.log(` Plugin manifest copied to: ${n}`)}if(s){let n=w.join(r,"skills");Lr(s,n,{recursive:!0,force:!0}),console.log(` Skills copied to: ${n}`)}Uo(w.join(r,"package.json"),JSON.stringify(i,null,2)+`
|
|
283
|
+
`,"utf-8"),Da(),console.log(" Registered in openclaw.json"),a.info("OPENCLAW","Plugin installed",{destination:r})}function ma(){let t=!1,e=Qe();if(X(e))try{la(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{da(),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 ga(){console.log(`
|
|
292
284
|
Claude-Mem OpenClaw Integration Status
|
|
293
|
-
`);let
|
|
285
|
+
`);let t=Ze(),e=Qe(),r=xe(),o=w.join(e,"dist","index.js");if(console.log(`Config directory: ${t}`),console.log(` Exists: ${X(t)?"yes":"no"}`),console.log(""),console.log(`Extension directory: ${e}`),console.log(` Exists: ${X(e)?"yes":"no"}`),console.log(` Plugin entry: ${X(o)?"yes":"no"}`),console.log(""),console.log(`Config (openclaw.json): ${r}`),X(r)){let s=Br(),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 fa(){console.log(`
|
|
294
286
|
Installing Claude-Mem for OpenClaw...
|
|
295
|
-
`);let
|
|
287
|
+
`);let t=Vo();if(t!==0)return t;let e=Qe();return console.log(`
|
|
296
288
|
Installation complete!
|
|
297
289
|
|
|
298
|
-
Plugin installed to: ${
|
|
299
|
-
Config updated: ${
|
|
290
|
+
Plugin installed to: ${e}
|
|
291
|
+
Config updated: ${xe()}
|
|
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";T()});import{existsSync as Cd,readFileSync as Ed,writeFileSync as hd,mkdirSync as Fd}from"fs";import{homedir as Xo}from"os";import{join as zo,dirname as wd}from"path";var le,et,Ca,Ut,qo=m(()=>{"use strict";le=zo(Xo(),".claude-mem","transcript-watch.json"),et=zo(Xo(),".claude-mem","transcript-watch-state.json"),Ca={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"}]},Ut={version:1,schemas:{codex:Ca},watches:[{name:"codex",path:"~/.codex/sessions/**/*.jsonl",schema:"codex",startAtEnd:!0,context:{mode:"agents",updateOn:["session_start","session_end"]}}],stateFile:et}});var Hr={};Y(Hr,{installCodexCli:()=>va,uninstallCodexCli:()=>xa});import Gr from"path";import{homedir as Zo}from"os";import{existsSync as Wr,readFileSync as Ur,writeFileSync as Gt,mkdirSync as Ea}from"fs";function Qo(){let t=le;if(!Wr(t))return{version:1,schemas:{},watches:[],stateFile:et};try{let e=Ur(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=et),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 Gt(r,Ur(t)),console.warn(` Backed up corrupt transcript-watch.json to ${r}`),{version:1,schemas:{},watches:[],stateFile:et}}}function Sa(t){let e={...t};e.schemas={...e.schemas};let r=Ut.schemas?.[ke];r&&(e.schemas[ke]=r);let o=Ut.watches.find(s=>s.name===ke);if(o){let s=e.watches.findIndex(i=>i.name===ke);s!==-1?e.watches[s]=o:e.watches.push(o)}return e}function es(t){Ea(Fa,{recursive:!0}),Gt(le,JSON.stringify(t,null,2)+`
|
|
298
|
+
`)}function ya(){if(!Wr(tt))return;let t="<claude-mem-context>",e="</claude-mem-context>";try{wa(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 wa(t,e){let r=Ur(tt,"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?Gt(tt,u+`
|
|
301
|
+
`):Gt(tt,""),console.log(` Removed legacy global context from ${tt}`)}async function va(){console.log(`
|
|
310
302
|
Installing Claude-Mem for Codex CLI (transcript watching)...
|
|
311
|
-
`);let
|
|
312
|
-
Installation failed: ${
|
|
303
|
+
`);let t=Qo(),e=Sa(t);try{return _a(e),0}catch(r){let o=r instanceof Error?r.message:String(r);return console.error(`
|
|
304
|
+
Installation failed: ${o}`),1}}function _a(t){es(t),console.log(` Updated ${le}`),console.log(" Watch path: ~/.codex/sessions/**/*.jsonl"),console.log(` Schema: codex (v${Ut.schemas?.codex?.version??"?"})`),ts(),console.log(`
|
|
313
305
|
Installation complete!
|
|
314
306
|
|
|
315
|
-
Transcript watch config: ${
|
|
307
|
+
Transcript watch config: ${le}
|
|
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 xa(){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
|
+
`),Wr(le)){let t=Qo();t.watches=t.watches.filter(e=>e.name!==ke),t.schemas&&delete t.schemas[ke];try{es(t),console.log(` Removed codex watch from ${le}`)}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 ts(),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 ha,tt,Fa,ke,ts,Kr=m(()=>{"use strict";T();qo();ha=Gr.join(Zo(),".codex"),tt=Gr.join(ha,"AGENTS.md"),Fa=Gr.join(Zo(),".claude-mem"),ke="codex";ts=ya});var us={};Y(us,{MCP_IDE_INSTALLERS:()=>ja,installGooseMcpIntegration:()=>is});import L from"path";import{homedir as ot}from"os";import{existsSync as os,readFileSync as ka,writeFileSync as nt,mkdirSync as ss}from"fs";function ba(t){return{command:process.execPath,args:[t]}}function Ma(t,e,r="mcpServers"){let o=L.dirname(t);ss(o,{recursive:!0});let s=G(t,{});s[r]||(s[r]={}),s[r]["claude-mem"]=ba(e),nt(t,JSON.stringify(s,null,2)+`
|
|
324
|
+
`)}function rt(t){return async()=>{console.log(`
|
|
325
|
+
Installing Claude-Mem MCP integration for ${t.ideLabel}...
|
|
326
|
+
`);let e=Ke();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"&&!os(L.dirname(r)),s;t.contextFile&&(s=t.contextFile.path);try{return Ia(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 Ia(t,e,r,o,s){o?console.log(" Note: ~/.warp/ not found. MCP may need to be configured via Warp Drive UI."):(Ma(e,r,t.configKey),console.log(` MCP config written to: ${e}`)),s&&(Rt(s,Aa),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 La(){return L.join(ot(),".config","goose","config.yaml")}function Ba(t){return t.includes("claude-mem:")&&t.includes("mcpServers:")}function rs(t){return["mcpServers:"," claude-mem:",` command: ${process.execPath}`," args:",` - ${t}`].join(`
|
|
331
|
+
`)}function ns(t){return[" claude-mem:",` command: ${process.execPath}`," args:",` - ${t}`].join(`
|
|
332
|
+
`)}async function is(){console.log(`
|
|
341
333
|
Installing Claude-Mem MCP integration for Goose...
|
|
342
|
-
`);let
|
|
343
|
-
Installation failed: ${s}`),1}}function
|
|
344
|
-
`;if(!
|
|
345
|
-
`+
|
|
346
|
-
`+
|
|
334
|
+
`);let t=Ke();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=La(),r=L.dirname(e);try{return ss(r,{recursive:!0}),Na(e,t),0}catch(o){let s=o instanceof Error?o.message:String(o);return console.error(`
|
|
335
|
+
Installation failed: ${s}`),1}}function Na(t,e){if(os(t)){let r=ka(t,"utf-8");if(Ba(r)){let o=/( {2}claude-mem:\n(?:.*\n)*?(?= {2}\S|\n\n|^\S|$))/m,s=ns(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),nt(t,r),console.log(` Updated existing claude-mem entry in: ${t}`)}else if(r.includes("mcpServers:")){let s=r.indexOf("mcpServers:")+11,i=`
|
|
337
|
+
`+ns(e);r=r.slice(0,s)+i+r.slice(s),nt(t,r),console.log(` Added claude-mem to existing mcpServers in: ${t}`)}else{let o=`
|
|
338
|
+
`+rs(e)+`
|
|
347
339
|
`;r=r.trimEnd()+`
|
|
348
|
-
`+
|
|
349
|
-
`;
|
|
340
|
+
`+o,nt(t,r),console.log(` Appended mcpServers section to: ${t}`)}}else{let r=rs(e)+`
|
|
341
|
+
`;nt(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,39 +349,39 @@ 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 Aa,$a,Ta,Ra,Pa,Oa,ja,as=m(()=>{"use strict";Je();Ie();Ar();Aa=`# 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.`;$a={ideId:"copilot-cli",ideLabel:"Copilot CLI",configPath:L.join(ot(),".github","copilot","mcp.json"),configKey:"servers",contextFile:{path:L.join(process.cwd(),".github","copilot-instructions.md"),isWorkspaceRelative:!0}},Ta={ideId:"antigravity",ideLabel:"Antigravity",configPath:L.join(ot(),".gemini","antigravity","mcp_config.json"),configKey:"mcpServers",contextFile:{path:L.join(process.cwd(),".agents","rules","claude-mem-context.md"),isWorkspaceRelative:!0}},Ra={ideId:"crush",ideLabel:"Crush",configPath:L.join(ot(),".config","crush","mcp.json"),configKey:"mcpServers"},Pa={ideId:"roo-code",ideLabel:"Roo Code",configPath:L.join(process.cwd(),".roo","mcp.json"),configKey:"mcpServers",contextFile:{path:L.join(process.cwd(),".roo","rules","claude-mem-context.md"),isWorkspaceRelative:!0}},Oa={ideId:"warp",ideLabel:"Warp",configPath:L.join(ot(),".warp","mcp.json"),configKey:"mcpServers",contextFile:{path:L.join(process.cwd(),"WARP.md"),isWorkspaceRelative:!0}};ja={"copilot-cli":rt($a),antigravity:rt(Ta),goose:is,crush:rt(Ra),"roo-code":rt(Pa),warp:rt(Oa)}});var Wt={};Y(Wt,{runInstallCommand:()=>Za});import{execSync as Jr}from"child_process";import{cpSync as cs,existsSync as st,readFileSync as Ua,rmSync as ls}from"fs";import{join as Ae}from"path";async function Ga(t){if(ne)await ht(t);else for(let e of t){let r=await e.task(o=>console.log(` ${o}`));console.log(` ${r}`)}}function Wa(){let t=G(pe(),{});t.thedotmack={source:{source:"github",repo:"thedotmack/claude-mem"},installLocation:b(),lastUpdated:new Date().toISOString(),autoUpdate:!0},Re(ue()),Z(pe(),t)}function Ha(t){let e=G(me(),{});e.version||(e.version=2),e.plugins||(e.plugins={});let r=Xt(t),o=new Date().toISOString();e.plugins["claude-mem@thedotmack"]=[{scope:"user",installPath:r,version:t,installedAt:o,lastUpdated:o}],Z(me(),e)}function Ka(){let t=G(ge(),{});t.enabledPlugins||(t.enabledPlugins={}),t.enabledPlugins["claude-mem@thedotmack"]=!0,Z(ge(),t)}async function Ja(t){let e=[];for(let r of t)switch(r){case"claude-code":{try{Jr("claude plugin marketplace add thedotmack/claude-mem && claude plugin install claude-mem",{stdio:"inherit"}),f.success("Claude Code: plugin installed via CLI.")}catch(o){console.error("[install] Claude Code plugin install error:",o instanceof Error?o.message:String(o)),f.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(()=>(Je(),yo));await o("user")===0?s("user")===0?f.success("Cursor: hooks + MCP installed."):f.success("Cursor: hooks installed (MCP setup failed \u2014 run `npx claude-mem cursor mcp` to retry)."):(f.error("Cursor: hook installation failed."),e.push(r));break}case"gemini-cli":{let{installGeminiCliHooks:o}=await Promise.resolve().then(()=>(xr(),_r));await o()===0?f.success("Gemini CLI: hooks installed."):(f.error("Gemini CLI: hook installation failed."),e.push(r));break}case"opencode":{let{installOpenCodeIntegration:o}=await Promise.resolve().then(()=>($r(),Ir));await o()===0?f.success("OpenCode: plugin installed."):(f.error("OpenCode: plugin installation failed."),e.push(r));break}case"windsurf":{let{installWindsurfHooks:o}=await Promise.resolve().then(()=>(Or(),Pr));await o()===0?f.success("Windsurf: hooks installed."):(f.error("Windsurf: hook installation failed."),e.push(r));break}case"openclaw":{let{installOpenClawIntegration:o}=await Promise.resolve().then(()=>(jr(),Nr));await o()===0?f.success("OpenClaw: plugin installed."):(f.error("OpenClaw: plugin installation failed."),e.push(r));break}case"codex-cli":{let{installCodexCli:o}=await Promise.resolve().then(()=>(Kr(),Hr));await o()===0?f.success("Codex CLI: transcript watching configured."):(f.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(()=>(as(),us)),s=o[r];if(s){let i=await s(),c=Ue().find(d=>d.id===r)?.label??r;i===0?f.success(`${c}: MCP integration installed.`):(f.error(`${c}: MCP integration failed.`),e.push(r))}break}default:{let s=Ue().find(i=>i.id===r);s&&!s.supported&&f.warn(`Support for ${s.label} coming soon.`);break}}return e}async function Ya(){let e=Ue().filter(s=>s.detected);if(e.length===0)return f.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 In({message:"Which IDEs do you use?",options:r,initialValues:e.filter(s=>s.supported).map(s=>s.id),required:!0});return ee(o)&&(Ne("Installation cancelled."),process.exit(0)),o}function Va(){let t=b(),e=ct();Re(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=Ae(e,o),i=Ae(t,o);st(s)&&(st(i)&&ls(i,{recursive:!0,force:!0}),cs(s,i,{recursive:!0,force:!0}))}}function Xa(t){let e=zt(),r=Xt(t);ls(r,{recursive:!0,force:!0}),Re(r),cs(e,r,{recursive:!0,force:!0})}function za(){let t=b(),e=Ae(t,"package.json");st(e)&&Jr("npm install --production",{cwd:t,stdio:"pipe",encoding:"utf8",...z?{shell:process.env.ComSpec??"cmd.exe"}:{}})}function qa(){let t=Ae(b(),"plugin","scripts","smart-install.js");if(!st(t))return f.warn("smart-install.js not found \u2014 skipping Bun/uv auto-install."),!1;try{return Jr(`node "${t}"`,{stdio:"inherit",encoding:"utf8",...z?{shell:process.env.ComSpec??"cmd.exe"}:{}}),!0}catch(e){return console.warn("[install] smart-install error:",e instanceof Error?e.message:String(e)),f.warn("smart-install encountered an issue. You may need to install Bun/uv manually."),!1}}async function Za(t={}){let e=Te();ne?Et(h.default.bgCyan(h.default.black(" claude-mem install "))):console.log("claude-mem install"),f.info(`Version: ${h.default.cyan(e)}`),f.info(`Platform: ${process.platform} (${process.arch})`);let r=b();if(st(Ae(r,"plugin",".claude-plugin","plugin.json"))){try{let D=JSON.parse(Ua(Ae(r,"plugin",".claude-plugin","plugin.json"),"utf-8"));f.warn(`Existing installation detected (v${D.version??"unknown"}).`)}catch(D){console.warn("[install] Failed to read existing plugin version:",D instanceof Error?D.message:String(D)),f.warn("Existing installation detected.")}if(process.stdin.isTTY){let D=await Le({message:"Overwrite existing installation?",initialValue:!0});(ee(D)||!D)&&(Ne("Installation cancelled."),process.exit(0))}}let s;if(t.ide){s=[t.ide];let D=Ue(),E=D.find(v=>v.id===t.ide);E&&!E.supported&&(f.error(`Support for ${E.label} coming soon.`),process.exit(1)),E||(f.error(`Unknown IDE: ${t.ide}`),f.info(`Available IDEs: ${D.map(v=>v.id).join(", ")}`),process.exit(1))}else process.stdin.isTTY?s=await Ya():s=["claude-code"];s.some(D=>D!=="claude-code")&&await Ga([{title:"Copying plugin files",task:async D=>(D("Copying to marketplace directory..."),Va(),`Plugin files copied ${h.default.green("OK")}`)},{title:"Caching plugin version",task:async D=>(D(`Caching v${e}...`),Xa(e),`Plugin cached (v${e}) ${h.default.green("OK")}`)},{title:"Registering marketplace",task:async()=>(Wa(),`Marketplace registered ${h.default.green("OK")}`)},{title:"Registering plugin",task:async()=>(Ha(e),`Plugin registered ${h.default.green("OK")}`)},{title:"Enabling plugin in Claude settings",task:async()=>(Ka(),`Plugin enabled ${h.default.green("OK")}`)},{title:"Installing dependencies",task:async D=>{D("Running npm install...");try{return za(),`Dependencies installed ${h.default.green("OK")}`}catch(E){return console.warn("[install] npm install error:",E instanceof Error?E.message:String(E)),`Dependencies may need manual install ${h.default.yellow("!")}`}}},{title:"Setting up Bun and uv",task:async D=>(D("Running smart-install..."),qa()?`Runtime dependencies ready ${h.default.green("OK")}`:`Runtime setup may need attention ${h.default.yellow("!")}`)}]);let n=await Ja(s),u=n.length>0?"Installation Partial":"Installation Complete",c=[`Version: ${h.default.cyan(e)}`,`Plugin dir: ${h.default.cyan(r)}`,`IDEs: ${h.default.cyan(s.join(", "))}`];n.length>0&&c.push(`Failed: ${h.default.red(n.join(", "))}`),ne?Be(c.join(`
|
|
357
|
+
`),u):(console.log(`
|
|
358
|
+
${u}`),c.forEach(D=>console.log(` ${D}`)));let d=process.env.CLAUDE_MEM_WORKER_PORT||"37777",p=["Open Claude Code and start a conversation -- memory is automatic!",`View your memories: ${h.default.underline(`http://localhost:${d}`)}`,`Search past work: use ${h.default.bold("/mem-search")} in Claude Code`,`Start worker: ${h.default.bold("npx claude-mem start")}`];ne?(Be(p.join(`
|
|
359
|
+
`),"Next Steps"),n.length>0?ce(h.default.yellow("claude-mem installed with some IDE setup failures.")):ce(h.default.green("claude-mem installed successfully!"))):(console.log(`
|
|
360
|
+
Next Steps`),p.forEach(D=>console.log(` ${D}`)),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
|
-
`),"Note"),
|
|
372
|
-
${
|
|
373
|
-
|
|
374
|
-
${
|
|
375
|
-
${
|
|
376
|
-
${
|
|
377
|
-
${
|
|
378
|
-
${
|
|
379
|
-
${
|
|
380
|
-
${
|
|
381
|
-
|
|
382
|
-
${
|
|
383
|
-
${
|
|
384
|
-
${
|
|
385
|
-
${
|
|
386
|
-
${
|
|
387
|
-
${
|
|
388
|
-
${
|
|
389
|
-
${
|
|
390
|
-
|
|
391
|
-
${
|
|
362
|
+
claude-mem installed successfully!`))}var h,ne,f,Ht=m(()=>{"use strict";ar();h=ie(de(),1);ae();Ie();Rn();ne=process.stdin.isTTY===!0;f={info:t=>ne?M.info(t):console.log(` ${t}`),success:t=>ne?M.success(t):console.log(` ${t}`),warn:t=>ne?M.warn(t):console.warn(` ${t}`),error:t=>ne?M.error(t):console.error(` ${t}`)}});var ps={};Y(ps,{runUninstallCommand:()=>sc});import{existsSync as Ds,rmSync as ds}from"fs";import{join as Qa}from"path";function ec(){let t=b();return Ds(t)?(ds(t,{recursive:!0,force:!0}),!0):!1}function tc(){let t=Qa(ue(),"cache","thedotmack","claude-mem");return Ds(t)?(ds(t,{recursive:!0,force:!0}),!0):!1}function rc(){let t=G(pe(),{});t.thedotmack&&(delete t.thedotmack,Z(pe(),t))}function nc(){let t=G(me(),{});t.plugins?.["claude-mem@thedotmack"]&&(delete t.plugins["claude-mem@thedotmack"],Z(me(),t))}function oc(){let t=G(ge(),{});t.enabledPlugins?.["claude-mem@thedotmack"]!==void 0&&(delete t.enabledPlugins["claude-mem@thedotmack"],Z(ge(),t))}async function sc(){if(Et(j.default.bgRed(j.default.white(" claude-mem uninstall "))),lt()){if(process.stdin.isTTY){let r=await Le({message:"Are you sure you want to uninstall claude-mem?",initialValue:!1});if(ee(r)||!r){Ne("Uninstall cancelled.");return}}}else if(M.warn("claude-mem does not appear to be installed."),process.stdin.isTTY){let r=await Le({message:"Clean up any remaining registration data anyway?",initialValue:!1});if(ee(r)||!r){ce("Nothing to do.");return}}else{ce("Nothing to do.");return}let t=process.env.CLAUDE_MEM_WORKER_PORT||"37777";try{await fetch(`http://127.0.0.1:${t}/api/admin/shutdown`,{method:"POST",signal:AbortSignal.timeout(5e3)});for(let r=0;r<20;r++){await new Promise(o=>setTimeout(o,500));try{await fetch(`http://127.0.0.1:${t}/api/health`,{signal:AbortSignal.timeout(1e3)})}catch(o){console.error("[uninstall] Worker health check failed (worker stopped):",o instanceof Error?o.message:String(o));break}}M.info("Worker service stopped.")}catch{}await ht([{title:"Removing marketplace directory",task:async()=>ec()?`Marketplace directory removed ${j.default.green("OK")}`:`Marketplace directory not found ${j.default.dim("skipped")}`},{title:"Removing cache directory",task:async()=>tc()?`Cache directory removed ${j.default.green("OK")}`:`Cache directory not found ${j.default.dim("skipped")}`},{title:"Removing marketplace registration",task:async()=>(rc(),`Marketplace registration removed ${j.default.green("OK")}`)},{title:"Removing plugin registration",task:async()=>(nc(),`Plugin registration removed ${j.default.green("OK")}`)},{title:"Removing from Claude settings",task:async()=>(oc(),`Claude settings updated ${j.default.green("OK")}`)}]);let e=[{label:"Gemini CLI hooks",fn:async()=>{let{uninstallGeminiCliHooks:r}=await Promise.resolve().then(()=>(xr(),_r));return r()}},{label:"Windsurf hooks",fn:async()=>{let{uninstallWindsurfHooks:r}=await Promise.resolve().then(()=>(Or(),Pr));return r()}},{label:"OpenCode plugin",fn:async()=>{let{uninstallOpenCodePlugin:r}=await Promise.resolve().then(()=>($r(),Ir));return r()}},{label:"OpenClaw plugin",fn:async()=>{let{uninstallOpenClawPlugin:r}=await Promise.resolve().then(()=>(jr(),Nr));return r()}},{label:"Codex CLI",fn:async()=>{let{uninstallCodexCli:r}=await Promise.resolve().then(()=>(Kr(),Hr));return r()}}];for(let{label:r,fn:o}of e)try{await o()===0&&M.info(`${r}: removed.`)}catch(s){console.warn(`[uninstall] ${r} cleanup failed:`,s instanceof Error?s.message:String(s))}Be([`Your data directory at ${j.default.cyan("~/.claude-mem")} was preserved.`,"To remove it manually: rm -rf ~/.claude-mem"].join(`
|
|
363
|
+
`),"Note"),ce(j.default.green("claude-mem has been uninstalled."))}var j,ms=m(()=>{"use strict";ar();j=ie(de(),1);ae();Ie()});import{spawnSync as ic}from"child_process";import{existsSync as uc}from"fs";import{homedir as Yr}from"os";import{join as Vr}from"path";function ac(){return z?[Vr(Yr(),".bun","bin","bun.exe"),Vr(process.env.USERPROFILE||Yr(),".bun","bin","bun.exe")]:[Vr(Yr(),".bun","bin","bun"),"/usr/local/bin/bun","/opt/homebrew/bin/bun","/home/linuxbrew/.linuxbrew/bin/bun"]}function gs(){let e=ic(z?"where":"which",["bun"],{encoding:"utf-8",stdio:["pipe","pipe","pipe"],shell:z});if(e.status===0&&e.stdout.trim())return"bun";for(let r of ac())if(uc(r))return r;return null}var fs=m(()=>{"use strict";ae()});var oe={};Y(oe,{runAdoptCommand:()=>pc,runRestartCommand:()=>Dc,runSearchCommand:()=>mc,runStartCommand:()=>cc,runStatusCommand:()=>dc,runStopCommand:()=>lc,runTranscriptWatchCommand:()=>gc});import{spawn as Xr}from"child_process";import{existsSync as zr}from"fs";import{join as Cs}from"path";function Kt(){lt()||(console.error(x.default.red("claude-mem is not installed.")),console.error(`Run: ${x.default.bold("npx claude-mem install")}`),process.exit(1))}function qr(){let t=gs();return t||(console.error(x.default.red("Bun not found.")),console.error("Install Bun: https://bun.sh"),console.error("After installation, restart your terminal."),process.exit(1)),t}function Es(){return Cs(b(),"plugin","scripts","worker-service.cjs")}function it(t,e=[]){Kt();let r=qr(),o=Es();zr(o)||(console.error(x.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=Xr(r,s,{stdio:"inherit",cwd:b(),env:process.env});i.on("error",n=>{console.error(x.default.red(`Failed to start Bun: ${n.message}`)),process.exit(1)}),i.on("close",n=>{process.exit(n??0)})}function cc(){it("start")}function lc(){it("stop")}function Dc(){it("restart")}function dc(){it("status")}function pc(t=[]){Kt();let e=qr(),r=Es();zr(r)||(console.error(x.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=Xr(e,s,{stdio:"inherit",cwd:b(),env:process.env});i.on("error",n=>{console.error(x.default.red(`Failed to start Bun: ${n.message}`)),process.exit(1)}),i.on("close",n=>{process.exit(n??0)})}async function mc(t){Kt();let e=t.join(" ").trim();e||(console.error(x.default.red("Usage: npx claude-mem search <query>")),process.exit(1));let o=`http://127.0.0.1:${process.env.CLAUDE_MEM_WORKER_PORT||"37777"}/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(x.default.red("Worker is not running.")),console.error(`Start it with: ${x.default.bold("npx claude-mem start")}`),process.exit(1)),console.error(x.default.red(`Search failed: ${u}`)),process.exit(1)}s.ok||(s.status===404&&(console.error(x.default.red("Search endpoint not found. Is the worker running?")),console.error(`Try: ${x.default.bold("npx claude-mem start")}`),process.exit(1)),console.error(x.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(x.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 gc(){Kt();let t=qr(),e=Cs(b(),"plugin","scripts","transcript-watcher.cjs");if(!zr(e)){it("transcript",["watch"]);return}let r=Xr(t,[e,"watch"],{stdio:"inherit",cwd:b(),env:process.env});r.on("error",o=>{console.error(x.default.red(`Failed to start transcript watcher: ${o.message}`)),process.exit(1)}),r.on("close",o=>{process.exit(o??0)})}var x,se=m(()=>{"use strict";x=ie(de(),1);fs();ae()});var F=ie(de(),1);ae();var be=process.argv.slice(2),hs=be[0]?.toLowerCase()??"";function fc(){let t=Te();console.log(`
|
|
364
|
+
${F.default.bold("claude-mem")} v${t} \u2014 persistent memory for AI coding assistants
|
|
365
|
+
|
|
366
|
+
${F.default.bold("Install Commands")} (no Bun required):
|
|
367
|
+
${F.default.cyan("npx claude-mem")} Interactive install
|
|
368
|
+
${F.default.cyan("npx claude-mem install")} Interactive install
|
|
369
|
+
${F.default.cyan("npx claude-mem install --ide <id>")} Install for specific IDE
|
|
370
|
+
${F.default.cyan("npx claude-mem update")} Update to latest version
|
|
371
|
+
${F.default.cyan("npx claude-mem uninstall")} Remove plugin and configs
|
|
372
|
+
${F.default.cyan("npx claude-mem version")} Print version
|
|
373
|
+
|
|
374
|
+
${F.default.bold("Runtime Commands")} (requires Bun, delegates to installed plugin):
|
|
375
|
+
${F.default.cyan("npx claude-mem start")} Start worker service
|
|
376
|
+
${F.default.cyan("npx claude-mem stop")} Stop worker service
|
|
377
|
+
${F.default.cyan("npx claude-mem restart")} Restart worker service
|
|
378
|
+
${F.default.cyan("npx claude-mem status")} Show worker status
|
|
379
|
+
${F.default.cyan("npx claude-mem search <query>")} Search observations
|
|
380
|
+
${F.default.cyan("npx claude-mem adopt [--dry-run] [--branch <name>]")} Stamp merged worktrees into parent project
|
|
381
|
+
${F.default.cyan("npx claude-mem transcript watch")} Start transcript watcher
|
|
382
|
+
|
|
383
|
+
${F.default.bold("IDE Identifiers")}:
|
|
392
384
|
claude-code, cursor, gemini-cli, opencode, openclaw,
|
|
393
385
|
windsurf, codex-cli, copilot-cli, antigravity, goose,
|
|
394
386
|
crush, roo-code, warp
|
|
395
|
-
`)}async function
|
|
387
|
+
`)}async function Cc(){switch(hs){case"":{let{runInstallCommand:t}=await Promise.resolve().then(()=>(Ht(),Wt));await t();break}case"install":{let t=be.indexOf("--ide"),e=t!==-1?be[t+1]:void 0,{runInstallCommand:r}=await Promise.resolve().then(()=>(Ht(),Wt));await r({ide:e});break}case"update":case"upgrade":{let{runInstallCommand:t}=await Promise.resolve().then(()=>(Ht(),Wt));await t();break}case"uninstall":case"remove":{let{runUninstallCommand:t}=await Promise.resolve().then(()=>(ms(),ps));await t();break}case"version":case"--version":case"-v":{console.log(Te());break}case"help":case"--help":case"-h":{fc();break}case"start":{let{runStartCommand:t}=await Promise.resolve().then(()=>(se(),oe));t();break}case"stop":{let{runStopCommand:t}=await Promise.resolve().then(()=>(se(),oe));t();break}case"restart":{let{runRestartCommand:t}=await Promise.resolve().then(()=>(se(),oe));t();break}case"status":{let{runStatusCommand:t}=await Promise.resolve().then(()=>(se(),oe));t();break}case"search":{let{runSearchCommand:t}=await Promise.resolve().then(()=>(se(),oe));await t(be.slice(1));break}case"adopt":{let{runAdoptCommand:t}=await Promise.resolve().then(()=>(se(),oe));t(be.slice(1));break}case"transcript":{let t=be[1]?.toLowerCase();if(t==="watch"){let{runTranscriptWatchCommand:e}=await Promise.resolve().then(()=>(se(),oe));e()}else console.error(F.default.red(`Unknown transcript subcommand: ${t??"(none)"}`)),console.error("Usage: npx claude-mem transcript watch"),process.exit(1);break}default:console.error(F.default.red(`Unknown command: ${hs}`)),console.error(`Run ${F.default.bold("npx claude-mem --help")} for usage information.`),process.exit(1)}}Cc().catch(t=>{console.error(F.default.red("Fatal error:"),t.message||t),process.exit(1)});
|