minnimemory 1.3.2 → 1.3.4
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/CHANGELOG.md +17 -0
- package/README.md +15 -0
- package/package.json +1 -1
- package/pkg/chunks/{chunk-4FYIFKN4.js → chunk-6KBBT7IM.js} +21 -21
- package/pkg/chunks/{chunk-KTZV7XLL.js → chunk-AQ6QWAHT.js} +44 -44
- package/pkg/chunks/mcpServer-5J4HOZCC.js +2 -0
- package/pkg/cli.js +15 -15
- package/pkg/index.js +1 -1
- package/pkg/chunks/mcpServer-BY6AO25X.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* MinniMemoryMCP (c) 2026 MinniAI. Licensed under the MinniMemoryMCP License, see LICENSE. */
|
|
2
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q}from"./chunk-6KBBT7IM.js";import"./chunk-AQ6QWAHT.js";export{m as BASIC_PROMPTS,d as BASIC_READ_TOOLS,e as BASIC_WRITE_TOOLS,q as CONTENT_CAP_CHARS,i as DATA_CLOSE_LINE,h as DATA_OPEN_LINE,o as DISABLED_MESSAGE,j as MARKER_NOTE,a as SERVE_TOOLS,b as SETUP_TOOLS,c as WRITE_TOOLS,k as asData,p as createDisabledMcpServer,n as createMcpServer,g as dataClose,f as dataOpen,l as unwrapData};
|
package/pkg/cli.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/* MinniMemoryMCP (c) 2026 MinniAI. Licensed under the MinniMemoryMCP License, see LICENSE. */
|
|
3
|
-
import{$ as We,$a as dt,A as Re,Aa as W,B as Pe,Ba as nt,E as De,F as Ae,G as E,Ga as rt,H as V,I as Ee,Ja as ot,K as Ie,L as D,M as X,N as Ne,O as Q,P as Fe,Q as Le,R as Be,Ra as st,S as He,Sa as it,Ta as oe,U as H,V as Ue,W as Je,Wa as at,X as _e,Ya as se,Za as ie,_a as ae,aa as Ge,ab as lt,b as P,ba as qe,bb as ut,ca as ze,cb as ct,da as Ye,db as pt,ea as Z,eb as de,fa as Ke,fb as le,g,ga as Ve,j as $e,la as Xe,n as xe,na as ee,o as Ce,p as Se,q as Oe,qa as U,r as Me,ra as te,s as Y,sa as J,t as K,ta as _,ua as ne,v as je,va as re,w as Te,wa as Qe,xa as Ze,ya as et,za as tt}from"./chunks/chunk-
|
|
4
|
-
one task description per line, # for comments`);return t}function G(e){return`${e.onDemandFile}:${e.startLine}`}function Nt(e){return`${e.onDemandFile} > ${e.heading}`}function Ft(e,n){let t=P(e).flatMap(o=>xe({name:o.name,file:o.file},Ee(n,o.file)));return Ce(t,new Map(P(e).map(o=>[o.name,o.triggers])))}function mt(e,n,t={}){let o=t.root?Ft(e,t.root):void 0,r=o?"section":"file",c=new Set,u=new Map,d=new Map,l=new Map;for(let i of P(e))u.set(i.name,i.tokens),d.set(i.name,i.name),l.set(i.name,i.name);if(o)for(let i of o.units)u.set(G(i),i.tokens),d.set(G(i),Nt(i)),l.set(G(i),i.onDemandFile);let y=[],v=0;n.forEach((i,h)=>{let C=o?Oe(Se(o,i)).map(f=>G(f.unit)):Me(e,i).filter(f=>f.score>0).map(f=>f.name);C.length===0&&v++;let $=C.filter(f=>!c.has(f));for(let f of $)c.add(f);let b=[...c].reduce((f,z)=>f+(u.get(z)??0),0);y.push({turn:h+1,task:i,opened:$.map(f=>d.get(f)??f),carried:[...c].map(f=>d.get(f)??f),compiledTokens:e.prefix.after+b,baselineTokens:e.prefix.before})});let w=y.reduce((i,h)=>i+h.compiledTokens,0),m=y.reduce((i,h)=>i+h.baselineTokens,0),k=new Set([...c].map(i=>l.get(i)??i)),
|
|
3
|
+
import{$ as We,$a as dt,A as Re,Aa as W,B as Pe,Ba as nt,E as De,F as Ae,G as E,Ga as rt,H as V,I as Ee,Ja as ot,K as Ie,L as D,M as X,N as Ne,O as Q,P as Fe,Q as Le,R as Be,Ra as st,S as He,Sa as it,Ta as oe,U as H,V as Ue,W as Je,Wa as at,X as _e,Ya as se,Za as ie,_a as ae,aa as Ge,ab as lt,b as P,ba as qe,bb as ut,ca as ze,cb as ct,da as Ye,db as pt,ea as Z,eb as de,fa as Ke,fb as le,g,ga as Ve,j as $e,la as Xe,n as xe,na as ee,o as Ce,p as Se,q as Oe,qa as U,r as Me,ra as te,s as Y,sa as J,t as K,ta as _,ua as ne,v as je,va as re,w as Te,wa as Qe,xa as Ze,ya as et,za as tt}from"./chunks/chunk-AQ6QWAHT.js";import{spawnSync as Xt}from"node:child_process";import S from"node:fs";import Qt from"node:os";import x from"node:path";import{fileURLToPath as Zt}from"node:url";import{parseArgs as en}from"node:util";import Et from"node:fs";function It(e){return e.split(/\r?\n/).map(n=>n.trim()).filter(n=>n!==""&&!n.startsWith("#"))}function ft(e){let n;try{n=Et.readFileSync(e,"utf8")}catch{throw new D(`cannot read workload file: ${e}`)}let t=It(n);if(t.length===0)throw new D(`workload file has no tasks: ${e}
|
|
4
|
+
one task description per line, # for comments`);return t}function G(e){return`${e.onDemandFile}:${e.startLine}`}function Nt(e){return`${e.onDemandFile} > ${e.heading}`}function Ft(e,n){let t=P(e).flatMap(o=>xe({name:o.name,file:o.file},Ee(n,o.file)));return Ce(t,new Map(P(e).map(o=>[o.name,o.triggers])))}function mt(e,n,t={}){let o=t.root?Ft(e,t.root):void 0,r=o?"section":"file",c=new Set,u=new Map,d=new Map,l=new Map;for(let i of P(e))u.set(i.name,i.tokens),d.set(i.name,i.name),l.set(i.name,i.name);if(o)for(let i of o.units)u.set(G(i),i.tokens),d.set(G(i),Nt(i)),l.set(G(i),i.onDemandFile);let y=[],v=0;n.forEach((i,h)=>{let C=o?Oe(Se(o,i)).map(f=>G(f.unit)):Me(e,i).filter(f=>f.score>0).map(f=>f.name);C.length===0&&v++;let $=C.filter(f=>!c.has(f));for(let f of $)c.add(f);let b=[...c].reduce((f,z)=>f+(u.get(z)??0),0);y.push({turn:h+1,task:i,opened:$.map(f=>d.get(f)??f),carried:[...c].map(f=>d.get(f)??f),compiledTokens:e.prefix.after+b,baselineTokens:e.prefix.before})});let w=y.reduce((i,h)=>i+h.compiledTokens,0),m=y.reduce((i,h)=>i+h.baselineTokens,0),k=new Set([...c].map(i=>l.get(i)??i)),j=P(e).map(i=>i.name).filter(i=>k.has(i)),R=[...c].reduce((i,h)=>i+(u.get(h)??0),0),A=e.prefix.after+R,s=e.prefix.before-A,a=m-w,p;return a>=0?(p=y.findIndex((i,h)=>y.slice(0,h+1).reduce(($,b)=>$+b.baselineTokens-b.compiledTokens,0)>=0),p=p>=0?p+1:void 0):s>0&&(p=y.length+Math.ceil(-a/s)),{unit:r,turns:y,baselineTotal:m,compiledTotal:w,saving:a,savingPct:m===0?0:a/m*100,onDemandOpened:j,onDemandNeverOpened:P(e).map(i=>i.name).filter(i=>!k.has(i)),unroutedTurns:v,steadyStatePerTurn:A,steadyStateGainPerTurn:s,breakEvenTurn:p}}function Lt(e,n){return n===0?"0.0%":`${(e/n*100).toFixed(1)}%`}function ue(e){return e>=0?`saves ${g(e)}`:`costs ${g(-e)} more`}function ce(e,n){let t=[""];return t.push(` exact, over ${g(e.turns)} turns. No workload, no assumptions.`),t.push(""),t.push(` original memory file ${g(e.baselinePerTurn).padStart(8)} tokens per turn`),t.push(` compiled always-loaded ${g(e.compiledPerTurn).padStart(8)} tokens per turn`),t.push(` OnDemandMemory, all of it ${g(e.totalOnDemandTokens).padStart(8)} tokens, on demand`),t.push(""),t.push(" best case, no OnDemandMemory file ever opened"),t.push(` ${g(e.baselineTotal)} -> ${g(e.bestCaseTotal)} tokens, ${ue(e.bestCaseSaving)} (${Lt(e.bestCaseSaving,e.baselineTotal)})`),t.push(""),t.push(" worst case, every OnDemandMemory file opened on turn 1 and carried"),t.push(` ${g(e.baselineTotal)} -> ${g(e.worstCaseTotal)} tokens, ${ue(e.worstCaseSaving)}`),t.push(""),t.push(` break-even: ${g(e.breakEvenCarriedTokens)} tokens of OnDemandMemory can sit in`),t.push(" context from turn 1 to the end and come out even. Past that the compiled"),t.push(" shape costs more than the file it replaced."),t.push(""),t.push(` tokenizer: ${n}, an offline estimate`),t.push(""),t.join(`
|
|
5
5
|
`)}function ht(e,n){let t=[""],o=e.turns.length;if(t.push(` MODEL, not a measurement. ${g(o)} turns from the workload you supplied.`),t.push(e.unit==="section"?" routed at section level, as recall() does: a hit carries the section, not the file.":" routed at file level, as an agent reading a whole file the OnDemandMemory list named would."),t.push(""),t.push(` memory tokens over the session ${g(e.baselineTotal)} -> ${g(e.compiledTotal)}`),t.push(` ${ue(e.saving)}${e.saving>=0?` (${e.savingPct.toFixed(1)}%)`:""}`),t.push(""),e.onDemandOpened.length>0){t.push(` opened and carried (${e.onDemandOpened.length}):`);for(let r of e.onDemandOpened)t.push(` ${r}`);t.push("")}if(e.onDemandNeverOpened.length>0){t.push(` never opened (${e.onDemandNeverOpened.length}) - this is where the saving comes from:`);for(let r of e.onDemandNeverOpened)t.push(` ${r}`);t.push("")}return t.push(" one more turn, once everything this workload opens is in context:"),t.push(` ${g(e.steadyStatePerTurn)} vs ${g(e.turns[0]?.baselineTokens??0)} baseline, ${e.steadyStateGainPerTurn>=0?`saves ${g(e.steadyStateGainPerTurn)}`:`costs ${g(-e.steadyStateGainPerTurn)} more`} per turn`),t.push(""),e.saving<0&&e.steadyStateGainPerTurn<=0?(t.push(" this workload never breaks even. The OnDemandMemory files it opens are large enough that"),t.push(" carrying them costs more every turn than the original file did, so a longer"),t.push(" session loses more, not less. Splitting differently, or not compiling this"),t.push(" file at all, is the honest answer here."),t.push("")):e.saving<0&&e.breakEvenTurn!==void 0?(t.push(` behind by ${g(-e.saving)} at turn ${g(e.turns.length)}, recovering ${g(e.steadyStateGainPerTurn)} per turn:`),t.push(` breaks even around turn ${g(e.breakEvenTurn)} if nothing further opens.`),t.push("")):e.saving>=0&&e.breakEvenTurn!==void 0&&(t.push(` ahead from turn ${g(e.breakEvenTurn)} onward.`),t.push("")),e.unroutedTurns>0&&(t.push(` ${g(e.unroutedTurns)} of ${g(o)} turns matched no OnDemandMemory file at all.`),t.push(" Those turns are cheap here, but a real agent may have needed something and"),t.push(" not been routed to it. Check them before trusting the total."),t.push("")),t.push(" what this number is conditional on:"),t.push(" - your workload being what a real session looks like. It is your file;"),t.push(" the tool cannot tell whether it is representative."),e.unit==="section"?(t.push(" - every section recall() returns being carried for the rest of the session,"),t.push(" up to its token cap per turn. A real agent may widen with outline() or"),t.push(" read the whole file anyway.")):(t.push(" - every OnDemandMemory file whose triggers match being opened in full. A real"),t.push(" agent may read one and stop, or ignore one the list offered.")),t.push(" - memory tokens only. Reasoning, tool results and conversation are excluded"),t.push(" from both sides, so this ratio is not a session bill."),t.push(""),t.push(" For observed usage against a live agent, measure a real multi-turn session with"),t.push(" and without the compile. That is the only path allowed to call a number measured."),t.push(""),t.push(` tokenizer: ${n}, an offline estimate`),t.push(""),t.join(`
|
|
6
6
|
`)}function gt(){return[""," No workload given, so only the exact bounds above are available.",""," A session number needs a workload: a file with one task description per line,"," describing what you actually do in this repo.",""," minnimemory bench --workload tasks.txt",""," minnimemory ships no default task list on purpose. A number produced from tasks"," the tool invented for itself would say more about the tool than about your repo.",""].join(`
|
|
7
|
-
`)}import O from"node:fs";import
|
|
8
|
-
${e}`:e);return n.servedDirect?c.includes(t(n.servedDirect)):c.includes("npx -y minnimemory mcp")}function Wt(e){let n=/Scope:\s*(User|Project|Local)\b/i.exec(e);return n?n[1].toLowerCase():void 0}function he(e,n){let t=/^node "([^"]+)" (drift|loaded|hook)$/.exec(e);if(t===null||t[2]!==n)return!1;let o=t[1];return/minnimemory/i.test(o)||Gt(o)}function Gt(e){let n=
|
|
7
|
+
`)}import O from"node:fs";import M from"node:path";function I(e){let n=Te(e);return n&&Re(n)?n:void 0}function kt(e){return Pe(e)??`"${e.replace(/"/g,'\\"')}"`}function T(e){return e.map(kt).join(" ")}function vt(e){return e.map(kt)}function yt(e){if(!(!e.servedDirect||!/\/_npx\//.test(e.servedDirect)))return"note: this copy lives in the npx cache, which `npm cache clean` or a newer version can remove; the registration and the hook would then stop starting. For a durable install: npm i -g minnimemory, then minnimemory install --force"}function Bt(e){if(e==="cursor")return"~/.cursor/mcp.json";if(e==="windsurf")return"~/.codeium/windsurf/mcp_config.json"}function bt(e,n){let t=[];e.write&&t.push("--profile","full","--allow-write");let o=I(e.cliPath),r=o?["node",o,"mcp",...t]:["npx","-y","minnimemory","mcp",...t],c=["claude","mcp","add","minnimemory","-s",e.scope,"--",...r],u=["claude","mcp","remove","minnimemory","-s",e.scope],d=["claude","mcp","get","minnimemory"],l=["claude","--version"],y=T(c),v=JSON.stringify({mcpServers:{minnimemory:{command:"npx",args:["-y","minnimemory","mcp",...t]}}},null,2),w={scope:e.scope,servedFlags:t,servedArgv:r,...o?{servedDirect:o}:{},addArgv:c,removeArgv:u,getArgv:d,probeArgv:l,manualLine:y,jsonSnippet:v};if(e.host&&e.host!=="json"){let m=Bt(e.host);m&&(w.hostConfigPath=m)}return w}function $t(e){return e.error!==void 0&&e.error.code==="ENOENT"}var fe="npx -y minnimemory drift";function Ht(e){let n=I(e);return n?`node "${n}" drift`:fe}var me="npx -y minnimemory hook";function Ut(e){let n=I(e);return n?`node "${n}" hook`:me}function Jt(e){return typeof e=="string"&&(e===me||he(e,"hook"))}function _t(e,n){let t=u=>u.replace(/\\/g,"/").toLowerCase(),o=/^\s*Command:\s*(.*)$/m.exec(e)?.[1]?.trim(),r=/^\s*Args:\s*(.*)$/m.exec(e)?.[1]?.trim(),c=t(o?`${o} ${r??""}
|
|
8
|
+
${e}`:e);return n.servedDirect?c.includes(t(n.servedDirect)):c.includes("npx -y minnimemory mcp")}function Wt(e){let n=/Scope:\s*(User|Project|Local)\b/i.exec(e);return n?n[1].toLowerCase():void 0}function he(e,n){let t=/^node "([^"]+)" (drift|loaded|hook)$/.exec(e);if(t===null||t[2]!==n)return!1;let o=t[1];return/minnimemory/i.test(o)||Gt(o)}function Gt(e){if(!M.isAbsolute(e))return!1;let n=M.dirname(e);for(let t=0;t<4;t++)try{return JSON.parse(O.readFileSync(M.join(n,"package.json"),"utf8")).name==="minnimemory"}catch{let o=M.dirname(n);if(o===n)return!1;n=o}return!1}function qt(e){return typeof e=="string"&&(e===fe||he(e,"drift"))}var ge="npx -y minnimemory loaded";function zt(e){let n=I(e);return n?`node "${n}" loaded`:ge}function Yt(e){return typeof e=="string"&&(e===ge||he(e,"loaded"))}function xt(e){let n=Ht(e),t=Ut(e),o=zt(e);return[{event:"UserPromptSubmit",command:n,fallback:fe,isOurs:r=>r===n||qt(r)},{event:"UserPromptSubmit",command:t,fallback:me,isOurs:r=>r===t||Jt(r)},{event:"InstructionsLoaded",command:o,fallback:ge,isOurs:r=>r===o||Yt(r)}]}function Ct(e,n){let t=n.cwd??process.cwd();return e==="user"?M.join(n.configDir??M.join(n.home,".claude"),"settings.json"):e==="project"?M.join(t,".claude","settings.json"):M.join(t,".claude","settings.local.json")}function St(e,n){let t=[];for(let o of e){if(!o||typeof o!="object")continue;let r=o.hooks;if(Array.isArray(r))for(let c of r){let u=c&&typeof c=="object"?c.command:void 0;n(u)&&t.push(u)}}return t}function Ot(e){if(!O.existsSync(e))return{};try{let n=JSON.parse(O.readFileSync(e,"utf8"));return!n||typeof n!="object"||Array.isArray(n)?void 0:n}catch{return}}function Mt(e,n){let t=`${JSON.stringify(n,null,2)}
|
|
9
9
|
`,o=`${e}.minnimemory-${process.pid}.tmp`;O.writeFileSync(o,t,"utf8");try{O.renameSync(o,e)}catch{O.rmSync(o,{force:!0}),O.writeFileSync(e,t,"utf8")}}function jt(e){let n=e.hooks;return n&&typeof n=="object"&&!Array.isArray(n)?n:void 0}function Kt(e,n){let t=Ct(e.scope,n),o=xt(e.cliPath);if(e.dryRun)return{exitCode:0,output:o.map(l=>`would add the ${l.event} hook \`${l.command}\` to ${t}`).join(`
|
|
10
|
-
`),path:t};let r=Ot(t);if(!r)return{exitCode:1,output:`install --hook: ${t} is not valid JSON; not touched.`,path:t};let c=jt(r)??{},u=[],d=!1;for(let l of o){let y=Array.isArray(c[l.event])?[...c[l.event]]:[],v=St(y,l.isOurs);if(v.includes(l.command)){u.push(l.event==="UserPromptSubmit"?`hook: \`${l.fallback.split(" ").pop()}\` already present in ${t}`:`hook: ${l.event} already present in ${t}`);continue}if(v.length>0){for(let w of y){let m=w&&typeof w=="object"?w.hooks:void 0;if(Array.isArray(m))for(let k of m)k&&typeof k=="object"&&l.isOurs(k.command)&&(k.command=l.command)}u.push(`hook: updated \`${v[0]}\` -> \`${l.command}\` in ${t} (${l.event}). Restart Claude Code.`)}else{let w={hooks:[{type:"command",command:l.command}]};y.push(w),u.push(`hook: added \`${l.command}\` to ${t} (${l.event}). Restart Claude Code.`)}c[l.event]=y,d=!0}return d&&(r.hooks=c,O.mkdirSync(
|
|
10
|
+
`),path:t};let r=Ot(t);if(!r)return{exitCode:1,output:`install --hook: ${t} is not valid JSON; not touched.`,path:t};let c=jt(r)??{},u=[],d=!1;for(let l of o){let y=Array.isArray(c[l.event])?[...c[l.event]]:[],v=St(y,l.isOurs);if(v.includes(l.command)){u.push(l.event==="UserPromptSubmit"?`hook: \`${l.fallback.split(" ").pop()}\` already present in ${t}`:`hook: ${l.event} already present in ${t}`);continue}if(v.length>0){for(let w of y){let m=w&&typeof w=="object"?w.hooks:void 0;if(Array.isArray(m))for(let k of m)k&&typeof k=="object"&&l.isOurs(k.command)&&(k.command=l.command)}u.push(`hook: updated \`${v[0]}\` -> \`${l.command}\` in ${t} (${l.event}). Restart Claude Code.`)}else{let w={hooks:[{type:"command",command:l.command}]};y.push(w),u.push(`hook: added \`${l.command}\` to ${t} (${l.event}). Restart Claude Code.`)}c[l.event]=y,d=!0}return d&&(r.hooks=c,O.mkdirSync(M.dirname(t),{recursive:!0}),Mt(t,r)),{exitCode:0,output:u.join(`
|
|
11
11
|
`),path:t}}function wt(e,n){let t=Ct(e.scope,n),o=xt(e.cliPath);if(e.dryRun)return{exitCode:0,output:o.map(d=>`would remove the ${d.event} hook (\`${d.fallback}\` or its direct node form) from ${t}`).join(`
|
|
12
|
-
`),path:t};if(!O.existsSync(t))return{exitCode:0,output:`hook: nothing to remove (${t} does not exist)`,path:t};let r=Ot(t);if(!r)return{exitCode:1,output:`install --remove: ${t} is not valid JSON; not touched.`,path:t};let c=jt(r),u=[];for(let d of o){let l=c&&Array.isArray(c[d.event])?c[d.event]:void 0,y=l?St(l,d.isOurs):[];if(!c||!l||y.length===0)continue;let v=l.filter(w=>{if(!w||typeof w!="object")return!0;let m=w.hooks;if(!Array.isArray(m))return!0;let k=m.filter(
|
|
13
|
-
`),path:t})}function Tt(e,n,t){let o=bt(e,n),r=[];if(e.dryRun){r.push(`would run: ${
|
|
12
|
+
`),path:t};if(!O.existsSync(t))return{exitCode:0,output:`hook: nothing to remove (${t} does not exist)`,path:t};let r=Ot(t);if(!r)return{exitCode:1,output:`install --remove: ${t} is not valid JSON; not touched.`,path:t};let c=jt(r),u=[];for(let d of o){let l=c&&Array.isArray(c[d.event])?c[d.event]:void 0,y=l?St(l,d.isOurs):[];if(!c||!l||y.length===0)continue;let v=l.filter(w=>{if(!w||typeof w!="object")return!0;let m=w.hooks;if(!Array.isArray(m))return!0;let k=m.filter(j=>!(j&&typeof j=="object"&&d.isOurs(j.command)));return k.length===0?!1:(w.hooks=k,!0)});v.length===0?delete c[d.event]:c[d.event]=v,u.push(`hook: removed \`${y[0]}\` from ${t}`)}return u.length===0?{exitCode:0,output:`hook: nothing to remove in ${t}`,path:t}:(c&&Object.keys(c).length===0&&delete r.hooks,Mt(t,r),{exitCode:0,output:u.join(`
|
|
13
|
+
`),path:t})}function Tt(e,n,t){let o=bt(e,n),r=[];if(e.dryRun){r.push(`would run: ${T(o.removeArgv)}`);let l=wt({...e,dryRun:!0},n);return r.push(l.output),{exitCode:0,output:`${r.join(`
|
|
14
14
|
`)}
|
|
15
|
-
`}}let c=t(o.probeArgv[0],o.probeArgv.slice(1)),u=0;if($t(c))r.push("the claude CLI is not on PATH; skipping the MCP registration removal.");else{let l=t(o.removeArgv[0],o.removeArgv.slice(1));r.push(`ran: ${
|
|
15
|
+
`}}let c=t(o.probeArgv[0],o.probeArgv.slice(1)),u=0;if($t(c))r.push("the claude CLI is not on PATH; skipping the MCP registration removal.");else{let l=t(o.removeArgv[0],o.removeArgv.slice(1));r.push(`ran: ${T(o.removeArgv)}`),l.code!==0&&/no mcp server named/i.test(`${l.stdout}
|
|
16
16
|
${l.stderr}`)?r.push(`nothing registered as minnimemory in ${e.scope} scope`):l.code!==0?(r.push(l.stderr.trim()),u=1):l.stdout.trim()&&r.push(l.stdout.trim())}let d=wt(e,n);return r.push(d.output),d.exitCode!==0&&(u=d.exitCode),{exitCode:u,output:`${r.join(`
|
|
17
17
|
`)}
|
|
18
18
|
`}}function Vt(e){let n=I(e);return`next: restart Claude Code, then ask it to clean up your memory with minnimemory; it starts with init. In a terminal: \`${n?`node "${n}" init`:"npx -y minnimemory init"} <folder> --from-log\` from your project.`}function pe(e,n,t,o){if(e.hook){let r=Kt(e,n);t.push(r.output),r.exitCode!==0&&(o=r.exitCode)}return o===0&&t.push(Vt(e.cliPath)),{exitCode:o,output:`${t.join(`
|
|
@@ -20,11 +20,11 @@ ${l.stderr}`)?r.push(`nothing registered as minnimemory in ${e.scope} scope`):l.
|
|
|
20
20
|
`}}function Rt(e,n,t){let o=bt(e,n),r=[];if(e.hook&&e.host)return{exitCode:2,output:`--hook only applies to Claude Code
|
|
21
21
|
`};if(e.host)return r.push(o.jsonSnippet),o.hostConfigPath?r.push("",`config file: ${o.hostConfigPath}`):r.push("",`add this under "mcpServers" in your host's MCP config file.`),{exitCode:0,output:`${r.join(`
|
|
22
22
|
`)}
|
|
23
|
-
`};if(e.dryRun){e.force&&r.push(`would run: ${
|
|
23
|
+
`};if(e.dryRun){e.force&&r.push(`would run: ${T(o.removeArgv)}`),r.push(`would run: ${T(o.addArgv)}`);let k=yt(o);return k&&r.push(k),pe(e,n,r,0)}let c=t(o.probeArgv[0],o.probeArgv.slice(1));if($t(c))return r.push("the claude CLI is not on PATH. Register minnimemory manually:","",` ${o.manualLine}`,"","or add this to another host's MCP config:","",o.jsonSnippet),{exitCode:2,output:`${r.join(`
|
|
24
24
|
`)}
|
|
25
|
-
`};let u=t(o.getArgv[0],o.getArgv.slice(1)),d=u.code===0?Wt(u.stdout):void 0,l=d!==void 0&&d!==e.scope;l&&r.push(`minnimemory is also registered at ${d} scope; that registration is left as it is (Claude Code uses local, then project, then user).`);let y=u.code===0&&!l,v=y&&!_t(u.stdout,o);if(y&&!e.force&&!v)return r.push("minnimemory is already registered.",`to change it: ${
|
|
25
|
+
`};let u=t(o.getArgv[0],o.getArgv.slice(1)),d=u.code===0?Wt(u.stdout):void 0,l=d!==void 0&&d!==e.scope;l&&r.push(`minnimemory is also registered at ${d} scope; that registration is left as it is (Claude Code uses local, then project, then user).`);let y=u.code===0&&!l,v=y&&!_t(u.stdout,o);if(y&&!e.force&&!v)return r.push("minnimemory is already registered.",`to change it: ${T(["npx","-y","minnimemory","install","--force","--scope",e.scope,...e.write?["--write"]:[]])}`),pe(e,n,r,0);if(y){v&&!e.force&&r.push("minnimemory is registered with a different command; repointing it at this copy.");let k=t(o.removeArgv[0],o.removeArgv.slice(1));if(k.code!==0)return r.push(`ran: ${T(o.removeArgv)}`,k.stderr.trim()),{exitCode:1,output:`${r.join(`
|
|
26
26
|
`)}
|
|
27
|
-
`}}let w=t(o.addArgv[0],o.addArgv.slice(1));if(r.push(`ran: ${
|
|
27
|
+
`}}let w=t(o.addArgv[0],o.addArgv.slice(1));if(r.push(`ran: ${T(o.addArgv)}`),w.code!==0)return r.push(w.stderr.trim()),{exitCode:1,output:`${r.join(`
|
|
28
28
|
`)}
|
|
29
29
|
`};w.stdout.trim()&&r.push(w.stdout.trim());let m=yt(o);return m&&r.push(m),pe(e,n,r,0)}var tn=!1,q=`
|
|
30
30
|
minnimemory ${le} the agent memory compiler
|
|
@@ -215,7 +215,7 @@ ${t.content}`).join(`
|
|
|
215
215
|
`),2)}let o=n.profile??"basic";return o!=="basic"&&o!=="full"?(process.stderr.write(`
|
|
216
216
|
error: --profile must be one of basic, full (got "${o}")
|
|
217
217
|
|
|
218
|
-
`),2):((async()=>{let[{StdioServerTransport:r},{createMcpServer:c}]=await Promise.all([import("@modelcontextprotocol/sdk/server/stdio.js"),import("./chunks/mcpServer-
|
|
218
|
+
`),2):((async()=>{let[{StdioServerTransport:r},{createMcpServer:c}]=await Promise.all([import("@modelcontextprotocol/sdk/server/stdio.js"),import("./chunks/mcpServer-5J4HOZCC.js")]);await c(t,{profile:o,allowWrite:n["allow-write"]===!0}).connect(new r)})().catch(r=>{process.stderr.write(`
|
|
219
219
|
mcp server failed: ${r.message??String(r)}
|
|
220
220
|
`),process.exitCode=1}),0)}function un(){let e=tt(),n=[];if(e.length>0){n.push("still compiled (they keep working without minnimemory; to put the originals back, undo each one):");for(let t of e)n.push(` ${De(t)}`)}return n.push(`kept: ${x.dirname(Ze())} (init records, the load log, undo backups); delete it yourself once you have checked undo-backups/.`),n.push("restart Claude Code."),n.join(`
|
|
221
221
|
`)}var cn=new Set(["init","doctor","apply","undo","bench"]);function pn(e){if(W(process.cwd()))return!0;let n=ye(e);return te(n)==="compiled"||re(n)!==void 0||Q(n)!==void 0}function ye(e){let n=x.resolve(e);return S.existsSync(n)&&S.statSync(n).isFile()?x.dirname(n):n}function fn(e){if(W(process.cwd()))return;let n=ye(e);return Q(n)?Ne(n):void 0}function mn(e){let n=`minnimemory ${e} <folder>`;if(process.stdin.isTTY!==!0){process.stderr.write(`
|
|
@@ -241,8 +241,8 @@ ${q}`),2}let{values:t,positionals:o}=n;if(t.help)return process.stdout.write(q),
|
|
|
241
241
|
`),2;let l=t.diff,y=[...t.loaded??[],...t["host-file"]??[]].map(s=>J(s));if(t["from-log"]===!0){let s=dt(process.cwd());if(!s)return process.stderr.write(`
|
|
242
242
|
error: no load log for ${process.cwd()}: open Claude Code in this folder once (install adds the hook that writes it), then run this again
|
|
243
243
|
|
|
244
|
-
`),2;for(let a of Object.keys(s.files))/\.md$/i.test(a)&&S.existsSync(a)&&y.push(x.resolve(a))}let v=typeof t["memory-dir"]=="string"?J(t["memory-dir"]):void 0,m=y.length>0||v!==void 0||t["only-this-folder"]===!0?{files:[...new Set(y)],...v?{memoryDir:v}:{},source:t["from-log"]===!0&&(t.loaded??[]).length===0?"log":"terminal",...t["only-this-folder"]===!0?{onlyThisFolder:!0}:{}}:void 0,k=m||!["doctor","apply"].includes(r)?void 0:fn(d),
|
|
245
|
-
`);let R={cwd:process.cwd(),...m?{reported:m}:
|
|
244
|
+
`),2;for(let a of Object.keys(s.files))/\.md$/i.test(a)&&S.existsSync(a)&&y.push(x.resolve(a))}let v=typeof t["memory-dir"]=="string"?J(t["memory-dir"]):void 0,m=y.length>0||v!==void 0||t["only-this-folder"]===!0?{files:[...new Set(y)],...v?{memoryDir:v}:{},source:t["from-log"]===!0&&(t.loaded??[]).length===0?"log":"terminal",...t["only-this-folder"]===!0?{onlyThisFolder:!0}:{}}:void 0,k=m||!["doctor","apply"].includes(r)?void 0:fn(d),j=m?void 0:nt(process.cwd())??(k?Fe(ye(d)):void 0);k&&process.stderr.write(` note: this machine has no init record for this project, so ${r} uses the one in the repo: ${x.relative(process.cwd(),k).split(x.sep).join("/")||k}
|
|
245
|
+
`);let R={cwd:process.cwd(),...m?{reported:m}:j?{reported:j}:{}};if(r==="install"||r==="uninstall"){let s;try{s={write:t.write===!0,scope:an(t.scope),dryRun:t["dry-run"]===!0,force:t.force===!0,host:dn(t.host),hook:t.host===void 0&&t["no-hook"]!==!0,cliPath:process.argv[1]?yn(process.argv[1]):void 0}}catch(C){return process.stderr.write(`
|
|
246
246
|
error: ${C.message}
|
|
247
247
|
|
|
248
248
|
`),2}let a={home:Qt.homedir(),platform:process.platform,cwd:process.cwd(),configDir:je()},p=r==="uninstall"||t.remove===!0,i=p?Tt(s,a,Dt()):Rt(s,a,Dt()),h=i.exitCode===0?process.stdout:process.stderr;return h.write(`
|
|
@@ -312,7 +312,7 @@ ${i.output}
|
|
|
312
312
|
`),2):(process.stderr.write(`
|
|
313
313
|
unexpected error: ${s.stack??String(s)}
|
|
314
314
|
|
|
315
|
-
`),2)}if(r==="mcp")return tn?((async()=>{let[{StdioServerTransport:s},{createDisabledMcpServer:a,DISABLED_MESSAGE:p}]=await Promise.all([import("@modelcontextprotocol/sdk/server/stdio.js"),import("./chunks/mcpServer-
|
|
315
|
+
`),2)}if(r==="mcp")return tn?((async()=>{let[{StdioServerTransport:s},{createDisabledMcpServer:a,DISABLED_MESSAGE:p}]=await Promise.all([import("@modelcontextprotocol/sdk/server/stdio.js"),import("./chunks/mcpServer-5J4HOZCC.js")]);process.stderr.write(`
|
|
316
316
|
mcp: ${p}
|
|
317
317
|
|
|
318
318
|
`),await a().connect(new s)})().catch(s=>{process.stderr.write(`
|
package/pkg/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* MinniMemoryMCP (c) 2026 MinniAI. Licensed under the MinniMemoryMCP License, see LICENSE. */
|
|
2
|
-
import{a as q,b as z,c as Q,d as X,e as $,
|
|
2
|
+
import{a as q,b as z,c as Q,d as X,e as $,n as ee,o as re,p as oe}from"./chunks/chunk-6KBBT7IM.js";import{Da as N,Ea as H,Fa as v,G as E,Ga as A,H as O,Ha as U,Ia as W,Ja as g,K as S,Ka as h,La as B,Ma as K,Na as w,Oa as G,Pa as V,Ra as b,S as f,T as c,Ta as J,U as m,Ua as Y,Va as Z,W as I,Wa as j,X as F,Y as T,a as e,ba as _,c as r,d as o,e as t,f as p,fa as D,g as l,h as n,i as a,ia as x,j as i,k as d,l as y,na as R,oa as L,pa as k,qa as u,ra as C,ta as P,u as s,va as M}from"./chunks/chunk-AQ6QWAHT.js";export{X as BASIC_READ_TOOLS,$ as BASIC_WRITE_TOOLS,r as DEFAULT_CONFIG,re as DISABLED_MESSAGE,u as DiscoveryError,m as FolderError,G as HOOK_CLOSE_LINE,w as HOOK_OPEN_LINE,L as HOST_FILES,n as INSTRUCTIONS,k as LIST_FILE_NAMES,E as McpTargetError,f as RULES,A as RecallDirError,q as SERVE_TOOLS,z as SETUP_TOOLS,e as SEVERITY_ORDER,t as TOKENIZER_ID,Q as WRITE_TOOLS,o as alwaysLoaded,F as applyFolderPlan,D as applyFolderUndo,H as auditWorkspace,s as compile,oe as createDisabledMcpServer,ee as createMcpServer,d as defaultProfile,C as detectPhase,P as discover,v as doctor,p as estimateTokens,j as exitCodeFor,h as fenceCode,x as folderPlanSummary,l as formatTokens,U as getDirIndex,K as hookClose,B as hookOpen,i as isProfileName,W as listDirFiles,O as loadManifest,J as parseHookInput,I as planFolder,_ as planFolderUndo,a as profile,M as readFolderManifest,S as recall,g as recallDir,T as renderFolderFiles,R as renderFolderPlan,b as renderHook,Y as renderHuman,y as renderInstructions,Z as renderJson,N as resolveConfig,c as ruleById,V as unwrapHook};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/* MinniMemoryMCP (c) 2026 MinniAI. Licensed under the MinniMemoryMCP License, see LICENSE. */
|
|
2
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p}from"./chunk-4FYIFKN4.js";import"./chunk-KTZV7XLL.js";export{d as BASIC_READ_TOOLS,e as BASIC_WRITE_TOOLS,p as CONTENT_CAP_CHARS,i as DATA_CLOSE_LINE,h as DATA_OPEN_LINE,n as DISABLED_MESSAGE,j as MARKER_NOTE,a as SERVE_TOOLS,b as SETUP_TOOLS,c as WRITE_TOOLS,k as asData,o as createDisabledMcpServer,m as createMcpServer,g as dataClose,f as dataOpen,l as unwrapData};
|