minnimemory 1.4.0 → 1.4.1
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 +22 -0
- package/README.md +6 -1
- package/package.json +1 -1
- package/pkg/chunks/chunk-7JYDJPVH.js +60 -0
- package/pkg/chunks/chunk-M7V2YVAQ.js +168 -0
- package/pkg/chunks/{mcpServer-6J4GLXHP.js → mcpServer-2JD64MUD.js} +1 -1
- package/pkg/cli.js +112 -107
- package/pkg/index.js +1 -1
- package/pkg/chunks/chunk-K7XLQMXJ.js +0 -166
- package/pkg/chunks/chunk-SELGA237.js +0 -54
|
@@ -1,2 +1,2 @@
|
|
|
1
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-
|
|
2
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q}from"./chunk-7JYDJPVH.js";import"./chunk-M7V2YVAQ.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,40 +1,40 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/* MinniMemoryMCP (c) 2026 MinniAI. Licensed under the MinniMemoryMCP License, see LICENSE. */
|
|
3
|
-
import{$ as
|
|
4
|
-
one task description per line, # for comments`);return o}function
|
|
5
|
-
`)}function
|
|
6
|
-
`)}function
|
|
7
|
-
`)}import
|
|
8
|
-
`):void 0,
|
|
9
|
-
${e}`:e);return t.servedDirect?u.includes(o(t.servedDirect)):u.includes("npx -y minnimemory mcp")}function
|
|
10
|
-
`,
|
|
11
|
-
`),path:o};let
|
|
12
|
-
`),path:o}}function
|
|
13
|
-
`),path:o};if(!
|
|
14
|
-
`),path:o})}function
|
|
3
|
+
import{$ as Ze,A as Fe,Aa as ue,B as Le,Ba as q,C as Be,Ca as z,Da as po,G as Ue,Ga as fo,H as Je,Ha as pe,Ia as fe,Ja as mo,K as Ge,Ka as ho,L as We,La as go,M as L,Ma as yo,N as ie,Na as wo,O as Xe,Oa as Y,Pa as ko,Q as qe,R as I,S as ae,T as ze,U as de,Ua as vo,V as Ye,X as Ke,Xa as bo,Z as Ve,_ as Qe,b as N,ba as W,ca as eo,da as oo,db as xo,ea as to,eb as $o,fb as me,g,gb as Co,hb as So,ia as ro,ib as Oo,j as De,ja as no,jb as jo,ka as so,kb as Mo,la as io,lb as To,ma as ao,mb as Eo,n as Ae,na as le,nb as Do,o as Re,oa as lo,ob as Ao,p as Pe,pa as co,q as Ne,r as Ie,rb as Ro,s as re,t as ne,tb as he,ua as uo,ub as ge,v as He,vb as ye,w as G,wa as ce,wb as we,x as F,y as se,z as _e,za as X}from"./chunks/chunk-M7V2YVAQ.js";import{spawnSync as Ot}from"node:child_process";import C from"node:fs";import Zo from"node:os";import b from"node:path";import{fileURLToPath as jt}from"node:url";import{parseArgs as Mt}from"node:util";import st from"node:fs";function it(e){return e.split(/\r?\n/).map(t=>t.trim()).filter(t=>t!==""&&!t.startsWith("#"))}function Po(e){let t;try{t=st.readFileSync(e,"utf8")}catch{throw new I(`cannot read workload file: ${e}`)}let o=it(t);if(o.length===0)throw new I(`workload file has no tasks: ${e}
|
|
4
|
+
one task description per line, # for comments`);return o}function K(e){return`${e.onDemandFile}:${e.startLine}`}function at(e){return`${e.onDemandFile} > ${e.heading}`}function dt(e,t){let o=N(e).flatMap(r=>Ae({name:r.name,file:r.file},Xe(t,r.file)));return Re(o,new Map(N(e).map(r=>[r.name,r.triggers])))}function No(e,t,o={}){let r=o.root?dt(e,o.root):void 0,n=r?"section":"file",u=new Set,a=new Map,d=new Map,l=new Map;for(let i of N(e))a.set(i.name,i.tokens),d.set(i.name,i.name),l.set(i.name,i.name);if(r)for(let i of r.units)a.set(K(i),i.tokens),d.set(K(i),at(i)),l.set(K(i),i.onDemandFile);let f=[],w=0;t.forEach((i,p)=>{let c=r?Ne(Pe(r,i)).map(m=>K(m.unit)):Ie(e,i).filter(m=>m.score>0).map(m=>m.name);c.length===0&&w++;let v=c.filter(m=>!u.has(m));for(let m of v)u.add(m);let x=[...u].reduce((m,$)=>m+(a.get($)??0),0);f.push({turn:p+1,task:i,opened:v.map(m=>d.get(m)??m),carried:[...u].map(m=>d.get(m)??m),compiledTokens:e.prefix.after+x,baselineTokens:e.prefix.before})});let k=f.reduce((i,p)=>i+p.compiledTokens,0),h=f.reduce((i,p)=>i+p.baselineTokens,0),y=new Set([...u].map(i=>l.get(i)??i)),T=N(e).map(i=>i.name).filter(i=>y.has(i)),D=[...u].reduce((i,p)=>i+(a.get(p)??0),0),j=e.prefix.after+D,R=e.prefix.before-j,A=h-k,s;return A>=0?(s=f.findIndex((i,p)=>f.slice(0,p+1).reduce((v,x)=>v+x.baselineTokens-x.compiledTokens,0)>=0),s=s>=0?s+1:void 0):R>0&&(s=f.length+Math.ceil(-A/R)),{unit:n,turns:f,baselineTotal:h,compiledTotal:k,saving:A,savingPct:h===0?0:A/h*100,onDemandOpened:T,onDemandNeverOpened:N(e).map(i=>i.name).filter(i=>!y.has(i)),unroutedTurns:w,steadyStatePerTurn:j,steadyStateGainPerTurn:R,breakEvenTurn:s}}function lt(e,t){return t===0?"0.0%":`${(e/t*100).toFixed(1)}%`}function ke(e){return e>=0?`saves ${g(e)}`:`costs ${g(-e)} more`}function ve(e,t){let o=[""];return o.push(` exact, over ${g(e.turns)} turns. No workload, no assumptions.`),o.push(""),o.push(` original memory file ${g(e.baselinePerTurn).padStart(8)} tokens per turn`),o.push(` compiled always-loaded ${g(e.compiledPerTurn).padStart(8)} tokens per turn`),o.push(` OnDemandMemory, all of it ${g(e.totalOnDemandTokens).padStart(8)} tokens, on demand`),o.push(""),o.push(" best case, no OnDemandMemory file ever opened"),o.push(` ${g(e.baselineTotal)} -> ${g(e.bestCaseTotal)} tokens, ${ke(e.bestCaseSaving)} (${lt(e.bestCaseSaving,e.baselineTotal)})`),o.push(""),o.push(" worst case, every OnDemandMemory file opened on turn 1 and carried"),o.push(` ${g(e.baselineTotal)} -> ${g(e.worstCaseTotal)} tokens, ${ke(e.worstCaseSaving)}`),o.push(""),o.push(` break-even: ${g(e.breakEvenCarriedTokens)} tokens of OnDemandMemory can sit in`),o.push(" context from turn 1 to the end and come out even. Past that the compiled"),o.push(" shape costs more than the file it replaced."),o.push(""),o.push(` tokenizer: ${t}, an offline estimate`),o.push(""),o.join(`
|
|
5
|
+
`)}function Io(e,t){let o=[""],r=e.turns.length;if(o.push(` MODEL, not a measurement. ${g(r)} turns from the workload you supplied.`),o.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."),o.push(""),o.push(` memory tokens over the session ${g(e.baselineTotal)} -> ${g(e.compiledTotal)}`),o.push(` ${ke(e.saving)}${e.saving>=0?` (${e.savingPct.toFixed(1)}%)`:""}`),o.push(""),e.onDemandOpened.length>0){o.push(` opened and carried (${e.onDemandOpened.length}):`);for(let n of e.onDemandOpened)o.push(` ${n}`);o.push("")}if(e.onDemandNeverOpened.length>0){o.push(` never opened (${e.onDemandNeverOpened.length}) - this is where the saving comes from:`);for(let n of e.onDemandNeverOpened)o.push(` ${n}`);o.push("")}return o.push(" one more turn, once everything this workload opens is in context:"),o.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`),o.push(""),e.saving<0&&e.steadyStateGainPerTurn<=0?(o.push(" this workload never breaks even. The OnDemandMemory files it opens are large enough that"),o.push(" carrying them costs more every turn than the original file did, so a longer"),o.push(" session loses more, not less. Splitting differently, or not compiling this"),o.push(" file at all, is the honest answer here."),o.push("")):e.saving<0&&e.breakEvenTurn!==void 0?(o.push(` behind by ${g(-e.saving)} at turn ${g(e.turns.length)}, recovering ${g(e.steadyStateGainPerTurn)} per turn:`),o.push(` breaks even around turn ${g(e.breakEvenTurn)} if nothing further opens.`),o.push("")):e.saving>=0&&e.breakEvenTurn!==void 0&&(o.push(` ahead from turn ${g(e.breakEvenTurn)} onward.`),o.push("")),e.unroutedTurns>0&&(o.push(` ${g(e.unroutedTurns)} of ${g(r)} turns matched no OnDemandMemory file at all.`),o.push(" Those turns are cheap here, but a real agent may have needed something and"),o.push(" not been routed to it. Check them before trusting the total."),o.push("")),o.push(" what this number is conditional on:"),o.push(" - your workload being what a real session looks like. It is your file;"),o.push(" the tool cannot tell whether it is representative."),e.unit==="section"?(o.push(" - every section recall() returns being carried for the rest of the session,"),o.push(" up to its token cap per turn. A real agent may widen with outline() or"),o.push(" read the whole file anyway.")):(o.push(" - every OnDemandMemory file whose triggers match being opened in full. A real"),o.push(" agent may read one and stop, or ignore one the list offered.")),o.push(" - memory tokens only. Reasoning, tool results and conversation are excluded"),o.push(" from both sides, so this ratio is not a session bill."),o.push(""),o.push(" For observed usage against a live agent, measure a real multi-turn session with"),o.push(" and without the compile. That is the only path allowed to call a number measured."),o.push(""),o.push(` tokenizer: ${t}, an offline estimate`),o.push(""),o.join(`
|
|
6
|
+
`)}function Ho(){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 E from"node:fs";import S from"node:path";function B(e){let t=Be(e);return t&&Ue(t)?t:void 0}function ct(e){return e===void 0||e==="codex"}var V=" --host codex";function Lo(e){return Je(e)??`"${e.replace(/"/g,'\\"')}"`}function O(e){return e.map(Lo).join(" ")}function Bo(e){return e.map(Lo)}function Q(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 ut(e){if(e==="cursor")return"~/.cursor/mcp.json";if(e==="windsurf")return"~/.codeium/windsurf/mcp_config.json";if(e==="codex")return"~/.codex/config.toml"}function Uo(e){return e.codexConfigDir??S.join(e.home,".codex")}function pt(e){try{return/^\s*\[mcp_servers\.minnimemory\]\s*$/m.test(E.readFileSync(S.join(Uo(e),"config.toml"),"utf8"))}catch{return!1}}function Jo(e,t){let o=[];e.write&&o.push("--profile","full","--allow-write");let r=e.host==="codex";r&&o.push("--host","codex");let n=B(e.cliPath),u=n?["node",n,"mcp",...o]:["npx","-y","minnimemory","mcp",...o],a=r&&t.codexHome?t.codexHome:void 0,d=a?["--env",`CODEX_HOME=${a}`]:[],l=r?["codex","mcp","add","minnimemory",...d,"--",...u]:["claude","mcp","add","minnimemory","-s",e.scope,"--",...u],f=r?["codex","mcp","remove","minnimemory"]:["claude","mcp","remove","minnimemory","-s",e.scope],w=r?["codex","mcp","get","minnimemory"]:["claude","mcp","get","minnimemory"],k=r?["codex","--version"]:["claude","--version"],h=O(l),y=r?["[mcp_servers.minnimemory]",`command = ${JSON.stringify(u[0])}`,`args = [${u.slice(1).map(j=>JSON.stringify(j)).join(", ")}]`,...a?[`env = { CODEX_HOME = ${JSON.stringify(a)} }`]:[]].join(`
|
|
8
|
+
`):void 0,T=JSON.stringify({mcpServers:{minnimemory:{command:"npx",args:["-y","minnimemory","mcp",...o]}}},null,2),D={scope:e.scope,servedFlags:o,servedArgv:u,...n?{servedDirect:n}:{},addArgv:l,removeArgv:f,getArgv:w,probeArgv:k,manualLine:h,jsonSnippet:T,...y?{tomlSnippet:y}:{}};if(e.host&&e.host!=="json"){let j=ut(e.host);j&&(D.hostConfigPath=j)}return D}function be(e){return e.error!==void 0&&e.error.code==="ENOENT"}var xe="npx -y minnimemory drift";function ft(e,t){let o=B(e);return(o?`node "${o}" drift`:xe)+(t==="codex"?V:"")}var $e="npx -y minnimemory hook";function mt(e,t){let o=B(e);return(o?`node "${o}" hook`:$e)+(t==="codex"?V:"")}function Go(e){return e.endsWith(V)?e.slice(0,-V.length):e}function ht(e){if(typeof e!="string")return!1;let t=Go(e);return t===$e||Ce(t,"hook")}function gt(e,t){let o=a=>a.replace(/\\/g,"/").toLowerCase(),r=/^\s*Command:\s*(.*)$/m.exec(e)?.[1]?.trim(),n=/^\s*Args:\s*(.*)$/m.exec(e)?.[1]?.trim(),u=o(r?`${r} ${n??""}
|
|
9
|
+
${e}`:e);return t.servedDirect?u.includes(o(t.servedDirect)):u.includes("npx -y minnimemory mcp")}function yt(e){let t=/Scope:\s*(User|Project|Local)\b/i.exec(e);return t?t[1].toLowerCase():void 0}function Ce(e,t){let o=/^node "([^"]+)" (drift|loaded|hook)$/.exec(e);if(o===null||o[2]!==t)return!1;let r=o[1];return/minnimemory/i.test(r)||wt(r)}function wt(e){if(!S.isAbsolute(e))return!1;let t=S.dirname(e);for(let o=0;o<4;o++)try{return JSON.parse(E.readFileSync(S.join(t,"package.json"),"utf8")).name==="minnimemory"}catch{let r=S.dirname(t);if(r===t)return!1;t=r}return!1}function kt(e){if(typeof e!="string")return!1;let t=Go(e);return t===xe||Ce(t,"drift")}var Se="npx -y minnimemory loaded";function vt(e){let t=B(e);return t?`node "${t}" loaded`:Se}function bt(e){return typeof e=="string"&&(e===Se||Ce(e,"loaded"))}function Wo(e,t){let o=ft(e,t),r=mt(e,t),n=vt(e),u=[{event:"UserPromptSubmit",command:o,fallback:xe,isOurs:a=>a===o||kt(a)},{event:"UserPromptSubmit",command:r,fallback:$e,isOurs:a=>a===r||ht(a)}];return t==="codex"?u:[...u,{event:"InstructionsLoaded",command:n,fallback:Se,isOurs:a=>a===n||bt(a)}]}function Xo(e,t,o){let r=t.cwd??process.cwd();return o==="codex"?e==="user"?S.join(Uo(t),"hooks.json"):S.join(r,".codex","hooks.json"):e==="user"?S.join(t.configDir??S.join(t.home,".claude"),"settings.json"):e==="project"?S.join(r,".claude","settings.json"):S.join(r,".claude","settings.local.json")}function _o(e){return e==="codex"?"Restart Codex.":"Restart Claude Code."}var xt="then run /hooks inside Codex once to trust the two minnimemory hooks (Codex skips an untrusted hook)";function qo(e,t){let o=[];for(let r of e){if(!r||typeof r!="object")continue;let n=r.hooks;if(Array.isArray(n))for(let u of n){let a=u&&typeof u=="object"?u.command:void 0;t(a)&&o.push(a)}}return o}function zo(e){if(!E.existsSync(e))return{};try{let t=JSON.parse(E.readFileSync(e,"utf8"));return!t||typeof t!="object"||Array.isArray(t)?void 0:t}catch{return}}function Yo(e,t){let o=`${JSON.stringify(t,null,2)}
|
|
10
|
+
`,r=`${e}.minnimemory-${process.pid}.tmp`;E.writeFileSync(r,o,"utf8");try{E.renameSync(r,e)}catch{E.rmSync(r,{force:!0}),E.writeFileSync(e,o,"utf8")}}function Ko(e){let t=e.hooks;return t&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function $t(e,t){if(e.host==="codex"&&e.scope==="local")return{exitCode:2,output:"install --hook: Codex has no local scope; use --scope user or --scope project.",path:""};let o=Xo(e.scope,t,e.host),r=Wo(e.cliPath,e.host);if(e.dryRun)return{exitCode:0,output:r.map(l=>`would add the ${l.event} hook \`${l.command}\` to ${o}`).join(`
|
|
11
|
+
`),path:o};let n=zo(o);if(!n)return{exitCode:1,output:`install --hook: ${o} is not valid JSON; not touched.`,path:o};let u=Ko(n)??{},a=[],d=!1;for(let l of r){let f=Array.isArray(u[l.event])?[...u[l.event]]:[],w=qo(f,l.isOurs);if(w.includes(l.command)){a.push(l.event==="UserPromptSubmit"?`hook: \`${l.fallback.split(" ").pop()}\` already present in ${o}`:`hook: ${l.event} already present in ${o}`);continue}if(w.length>0){for(let k of f){let h=k&&typeof k=="object"?k.hooks:void 0;if(Array.isArray(h))for(let y of h)y&&typeof y=="object"&&l.isOurs(y.command)&&(y.command=l.command)}a.push(`hook: updated \`${w[0]}\` -> \`${l.command}\` in ${o} (${l.event}). ${_o(e.host)}`)}else{let k={hooks:[{type:"command",command:l.command}]};f.push(k),a.push(`hook: added \`${l.command}\` to ${o} (${l.event}). ${_o(e.host)}`)}u[l.event]=f,d=!0}return d&&(n.hooks=u,E.mkdirSync(S.dirname(o),{recursive:!0}),Yo(o,n)),{exitCode:0,output:a.join(`
|
|
12
|
+
`),path:o}}function Fo(e,t){let o=Xo(e.scope,t,e.host),r=Wo(e.cliPath,e.host);if(e.dryRun)return{exitCode:0,output:r.map(d=>`would remove the ${d.event} hook (\`${d.fallback}\` or its direct node form) from ${o}`).join(`
|
|
13
|
+
`),path:o};if(!E.existsSync(o))return{exitCode:0,output:`hook: nothing to remove (${o} does not exist)`,path:o};let n=zo(o);if(!n)return{exitCode:1,output:`install --remove: ${o} is not valid JSON; not touched.`,path:o};let u=Ko(n),a=[];for(let d of r){let l=u&&Array.isArray(u[d.event])?u[d.event]:void 0,f=l?qo(l,d.isOurs):[];if(!u||!l||f.length===0)continue;let w=l.filter(k=>{if(!k||typeof k!="object")return!0;let h=k.hooks;if(!Array.isArray(h))return!0;let y=h.filter(T=>!(T&&typeof T=="object"&&d.isOurs(T.command)));return y.length===0?!1:(k.hooks=y,!0)});w.length===0?delete u[d.event]:u[d.event]=w,a.push(`hook: removed \`${f[0]}\` from ${o}`)}return a.length===0?{exitCode:0,output:`hook: nothing to remove in ${o}`,path:o}:(u&&Object.keys(u).length===0&&delete n.hooks,Yo(o,n),{exitCode:0,output:a.join(`
|
|
14
|
+
`),path:o})}function Vo(e,t,o){let r=Jo(e,t),n=[];if(e.dryRun){n.push(`would run: ${O(r.removeArgv)}`);let l=Fo({...e,dryRun:!0},t);return n.push(l.output),{exitCode:0,output:`${n.join(`
|
|
15
15
|
`)}
|
|
16
|
-
`}}let u=o(
|
|
17
|
-
${
|
|
16
|
+
`}}let u=o(r.probeArgv[0],r.probeArgv.slice(1)),a=0;if(be(u))n.push(`the ${e.host==="codex"?"codex":"claude"} CLI is not on PATH; skipping the MCP registration removal.`);else{let l=o(r.removeArgv[0],r.removeArgv.slice(1));n.push(`ran: ${O(r.removeArgv)}`),l.code!==0&&/no mcp server named/i.test(`${l.stdout}
|
|
17
|
+
${l.stderr}`)?n.push(`nothing registered as minnimemory in ${e.scope} scope`):l.code!==0?(n.push(l.stderr.trim()),a=1):l.stdout.trim()&&n.push(l.stdout.trim())}let d=Fo(e,t);return n.push(d.output),d.exitCode!==0&&(a=d.exitCode),{exitCode:a,output:`${n.join(`
|
|
18
18
|
`)}
|
|
19
|
-
`}}function
|
|
19
|
+
`}}function Ct(e,t){let o=B(e),r=o?`node "${o}" init`:"npx -y minnimemory init";return t==="codex"?`next: restart Codex, ${xt}, then ask it to clean up your memory with minnimemory; it starts with init. In a terminal: \`${r} <folder> --host codex\` from your project (Codex's load set needs no --from-log).`:`next: restart Claude Code, then ask it to clean up your memory with minnimemory; it starts with init. In a terminal: \`${r} <folder> --from-log\` from your project.`}function H(e,t,o,r){if(e.hook){let n=$t(e,t);o.push(n.output),n.exitCode!==0&&(r=n.exitCode)}return r===0&&o.push(Ct(e.cliPath,e.host)),{exitCode:r,output:`${o.join(`
|
|
20
20
|
`)}
|
|
21
|
-
`}}function
|
|
21
|
+
`}}function St(e,t,o,r){let n=[];if(e.dryRun){e.force&&n.push(`would run: ${O(r.removeArgv)}`),n.push(`would run: ${O(r.addArgv)}`);let f=Q(r);return f&&n.push(f),H(e,t,n,0)}let u=o(r.probeArgv[0],r.probeArgv.slice(1));if(be(u))return n.push("the codex CLI is not on PATH. Register minnimemory manually:","",` ${r.manualLine}`,"",`or add this to ${r.hostConfigPath??"~/.codex/config.toml"}:`,"",r.tomlSnippet??""),{exitCode:2,output:`${n.join(`
|
|
22
22
|
`)}
|
|
23
|
-
`};let a=
|
|
23
|
+
`};let a=pt(t);if(a&&!e.force)return n.push("minnimemory is already registered with Codex.",`to change it: ${O(["npx","-y","minnimemory","install","--host","codex","--force",...e.write?["--write"]:[]])}`),H(e,t,n,0);if(a){let f=o(r.removeArgv[0],r.removeArgv.slice(1));if(f.code!==0)return n.push(`ran: ${O(r.removeArgv)}`,f.stderr.trim()),{exitCode:1,output:`${n.join(`
|
|
24
24
|
`)}
|
|
25
|
-
`}}let d=o(
|
|
25
|
+
`}}let d=o(r.addArgv[0],r.addArgv.slice(1));if(n.push(`ran: ${O(r.addArgv)}`),d.code!==0)return n.push(d.stderr.trim()),{exitCode:1,output:`${n.join(`
|
|
26
26
|
`)}
|
|
27
|
-
`};d.stdout.trim()&&
|
|
28
|
-
`};if(e.host==="codex")return
|
|
27
|
+
`};d.stdout.trim()&&n.push(d.stdout.trim());let l=Q(r);return l&&n.push(l),H(e,t,n,0)}function Qo(e,t,o){let r=Jo(e,t),n=[];if(e.hook&&!ct(e.host))return{exitCode:2,output:`--hook only applies to Claude Code and Codex
|
|
28
|
+
`};if(e.host==="codex")return St(e,t,o,r);if(e.host)return n.push(r.jsonSnippet),r.hostConfigPath?n.push("",`config file: ${r.hostConfigPath}`):n.push("",`add this under "mcpServers" in your host's MCP config file.`),{exitCode:0,output:`${n.join(`
|
|
29
29
|
`)}
|
|
30
|
-
`};if(e.dryRun){e.force&&
|
|
30
|
+
`};if(e.dryRun){e.force&&n.push(`would run: ${O(r.removeArgv)}`),n.push(`would run: ${O(r.addArgv)}`);let y=Q(r);return y&&n.push(y),H(e,t,n,0)}let u=o(r.probeArgv[0],r.probeArgv.slice(1));if(be(u))return n.push("the claude CLI is not on PATH. Register minnimemory manually:","",` ${r.manualLine}`,"","or add this to another host's MCP config:","",r.jsonSnippet),{exitCode:2,output:`${n.join(`
|
|
31
31
|
`)}
|
|
32
|
-
`};let a=o(
|
|
32
|
+
`};let a=o(r.getArgv[0],r.getArgv.slice(1)),d=a.code===0?yt(a.stdout):void 0,l=d!==void 0&&d!==e.scope;l&&n.push(`minnimemory is also registered at ${d} scope; that registration is left as it is (Claude Code uses local, then project, then user).`);let f=a.code===0&&!l,w=f&&!gt(a.stdout,r);if(f&&!e.force&&!w)return n.push("minnimemory is already registered.",`to change it: ${O(["npx","-y","minnimemory","install","--force","--scope",e.scope,...e.write?["--write"]:[]])}`),H(e,t,n,0);if(f){w&&!e.force&&n.push("minnimemory is registered with a different command; repointing it at this copy.");let y=o(r.removeArgv[0],r.removeArgv.slice(1));if(y.code!==0)return n.push(`ran: ${O(r.removeArgv)}`,y.stderr.trim()),{exitCode:1,output:`${n.join(`
|
|
33
33
|
`)}
|
|
34
|
-
`}}let k=o(
|
|
34
|
+
`}}let k=o(r.addArgv[0],r.addArgv.slice(1));if(n.push(`ran: ${O(r.addArgv)}`),k.code!==0)return n.push(k.stderr.trim()),{exitCode:1,output:`${n.join(`
|
|
35
35
|
`)}
|
|
36
|
-
`};k.stdout.trim()&&
|
|
37
|
-
minnimemory ${
|
|
36
|
+
`};k.stdout.trim()&&n.push(k.stdout.trim());let h=Q(r);return h&&n.push(h),H(e,t,n,0)}var Tt=!1,Z=`
|
|
37
|
+
minnimemory ${we} the agent memory compiler
|
|
38
38
|
|
|
39
39
|
usage: the four lifecycle verbs, the CLI and the MCP basic profile share.
|
|
40
40
|
The only difference is who writes: the CLI writes to disk itself, the MCP tools return the
|
|
@@ -228,8 +228,8 @@ doctor options
|
|
|
228
228
|
<folder> is required: a repo, a memory directory, or a single file. With none, minnimemory asks
|
|
229
229
|
for it (in a terminal) or stops and says so. Type . for the current folder. An @import that
|
|
230
230
|
points outside the folder is not read; the report names it.
|
|
231
|
-
`;function
|
|
232
|
-
`)}function
|
|
231
|
+
`;function Et(){let e=[""," rule set",""];for(let t of Ze)e.push(` ${t.id.padEnd(8)}${t.severity.padEnd(6)}${t.title}`);return e.push(""),e.join(`
|
|
232
|
+
`)}function Dt(e,t){if(e===void 0)return t;if(e==="low"||e==="med"||e==="high")return e;throw new Error(`--fail-on must be one of low, med, high (got "${e}")`)}function et(e){return e?e.split(",").map(t=>t.trim()).filter(Boolean):[]}function At(e,t){return e.matches.length===0?`
|
|
233
233
|
no match for "${e.query}"
|
|
234
234
|
|
|
235
235
|
`:t?`${e.matches.map(o=>`${o.onDemandFile} > ${o.path.join(" > ")} (${o.tokens} tokens)`).join(`
|
|
@@ -241,164 +241,169 @@ ${o.content}`).join(`
|
|
|
241
241
|
---
|
|
242
242
|
|
|
243
243
|
`)}
|
|
244
|
-
`}function
|
|
245
|
-
error: ${
|
|
244
|
+
`}function Rt(e){return e.isTTY?"usage":"serve"}function ot(){return(e,t)=>{let o=process.platform==="win32",r=Ot(e,o?Bo(t):t,{encoding:"utf8",shell:o});return{code:r.status,stdout:r.stdout??"",stderr:r.stderr??"",error:r.error}}}function Pt(e){if(e===void 0||e==="user")return"user";if(e==="project"||e==="local")return e;throw new Error(`--scope must be one of user, project, local (got "${e}")`)}function Nt(e){if(e!==void 0){if(e==="cursor"||e==="windsurf"||e==="json"||e==="codex")return e;throw new Error(`--host must be one of codex, cursor, windsurf, json (got "${e}")`)}}function tt(e){if(e===void 0)return;let t=Number(e);if(!Number.isInteger(t)||t<=0||t>re)throw new Error(`--budget must be a whole number of tokens from 1 to ${re.toLocaleString("en-US")} (got "${e}")`);return Math.floor(t)}function It(e,t){let o;try{if(o=b.resolve(e),!C.existsSync(o)||!C.statSync(o).isDirectory())throw new L(`not a directory: ${o}`)}catch(n){return n instanceof L?(process.stderr.write(`
|
|
245
|
+
error: ${n.message}
|
|
246
246
|
|
|
247
247
|
`),2):(process.stderr.write(`
|
|
248
|
-
unexpected error: ${
|
|
248
|
+
unexpected error: ${n.stack??String(n)}
|
|
249
249
|
|
|
250
|
-
`),2)}let
|
|
251
|
-
error: --profile must be one of basic, full (got "${
|
|
250
|
+
`),2)}let r=t.profile??"basic";return r!=="basic"&&r!=="full"?(process.stderr.write(`
|
|
251
|
+
error: --profile must be one of basic, full (got "${r}")
|
|
252
252
|
|
|
253
|
-
`),2):((async()=>{let[{StdioServerTransport:
|
|
254
|
-
mcp server failed: ${
|
|
255
|
-
`),process.exitCode=1}),0)}function
|
|
256
|
-
`)}var
|
|
253
|
+
`),2):((async()=>{let[{StdioServerTransport:n},{createMcpServer:u}]=await Promise.all([import("@modelcontextprotocol/sdk/server/stdio.js"),import("./chunks/mcpServer-2JD64MUD.js")]);await u(o,{profile:r,allowWrite:t["allow-write"]===!0,host:F()}).connect(new n)})().catch(n=>{process.stderr.write(`
|
|
254
|
+
mcp server failed: ${n.message??String(n)}
|
|
255
|
+
`),process.exitCode=1}),0)}function Ht(){let e=wo(),t=[];if(e.length>0){t.push("still compiled (they keep working without minnimemory; to put the originals back, undo each one):");for(let o of e)t.push(` ${Ge(o)}`)}return t.push(`kept: ${b.dirname(ho())} (init records, the load log, undo backups); delete it yourself once you have checked undo-backups/.`),t.push("restart Claude Code."),t.join(`
|
|
256
|
+
`)}var _t=new Set(["init","doctor","apply","undo","bench"]);function Ft(e){if(Y(process.cwd()))return!0;let t=Oe(e);return ue(t)==="compiled"||fe(t)!==void 0||de(t)!==void 0}function Oe(e){let t=b.resolve(e);return C.existsSync(t)&&C.statSync(t).isFile()?b.dirname(t):t}function Lt(e){if(Y(process.cwd()))return;let t=Oe(e);return de(t)?ze(t):void 0}function Bt(e){let t=`minnimemory ${e} <folder>`;if(process.stdin.isTTY!==!0){process.stderr.write(`
|
|
257
257
|
error: name the folder to read: ${t} (type . for the current folder)
|
|
258
258
|
|
|
259
259
|
`);return}process.stdout.write(`
|
|
260
260
|
Which folder should minnimemory ${e} read? Only that folder and the folders below it are read.
|
|
261
|
-
folder: `);let o=
|
|
261
|
+
folder: `);let o=Ut().trim();if(o===""){process.stderr.write(`
|
|
262
262
|
error: no folder given; run ${t}
|
|
263
263
|
|
|
264
|
-
`);return}return o}function
|
|
265
|
-
`)break;
|
|
264
|
+
`);return}return o}function Ut(){let e=Buffer.alloc(1),t="";for(;;){let o;try{o=C.readSync(0,e,0,1,null)}catch{break}if(o===0)break;let r=e.toString("utf8");if(r===`
|
|
265
|
+
`)break;r!=="\r"&&(t+=r)}return t}function Jt(e){let t;try{t=Mt({args:e,allowPositionals:!0,strict:!0,options:{json:{type:"boolean",default:!1},write:{type:"boolean",default:!1},force:{type:"boolean",default:!1},update:{type:"boolean",default:!1},"allow-secrets":{type:"boolean",default:!1},"episodic-json":{type:"boolean",default:!1},"allow-write":{type:"boolean",default:!1},"follow-external-imports":{type:"boolean",default:!1},"include-auto-memory":{type:"boolean",default:!1},scope:{type:"string"},"dry-run":{type:"boolean",default:!1},"auto-memory":{type:"boolean",default:!1},hook:{type:"boolean",default:!1},"no-hook":{type:"boolean",default:!1},remove:{type:"boolean",default:!1},host:{type:"string"},"host-file":{type:"string",multiple:!0},loaded:{type:"string",multiple:!0},"memory-dir":{type:"string"},"from-log":{type:"boolean",default:!1},"only-this-folder":{type:"boolean",default:!1},turns:{type:"string"},workload:{type:"string"},"whole-files":{type:"boolean",default:!1},"max-tokens":{type:"string"},headings:{type:"boolean",default:!1},dir:{type:"string"},profile:{type:"string"},plan:{type:"string"},ci:{type:"boolean",default:!1},rules:{type:"boolean",default:!1},map:{type:"boolean",default:!1},diff:{type:"string"},"fail-on":{type:"string"},budget:{type:"string"},policy:{type:"string"},only:{type:"string"},ignore:{type:"string"},help:{type:"boolean",short:"h",default:!1},version:{type:"boolean",short:"v",default:!1}}})}catch(s){let i=s.message,p=/argument is ambiguous/.test(i)?`
|
|
266
266
|
(a value that starts with '-' must be written as --option=value; --budget must be positive anyway)`:"";return process.stderr.write(`
|
|
267
|
-
error: ${
|
|
268
|
-
${
|
|
269
|
-
`),0;if(o.rules)return process.stdout.write(
|
|
270
|
-
`);let a=
|
|
271
|
-
error: --host must be claude or codex for ${
|
|
267
|
+
error: ${i}${p}
|
|
268
|
+
${Z}`),2}let{values:o,positionals:r}=t;if(o.help)return process.stdout.write(Z),0;if(o.version)return process.stdout.write(`${we}
|
|
269
|
+
`),0;if(o.rules)return process.stdout.write(Et()),0;let n;if(r[0]===void 0){if(Rt({isTTY:process.stdin.isTTY===!0})==="usage")return process.stdout.write(Z),0;n="mcp"}else n=r[0];let u=["include-auto-memory","follow-external-imports","auto-memory"].filter(s=>o[s]===!0);u.length>0&&process.stderr.write(` note: ${u.map(s=>`--${s}`).join(", ")} no longer does anything: minnimemory reads only the folder you name
|
|
270
|
+
`);let a=r[1]===void 0?void 0:/^~($|[\\/])/.test(r[1])?q(r[1]):r[1];if(a===void 0&&typeof o["memory-dir"]=="string"&&(a=o["memory-dir"]),a===void 0&&["doctor","apply","undo"].includes(n)){let s=Y(process.cwd());s&&(a=s.target??s.memoryDir??s.project)}if(a===void 0&&_t.has(n)&&(a=Bt(n),a===void 0))return 2;let d=a??".";if(n!=="install"&&n!=="uninstall")if(o.host!==void 0){if(!He(o.host))return process.stderr.write(`
|
|
271
|
+
error: --host must be claude or codex for ${n} (got "${o.host}")
|
|
272
272
|
|
|
273
|
-
`),2;
|
|
273
|
+
`),2;G(o.host)}else["init","doctor","apply","undo","mcp"].includes(n)?G(Fe({env:process.env,home:Zo.homedir(),cwd:process.cwd()})):G("claude");if(o.policy!==void 0&&n!=="doctor")return process.stderr.write(`
|
|
274
274
|
error: --policy is a doctor option: \`minnimemory doctor <folder> --policy <file>\`
|
|
275
275
|
|
|
276
276
|
`),2;if(o.diff!==void 0&&o.diff!=="summary"&&o.diff!=="full")return process.stderr.write(`
|
|
277
277
|
error: --diff takes summary or full, not "${o.diff}"
|
|
278
278
|
|
|
279
|
-
`),2;let
|
|
279
|
+
`),2;let l=o.diff,f=[...o.loaded??[],...o["host-file"]??[]].map(s=>q(s));if(o["from-log"]===!0){let s=Co(process.cwd());if(!s)return process.stderr.write(`
|
|
280
280
|
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
|
|
281
281
|
|
|
282
|
-
`),2;for(let
|
|
283
|
-
|
|
284
|
-
error: ${C.message}
|
|
282
|
+
`),2;for(let i of Object.keys(s.files))/\.md$/i.test(i)&&C.existsSync(i)&&f.push(b.resolve(i))}let w=typeof o["memory-dir"]=="string"?q(o["memory-dir"]):void 0;if(w&&F()==="codex"&&Ke(se("codex"),w))return process.stderr.write(`
|
|
283
|
+
error: ${w.split(b.sep).join("/")} is Codex's own memories folder: Codex generates and rewrites it, so minnimemory lists it in the map and never compiles it. Run init on the project; Codex's AGENTS.md files are what it works on.
|
|
285
284
|
|
|
286
|
-
`),2
|
|
287
|
-
|
|
288
|
-
|
|
285
|
+
`),2;let h=f.length>0||w!==void 0||o["only-this-folder"]===!0?{files:[...new Set(f)],...w?{memoryDir:w}:{},source:o["from-log"]===!0&&(o.loaded??[]).length===0?"log":"terminal",...o["only-this-folder"]===!0?{onlyThisFolder:!0}:{}}:void 0,y=h||!["doctor","apply"].includes(n)?void 0:Lt(d),T=h?void 0:ko(process.cwd())??(y?Ye(Oe(d)):void 0);y&&process.stderr.write(` note: this machine has no init record for this project, so ${n} uses the one in the repo: ${b.relative(process.cwd(),y).split(b.sep).join("/")||y}
|
|
286
|
+
`);let D={cwd:process.cwd(),...h?{reported:h}:T?{reported:T}:{}},j,R;if(n==="init"){let s=po(d,{reported:h});s&&(j=fo(d,s),R=b.resolve(d),d=s.dir,a=s.dir)}if(n==="install"||n==="uninstall"){let s;try{s={write:o.write===!0,scope:Pt(o.scope),dryRun:o["dry-run"]===!0,force:o.force===!0,host:Nt(o.host),hook:(o.host===void 0||o.host==="codex")&&o["no-hook"]!==!0,cliPath:process.argv[1]?Gt(process.argv[1]):void 0}}catch(x){return process.stderr.write(`
|
|
287
|
+
error: ${x.message}
|
|
289
288
|
|
|
290
|
-
`),i.
|
|
289
|
+
`),2}let i={home:Zo.homedir(),platform:process.platform,cwd:process.cwd(),configDir:Le(),codexConfigDir:se("codex"),...process.env.CODEX_HOME?{codexHome:process.env.CODEX_HOME}:{}},p=n==="uninstall"||o.remove===!0,c=p?Vo(s,i,ot()):Qo(s,i,ot()),v=c.exitCode===0?process.stdout:process.stderr;return v.write(`
|
|
290
|
+
${c.output}
|
|
291
|
+
`),p&&v.write(`${Ht()}
|
|
292
|
+
|
|
293
|
+
`),c.exitCode}if(n==="init"||n==="apply"){if(n==="init"&&(o.write===!0||o.update===!0))return process.stderr.write(`
|
|
291
294
|
error: init never writes; use apply
|
|
292
295
|
|
|
293
|
-
`),2;let s=o.profile??"auto";if(s!=="auto"&&!
|
|
296
|
+
`),2;let s=o.profile??"auto";if(s!=="auto"&&!De(s))return process.stderr.write(`
|
|
294
297
|
error: --profile must be one of auto, none, routing, full (got "${s}")
|
|
295
298
|
|
|
296
|
-
`),2;let
|
|
297
|
-
error: ${
|
|
299
|
+
`),2;let i;try{i=tt(o.budget)}catch($){return process.stderr.write(`
|
|
300
|
+
error: ${$.message}
|
|
301
|
+
|
|
302
|
+
`),2}let p=n==="apply",c=s==="auto"?void 0:s,v=o["episodic-json"]===!0,x=[...F()==="codex"?["--host codex"]:[],...c?[`--profile ${c}`]:[],...v?["--episodic-json"]:[],...o["only-this-folder"]===!0?["--only-this-folder"]:[]],m={budget:i,force:o.force===!0,profileName:c,episodicJson:v,discover:D};try{if(!p){let ee=C.existsSync(d)&&C.statSync(d).isFile()?b.dirname(b.resolve(d)):b.resolve(d),_;try{let J=z(d,D);J.shape==="memory-dir"&&(_=J)}catch{_=void 0}let P=!_&&F()==="codex"?Eo(process.cwd(),{projectRoot:R??ee}):void 0,oe=P?void 0:_?Mo(_):Oo(ee,{machine:!1,projectRoot:ee}),je=P?Do(P):To(oe),nt=()=>P?Ao(P):jo(oe);if(o.map===!0)return process.stdout.write(o.json?`${JSON.stringify(P??oe,null,2)}
|
|
303
|
+
`:je),0;o.json||process.stdout.write(je),j&&!o.json&&process.stdout.write(` ${j}
|
|
298
304
|
|
|
299
|
-
`)
|
|
300
|
-
|
|
301
|
-
`)}else process.stdout.write(me(F,{color:!1,ci:o.ci===!0,target:a,flags:C,diff:c}));let oe=F.workspace.folderRoot??$.resolve(d),Oe=F.workspace.claudeMemoryFolder?oe:void 0,je=po(process.cwd(),y?{...y,...y.memoryDir??Oe?{memoryDir:y.memoryDir??Oe}:{}}:void 0,oe);y&&!o.json&&process.stdout.write(je?` saved what ${He()} loads here for apply, doctor and undo: ${je}
|
|
305
|
+
`);let U=he(d,m);if(o.json){let J=JSON.parse(ye(U,a,x));process.stdout.write(`${JSON.stringify({map:nt(),...J},null,2)}
|
|
306
|
+
`)}else process.stdout.write(ge(U,{color:!1,ci:o.ci===!0,target:a,flags:x,diff:l}));let te=U.workspace.folderRoot??b.resolve(d),Me=U.workspace.claudeMemoryFolder?te:void 0,Te=go(process.cwd(),h?{...h,...h.memoryDir??Me?{memoryDir:h.memoryDir??Me}:{}}:void 0,te);h&&!o.json&&process.stdout.write(Te?` saved what ${_e()} loads here for apply, doctor and undo: ${Te}
|
|
302
307
|
|
|
303
308
|
`:` could not save the locations; pass them again to apply
|
|
304
309
|
|
|
305
|
-
`);let
|
|
310
|
+
`);let Ee=yo(process.cwd(),te);return Ee&&process.stderr.write(` ${Ee}
|
|
306
311
|
|
|
307
|
-
`),0}let
|
|
312
|
+
`),0}let $=z(d,D);if($.shape==="memory-dir"&&!$.reported)return process.stderr.write(`
|
|
308
313
|
error: apply refused: nothing reported the files Claude Code loads, so an import of this folder's files from outside it could break. Run from Claude Code (the agent passes them), or add --from-log (Claude Code's own load log for this folder), or --loaded <path> for each file. If nothing outside this folder loads it, pass --only-this-folder. Nothing was changed.
|
|
309
314
|
|
|
310
|
-
`),2;let
|
|
311
|
-
error: the plan on disk no longer matches --plan ${o.plan} (now ${
|
|
315
|
+
`),2;let M=oo($,{budget:i??$.manifest?.budget,profileName:c,episodicJson:v,sortAnyway:o.force===!0});if(o.plan!==void 0&&M.plan!==o.plan)return process.stderr.write(`
|
|
316
|
+
error: the plan on disk no longer matches --plan ${o.plan} (now ${M.plan}); run doctor again
|
|
312
317
|
|
|
313
|
-
`),2;if(
|
|
314
|
-
error: ${
|
|
318
|
+
`),2;if(M.verdict==="nothing")return process.stdout.write(ce(M,{write:!0})),0;if(M.verdict==="leave"&&o.force!==!0)return process.stderr.write(`
|
|
319
|
+
error: ${uo(M)} (${M.before} -> ${M.after} tokens; break-even ${M.bounds.breakEvenCarriedTokens} tokens of OnDemandMemory open all session)
|
|
315
320
|
Pass --force to write it anyway.
|
|
316
321
|
|
|
317
|
-
`),2;let
|
|
318
|
-
error: ${
|
|
322
|
+
`),2;let rt=ce(M,{write:!0,target:a});return to(M,{allowSecrets:o["allow-secrets"]===!0}),process.stdout.write(rt),0}catch($){return $ instanceof X||$ instanceof W?(process.stderr.write(`
|
|
323
|
+
error: ${$.message}
|
|
319
324
|
|
|
320
325
|
`),2):(process.stderr.write(`
|
|
321
|
-
unexpected error: ${
|
|
326
|
+
unexpected error: ${$.stack??String($)}
|
|
322
327
|
|
|
323
|
-
`),2)}}if(
|
|
328
|
+
`),2)}}if(n==="undo")try{let s;try{s=z(d).folderRoot}catch(m){if(!(m instanceof X))throw m}if(!s)return process.stdout.write(`
|
|
324
329
|
nothing to undo
|
|
325
330
|
|
|
326
|
-
`),0;let
|
|
327
|
-
error: ${
|
|
331
|
+
`),0;let i=fe(s),p=i?void 0:mo(s),c=p?co(s,p):!i&&pe(s)?io(s):so(s,i);if(c.kind==="none")return!i&&pe(s)?(process.stderr.write(`
|
|
332
|
+
error: ${eo(s)}
|
|
328
333
|
|
|
329
334
|
`),2):(process.stdout.write(`
|
|
330
335
|
nothing to undo
|
|
331
336
|
|
|
332
|
-
`),0);if(
|
|
333
|
-
error: undo has nothing left to restore here: ${
|
|
337
|
+
`),0);if(c.kind==="kept-only")return process.stderr.write(`
|
|
338
|
+
error: undo has nothing left to restore here: ${ao(c.kept)}
|
|
334
339
|
|
|
335
|
-
`),2;if(
|
|
336
|
-
error: no original copy under ${ne}/original/ for: ${
|
|
340
|
+
`),2;if(c.kind==="missing-original")return process.stderr.write(`
|
|
341
|
+
error: no original copy under ${ne}/original/ for: ${c.files.join(", ")}.
|
|
337
342
|
Backups stay on the machine that ran apply (they are gitignored), and a clone that re-applied backs up the compiled file, not the original; on a clone, the way back is git history.
|
|
338
343
|
|
|
339
|
-
`),2;let
|
|
340
|
-
error: ${
|
|
344
|
+
`),2;let v=ro(c.plan);if(v&&o.force!==!0)return process.stderr.write(`
|
|
345
|
+
error: ${v}
|
|
341
346
|
|
|
342
|
-
`),2;let
|
|
343
|
-
restored ${
|
|
344
|
-
deleted: ${
|
|
345
|
-
`+(
|
|
346
|
-
`:"")+(
|
|
347
|
-
`:"")+(
|
|
347
|
+
`),2;let x=v?no(c.plan):void 0;return lo(c.plan),process.stdout.write(`
|
|
348
|
+
restored ${c.plan.operations.filter(m=>m.op==="write"||m.op==="move").length} file(s) in ${s}
|
|
349
|
+
deleted: ${c.plan.operations.filter(m=>m.op==="delete").length} path(s), ${ne}/ ${c.plan.keptBackups?.length?"kept":"included"}
|
|
350
|
+
`+(le(c.plan)?` ${le(c.plan)}
|
|
351
|
+
`:"")+(c.plan.left?.length?` left in place: ${c.plan.left.join(", ")} (without manifest.json undo cannot tell which files there it wrote)
|
|
352
|
+
`:"")+(x?` the files as they were before this undo are copied to ${x.split(b.sep).join("/")}
|
|
348
353
|
`:"")+`
|
|
349
|
-
`),0}catch(s){return s instanceof
|
|
354
|
+
`),0}catch(s){return s instanceof W?(process.stderr.write(`
|
|
350
355
|
error: ${s.message}
|
|
351
356
|
|
|
352
357
|
`),2):(process.stderr.write(`
|
|
353
358
|
unexpected error: ${s.stack??String(s)}
|
|
354
359
|
|
|
355
|
-
`),2)}if(
|
|
360
|
+
`),2)}if(n==="mcp")return Tt?((async()=>{let[{StdioServerTransport:s},{createDisabledMcpServer:i,DISABLED_MESSAGE:p}]=await Promise.all([import("@modelcontextprotocol/sdk/server/stdio.js"),import("./chunks/mcpServer-2JD64MUD.js")]);process.stderr.write(`
|
|
356
361
|
mcp: ${p}
|
|
357
362
|
|
|
358
|
-
`),await
|
|
363
|
+
`),await i().connect(new s)})().catch(s=>{process.stderr.write(`
|
|
359
364
|
mcp server failed: ${s.message??String(s)}
|
|
360
|
-
`),process.exitCode=1}),0):
|
|
365
|
+
`),process.exitCode=1}),0):It(d,o);if(n==="recall"){let s=r.slice(2).join(" ").trim();if(!s)return process.stderr.write(`
|
|
361
366
|
error: recall needs a query: minnimemory recall <path> <query...>
|
|
362
367
|
|
|
363
|
-
`),2;let
|
|
368
|
+
`),2;let i;if(o["max-tokens"]!==void 0){let c=Number(o["max-tokens"]);if(!Number.isFinite(c)||c<=0)return process.stderr.write(`
|
|
364
369
|
error: --max-tokens must be a positive number (got "${o["max-tokens"]}")
|
|
365
370
|
|
|
366
|
-
`),2;
|
|
371
|
+
`),2;i=Math.floor(c)}let p=b.resolve(d);try{let c=ue(p),v;if(c==="compiled")v=qe(p,ie(p),s,{maxTokens:i});else if(c==="memory-dir")v=bo(p,s,{maxTokens:i});else return process.stderr.write(`
|
|
367
372
|
error: ${p} is neither a compiled workspace (.minnimemory/manifest.json) nor a manifest-less memory directory (an index file plus topic files) - nothing for recall to query
|
|
368
373
|
|
|
369
|
-
`),2;return process.stdout.write(
|
|
370
|
-
error: ${
|
|
374
|
+
`),2;return process.stdout.write(At(v,o.headings===!0)),0}catch(c){return c instanceof L||c instanceof vo?(process.stderr.write(`
|
|
375
|
+
error: ${c.message}
|
|
371
376
|
|
|
372
377
|
`),2):(process.stderr.write(`
|
|
373
|
-
unexpected error: ${
|
|
378
|
+
unexpected error: ${c.stack??String(c)}
|
|
374
379
|
|
|
375
|
-
`),2)}}if(
|
|
380
|
+
`),2)}}if(n==="hook"){let s="";try{s=C.readFileSync(0,"utf8")}catch{s=""}let i;if(o["max-tokens"]!==void 0){let p=Number(o["max-tokens"]);Number.isFinite(p)&&p>0&&(i=Math.floor(p))}try{let p=me(s),c=xo(p,{headings:o.headings===!0,maxTokens:i,dir:o.dir});c&&process.stdout.write(`${c}
|
|
376
381
|
`)}catch(p){process.stderr.write(`
|
|
377
382
|
hook: ${p.message??String(p)}
|
|
378
|
-
`)}return 0}if(
|
|
379
|
-
`)}catch(
|
|
380
|
-
drift: ${
|
|
381
|
-
`)}return 0}if(
|
|
382
|
-
`),0):(process.stdout.write(
|
|
383
|
-
`),0):(process.stdout.write(
|
|
383
|
+
`)}return 0}if(n==="loaded"){let s="";try{s=C.readFileSync(0,"utf8")}catch{s=""}try{So(JSON.parse(s))}catch{}return 0}if(n==="drift"){let s="";try{s=C.readFileSync(0,"utf8")}catch{s=""}try{let i=me(s),p=$o(i);p&&process.stdout.write(`${p}
|
|
384
|
+
`)}catch(i){process.stderr.write(`
|
|
385
|
+
drift: ${i.message??String(i)}
|
|
386
|
+
`)}return 0}if(n==="bench")try{let s=b.resolve(d),i=ie(s),p=o.turns===void 0?50:Number(o.turns);if(!Number.isFinite(p))throw new I(`--turns must be a positive whole number (got "${o.turns}")`);let c=ae(i,p);if(o.workload===void 0)return o.json===!0?(process.stdout.write(`${JSON.stringify({bounds:c,tokenizer:i.tokenizer},null,2)}
|
|
387
|
+
`),0):(process.stdout.write(ve(c,i.tokenizer)),process.stdout.write(Ho()),0);let v=Po(o.workload),x=No(i,v,o["whole-files"]===!0?{}:{root:s});return o.json===!0?(process.stdout.write(`${JSON.stringify({bounds:c,model:x,tokenizer:i.tokenizer},null,2)}
|
|
388
|
+
`),0):(process.stdout.write(ve(c,i.tokenizer)),process.stdout.write(Io(x,i.tokenizer)),0)}catch(s){return s instanceof I||s instanceof L?(process.stderr.write(`
|
|
384
389
|
error: ${s.message}
|
|
385
390
|
|
|
386
391
|
`),2):(process.stderr.write(`
|
|
387
392
|
unexpected error: ${s.stack??String(s)}
|
|
388
393
|
|
|
389
|
-
`),2)}if(
|
|
390
|
-
error: unknown command "${
|
|
391
|
-
${
|
|
392
|
-
error: run init first: doctor checks memory init has already looked at, and init has no record for this project and ${d} has not been compiled. Run \`${
|
|
394
|
+
`),2)}if(n!=="doctor")return process.stderr.write(`
|
|
395
|
+
error: unknown command "${n}"
|
|
396
|
+
${Z}`),2;if(!Ft(d))return process.stderr.write(`
|
|
397
|
+
error: run init first: doctor checks memory init has already looked at, and init has no record for this project and ${d} has not been compiled. Run \`${We(d)}\`.
|
|
393
398
|
|
|
394
|
-
`),2;let
|
|
399
|
+
`),2;let A;try{let s;if(o.policy!==void 0)try{s=Qe(o.policy)}catch(i){throw i instanceof Ve?new Error(`--policy: ${i.message}`):i}A={discover:D,budget:tt(o.budget)??s?.budgets.always_on_tokens,budgetFromPolicy:o.budget===void 0&&s?.budgets.always_on_tokens!==void 0,policy:s,failOn:Dt(o["fail-on"],"high"),only:et(o.only),ignore:et(o.ignore),force:o.force===!0}}catch(s){return process.stderr.write(`
|
|
395
400
|
error: ${s.message}
|
|
396
401
|
|
|
397
|
-
`),2}try{let s=
|
|
398
|
-
`);else{let
|
|
402
|
+
`),2}try{let s=he(d,A);if(o.json)process.stdout.write(`${ye(s,a)}
|
|
403
|
+
`);else{let i=!o.ci&&!process.env.NO_COLOR&&process.stdout.isTTY===!0;process.stdout.write(ge(s,{color:i,ci:o.ci===!0,target:a,diff:l}))}return Ro(s.audit.findings,s.config.failOn)}catch(s){return s instanceof X||s instanceof W?(process.stderr.write(`
|
|
399
404
|
error: ${s.message}
|
|
400
405
|
|
|
401
406
|
`),2):(process.stderr.write(`
|
|
402
407
|
unexpected error: ${s.stack??String(s)}
|
|
403
408
|
|
|
404
|
-
`),2)}}function
|
|
409
|
+
`),2)}}function Gt(e){try{return C.realpathSync(e)}catch{return b.resolve(e)}}function Wt(){let e=process.argv[1];if(!e)return!1;try{return C.realpathSync(jt(import.meta.url))===C.realpathSync(e)}catch{return!1}}Wt()&&(process.exitCode=Jt(process.argv.slice(2)));export{Tt as MCP_STASHED,Rt as defaultCommand,Jt as main};
|
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 $,n as ee,o as re,p as oe}from"./chunks/chunk-
|
|
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-7JYDJPVH.js";import{$ as f,$a as w,Aa as C,Ca as P,Ia as M,M as E,N as O,Q as S,Ra as N,Sa as H,Ta as v,Ua as A,Va as U,Wa as W,Xa as g,Ya as h,Za as B,_a as K,a as e,aa as c,ab as G,ba as m,bb as V,c as r,d as o,da as I,db as b,e as t,ea as F,f as p,fa as T,fb as J,g as l,h as n,i as a,j as i,k as d,ka as _,l as y,oa as D,pb as Y,qb as Z,ra as x,rb as j,u as s,wa as R,xa as L,ya as k,za as u}from"./chunks/chunk-M7V2YVAQ.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};
|