minnimemory 1.3.6 → 1.3.7
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 +27 -1
- package/README.md +4 -0
- package/package.json +21 -7
- package/pkg/chunks/{chunk-XOD4IZ2R.js → chunk-B5ETYKWT.js} +23 -21
- package/pkg/chunks/chunk-CR5T6SUD.js +162 -0
- package/pkg/chunks/{mcpServer-FRGKYD56.js → mcpServer-2FYD5LS3.js} +1 -1
- package/pkg/cli.js +70 -68
- package/pkg/index.js +1 -1
- package/pkg/chunks/chunk-LUEIBOGU.js +0 -157
package/pkg/cli.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
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 t}function G(e){return`${e.onDemandFile}:${e.startLine}`}function
|
|
5
|
-
`)}function
|
|
6
|
-
`)}function
|
|
7
|
-
`)}import O from"node:fs";import M from"node:path";function I(e){let n=
|
|
8
|
-
${e}`:e);return n.servedDirect?c.includes(t(n.servedDirect)):c.includes("npx -y minnimemory mcp")}function
|
|
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
|
|
10
|
-
`),path:t};let r=
|
|
11
|
-
`),path:t}}function
|
|
12
|
-
`),path:t};if(!O.existsSync(t))return{exitCode:0,output:`hook: nothing to remove (${t} does not exist)`,path:t};let r=
|
|
13
|
-
`),path:t})}function
|
|
3
|
+
import{$ as Ge,$a as de,A as Pe,Aa as rt,B as De,Ba as W,Ca as ot,E as Ae,F as Ee,G as E,H as X,Ha as st,I as Ie,K as Ne,Ka as it,L as D,M as Q,N as Fe,O as Z,P as Le,Q as Be,R as He,S as Ue,Sa as at,Ta as dt,U as H,Ua as se,V as Je,W as _e,X as We,Xa as lt,Za as ie,_a as ae,aa as qe,ab as ut,b as P,ba as ze,bb as ct,ca as Ye,cb as pt,da as Ke,db as ft,ea as ee,eb as mt,fa as Ve,fb as le,g,ga as Xe,gb as ue,j as xe,la as Qe,n as Ce,na as te,o as Se,p as Oe,q as Me,qa as U,r as je,ra as ne,s as K,sa as J,t as V,ta as _,ua as re,v as Te,va as oe,w as Re,wa as Ze,xa as et,ya as tt,za as nt}from"./chunks/chunk-CR5T6SUD.js";import{spawnSync as Zt}from"node:child_process";import S from"node:fs";import en from"node:os";import x from"node:path";import{fileURLToPath as tn}from"node:url";import{parseArgs as nn}from"node:util";import Nt from"node:fs";function Ft(e){return e.split(/\r?\n/).map(n=>n.trim()).filter(n=>n!==""&&!n.startsWith("#"))}function ht(e){let n;try{n=Nt.readFileSync(e,"utf8")}catch{throw new D(`cannot read workload file: ${e}`)}let t=Ft(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 Lt(e){return`${e.onDemandFile} > ${e.heading}`}function Bt(e,n){let t=P(e).flatMap(o=>Ce({name:o.name,file:o.file},Ie(n,o.file)));return Se(t,new Map(P(e).map(o=>[o.name,o.triggers])))}function gt(e,n,t={}){let o=t.root?Bt(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),Lt(i)),l.set(G(i),i.onDemandFile);let y=[],v=0;n.forEach((i,h)=>{let C=o?Me(Oe(o,i)).map(f=>G(f.unit)):je(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 Ht(e,n){return n===0?"0.0%":`${(e/n*100).toFixed(1)}%`}function ce(e){return e>=0?`saves ${g(e)}`:`costs ${g(-e)} more`}function pe(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, ${ce(e.bestCaseSaving)} (${Ht(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, ${ce(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
|
+
`)}function yt(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(` ${ce(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
|
+
`)}function wt(){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 M from"node:path";function I(e){let n=Re(e);return n&&Pe(n)?n:void 0}function bt(e){return De(e)??`"${e.replace(/"/g,'\\"')}"`}function T(e){return e.map(bt).join(" ")}function $t(e){return e.map(bt)}function kt(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"}function xt(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=Ut(e.host);m&&(w.hostConfigPath=m)}return w}function Ct(e){return e.error!==void 0&&e.error.code==="ENOENT"}var me="npx -y minnimemory drift";function Jt(e){let n=I(e);return n?`node "${n}" drift`:me}var he="npx -y minnimemory hook";function _t(e){let n=I(e);return n?`node "${n}" hook`:he}function Wt(e){return typeof e=="string"&&(e===he||ge(e,"hook"))}function Gt(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 qt(e){let n=/Scope:\s*(User|Project|Local)\b/i.exec(e);return n?n[1].toLowerCase():void 0}function ge(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)||zt(o)}function zt(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 Yt(e){return typeof e=="string"&&(e===me||ge(e,"drift"))}var ye="npx -y minnimemory loaded";function Kt(e){let n=I(e);return n?`node "${n}" loaded`:ye}function Vt(e){return typeof e=="string"&&(e===ye||ge(e,"loaded"))}function St(e){let n=Jt(e),t=_t(e),o=Kt(e);return[{event:"UserPromptSubmit",command:n,fallback:me,isOurs:r=>r===n||Yt(r)},{event:"UserPromptSubmit",command:t,fallback:he,isOurs:r=>r===t||Wt(r)},{event:"InstructionsLoaded",command:o,fallback:ye,isOurs:r=>r===o||Vt(r)}]}function Ot(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 Mt(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 jt(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 Tt(e,n){let t=`${JSON.stringify(n,null,2)}
|
|
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 Rt(e){let n=e.hooks;return n&&typeof n=="object"&&!Array.isArray(n)?n:void 0}function Xt(e,n){let t=Ot(e.scope,n),o=St(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=jt(t);if(!r)return{exitCode:1,output:`install --hook: ${t} is not valid JSON; not touched.`,path:t};let c=Rt(r)??{},u=[],d=!1;for(let l of o){let y=Array.isArray(c[l.event])?[...c[l.event]]:[],v=Mt(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}),Tt(t,r)),{exitCode:0,output:u.join(`
|
|
11
|
+
`),path:t}}function vt(e,n){let t=Ot(e.scope,n),o=St(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=jt(t);if(!r)return{exitCode:1,output:`install --remove: ${t} is not valid JSON; not touched.`,path:t};let c=Rt(r),u=[];for(let d of o){let l=c&&Array.isArray(c[d.event])?c[d.event]:void 0,y=l?Mt(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,Tt(t,r),{exitCode:0,output:u.join(`
|
|
13
|
+
`),path:t})}function Pt(e,n,t){let o=xt(e,n),r=[];if(e.dryRun){r.push(`would run: ${T(o.removeArgv)}`);let l=vt({...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(
|
|
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=
|
|
15
|
+
`}}let c=t(o.probeArgv[0],o.probeArgv.slice(1)),u=0;if(Ct(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
|
+
${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=vt(e,n);return r.push(d.output),d.exitCode!==0&&(u=d.exitCode),{exitCode:u,output:`${r.join(`
|
|
17
17
|
`)}
|
|
18
|
-
`}}function
|
|
18
|
+
`}}function Qt(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 fe(e,n,t,o){if(e.hook){let r=Xt(e,n);t.push(r.output),r.exitCode!==0&&(o=r.exitCode)}return o===0&&t.push(Qt(e.cliPath)),{exitCode:o,output:`${t.join(`
|
|
19
19
|
`)}
|
|
20
|
-
`}}function
|
|
20
|
+
`}}function Dt(e,n,t){let o=xt(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: ${T(o.removeArgv)}`),r.push(`would run: ${T(o.addArgv)}`);let k=
|
|
23
|
+
`};if(e.dryRun){e.force&&r.push(`would run: ${T(o.removeArgv)}`),r.push(`would run: ${T(o.addArgv)}`);let k=kt(o);return k&&r.push(k),fe(e,n,r,0)}let c=t(o.probeArgv[0],o.probeArgv.slice(1));if(Ct(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?
|
|
25
|
+
`};let u=t(o.getArgv[0],o.getArgv.slice(1)),d=u.code===0?qt(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&&!Gt(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"]:[]])}`),fe(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
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
|
-
`};w.stdout.trim()&&r.push(w.stdout.trim());let m=
|
|
30
|
-
minnimemory ${
|
|
29
|
+
`};w.stdout.trim()&&r.push(w.stdout.trim());let m=kt(o);return m&&r.push(m),fe(e,n,r,0)}var rn=!1,q=`
|
|
30
|
+
minnimemory ${ue} the agent memory compiler
|
|
31
31
|
|
|
32
32
|
usage: the four lifecycle verbs, the CLI and the MCP basic profile share.
|
|
33
33
|
The only difference is who writes: the CLI writes to disk itself, the MCP tools return the
|
|
@@ -193,8 +193,8 @@ doctor options
|
|
|
193
193
|
<folder> is required: a repo, a memory directory, or a single file. With none, minnimemory asks
|
|
194
194
|
for it (in a terminal) or stops and says so. Type . for the current folder. An @import that
|
|
195
195
|
points outside the folder is not read; the report names it.
|
|
196
|
-
`;function
|
|
197
|
-
`)}function
|
|
196
|
+
`;function on(){let e=[""," rule set",""];for(let n of Ue)e.push(` ${n.id.padEnd(8)}${n.severity.padEnd(6)}${n.title}`);return e.push(""),e.join(`
|
|
197
|
+
`)}function sn(e,n){if(e===void 0)return n;if(e==="low"||e==="med"||e==="high")return e;throw new Error(`--fail-on must be one of low, med, high (got "${e}")`)}function At(e){return e?e.split(",").map(n=>n.trim()).filter(Boolean):[]}function an(e,n){return e.matches.length===0?`
|
|
198
198
|
no match for "${e.query}"
|
|
199
199
|
|
|
200
200
|
`:n?`${e.matches.map(t=>`${t.onDemandFile} > ${t.path.join(" > ")} (${t.tokens} tokens)`).join(`
|
|
@@ -206,7 +206,7 @@ ${t.content}`).join(`
|
|
|
206
206
|
---
|
|
207
207
|
|
|
208
208
|
`)}
|
|
209
|
-
`}function
|
|
209
|
+
`}function dn(e){return e.isTTY?"usage":"serve"}function Et(){return(e,n)=>{let t=process.platform==="win32",o=Zt(e,t?$t(n):n,{encoding:"utf8",shell:t});return{code:o.status,stdout:o.stdout??"",stderr:o.stderr??"",error:o.error}}}function ln(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 un(e){if(e!==void 0){if(e==="cursor"||e==="windsurf"||e==="json")return e;throw new Error(`--host must be one of cursor, windsurf, json (got "${e}")`)}}function It(e){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<=0||n>K)throw new Error(`--budget must be a whole number of tokens from 1 to ${K.toLocaleString("en-US")} (got "${e}")`);return Math.floor(n)}function cn(e,n){let t;try{if(t=x.resolve(e),!S.existsSync(t)||!S.statSync(t).isDirectory())throw new E(`not a directory: ${t}`)}catch(r){return r instanceof E?(process.stderr.write(`
|
|
210
210
|
error: ${r.message}
|
|
211
211
|
|
|
212
212
|
`),2):(process.stderr.write(`
|
|
@@ -215,66 +215,68 @@ ${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-2FYD5LS3.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
|
-
`),process.exitCode=1}),0)}function
|
|
221
|
-
`)}var
|
|
220
|
+
`),process.exitCode=1}),0)}function pn(){let e=rt(),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(` ${Ae(t)}`)}return n.push(`kept: ${x.dirname(et())} (init records, the load log, undo backups); delete it yourself once you have checked undo-backups/.`),n.push("restart Claude Code."),n.join(`
|
|
221
|
+
`)}var fn=new Set(["init","doctor","apply","undo","bench"]);function mn(e){if(W(process.cwd()))return!0;let n=we(e);return ne(n)==="compiled"||oe(n)!==void 0||Z(n)!==void 0}function we(e){let n=x.resolve(e);return S.existsSync(n)&&S.statSync(n).isFile()?x.dirname(n):n}function hn(e){if(W(process.cwd()))return;let n=we(e);return Z(n)?Fe(n):void 0}function gn(e){let n=`minnimemory ${e} <folder>`;if(process.stdin.isTTY!==!0){process.stderr.write(`
|
|
222
222
|
error: name the folder to read: ${n} (type . for the current folder)
|
|
223
223
|
|
|
224
224
|
`);return}process.stdout.write(`
|
|
225
225
|
Which folder should minnimemory ${e} read? Only that folder and the folders below it are read.
|
|
226
|
-
folder: `);let t=
|
|
226
|
+
folder: `);let t=yn().trim();if(t===""){process.stderr.write(`
|
|
227
227
|
error: no folder given; run ${n}
|
|
228
228
|
|
|
229
|
-
`);return}return t}function
|
|
230
|
-
`)break;o!=="\r"&&(n+=o)}return n}function
|
|
229
|
+
`);return}return t}function yn(){let e=Buffer.alloc(1),n="";for(;;){let t;try{t=S.readSync(0,e,0,1,null)}catch{break}if(t===0)break;let o=e.toString("utf8");if(o===`
|
|
230
|
+
`)break;o!=="\r"&&(n+=o)}return n}function wn(e){let n;try{n=nn({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 a=s.message,p=/argument is ambiguous/.test(a)?`
|
|
231
231
|
(a value that starts with '-' must be written as --option=value; --budget must be positive anyway)`:"";return process.stderr.write(`
|
|
232
232
|
error: ${a}${p}
|
|
233
|
-
${q}`),2}let{values:t,positionals:o}=n;if(t.help)return process.stdout.write(q),0;if(t.version)return process.stdout.write(`${
|
|
234
|
-
`),0;if(t.rules)return process.stdout.write(
|
|
235
|
-
`);let u=o[1]===void 0?void 0:/^~($|[\\/])/.test(o[1])?J(o[1]):o[1];if(u===void 0&&typeof t["memory-dir"]=="string"&&(u=t["memory-dir"]),u===void 0&&["doctor","apply","undo"].includes(r)){let s=W(process.cwd());s&&(u=s.target??s.memoryDir??s.project)}if(u===void 0&&
|
|
233
|
+
${q}`),2}let{values:t,positionals:o}=n;if(t.help)return process.stdout.write(q),0;if(t.version)return process.stdout.write(`${ue}
|
|
234
|
+
`),0;if(t.rules)return process.stdout.write(on()),0;let r;if(o[0]===void 0){if(dn({isTTY:process.stdin.isTTY===!0})==="usage")return process.stdout.write(q),0;r="mcp"}else r=o[0];let c=["include-auto-memory","follow-external-imports","auto-memory"].filter(s=>t[s]===!0);c.length>0&&process.stderr.write(` note: ${c.map(s=>`--${s}`).join(", ")} no longer does anything: minnimemory reads only the folder you name
|
|
235
|
+
`);let u=o[1]===void 0?void 0:/^~($|[\\/])/.test(o[1])?J(o[1]):o[1];if(u===void 0&&typeof t["memory-dir"]=="string"&&(u=t["memory-dir"]),u===void 0&&["doctor","apply","undo"].includes(r)){let s=W(process.cwd());s&&(u=s.target??s.memoryDir??s.project)}if(u===void 0&&fn.has(r)&&(u=gn(r),u===void 0))return 2;let d=u??".";if(t.policy!==void 0&&r!=="doctor")return process.stderr.write(`
|
|
236
236
|
error: --policy is a doctor option: \`minnimemory doctor <folder> --policy <file>\`
|
|
237
237
|
|
|
238
238
|
`),2;if(t.diff!==void 0&&t.diff!=="summary"&&t.diff!=="full")return process.stderr.write(`
|
|
239
239
|
error: --diff takes summary or full, not "${t.diff}"
|
|
240
240
|
|
|
241
|
-
`),2;let l=t.diff,y=[...t.loaded??[],...t["host-file"]??[]].map(s=>J(s));if(t["from-log"]===!0){let s=
|
|
241
|
+
`),2;let l=t.diff,y=[...t.loaded??[],...t["host-file"]??[]].map(s=>J(s));if(t["from-log"]===!0){let s=ut(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:
|
|
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:
|
|
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:hn(d),j=m?void 0:ot(process.cwd())??(k?Le(we(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:ln(t.scope),dryRun:t["dry-run"]===!0,force:t.force===!0,host:un(t.host),hook:t.host===void 0&&t["no-hook"]!==!0,cliPath:process.argv[1]?kn(process.argv[1]):void 0}}catch(C){return process.stderr.write(`
|
|
246
246
|
error: ${C.message}
|
|
247
247
|
|
|
248
|
-
`),2}let a={home:
|
|
248
|
+
`),2}let a={home:en.homedir(),platform:process.platform,cwd:process.cwd(),configDir:Te()},p=r==="uninstall"||t.remove===!0,i=p?Pt(s,a,Et()):Dt(s,a,Et()),h=i.exitCode===0?process.stdout:process.stderr;return h.write(`
|
|
249
249
|
${i.output}
|
|
250
|
-
`),p&&h.write(`${
|
|
250
|
+
`),p&&h.write(`${pn()}
|
|
251
251
|
|
|
252
252
|
`),i.exitCode}if(r==="init"||r==="apply"){if(r==="init"&&(t.write===!0||t.update===!0))return process.stderr.write(`
|
|
253
253
|
error: init never writes; use apply
|
|
254
254
|
|
|
255
|
-
`),2;let s=t.profile??"auto";if(s!=="auto"
|
|
255
|
+
`),2;let s=t.profile??"auto";if(s!=="auto"&&!xe(s))return process.stderr.write(`
|
|
256
256
|
error: --profile must be one of auto, none, routing, full (got "${s}")
|
|
257
257
|
|
|
258
|
-
`),2;let a;try{a=
|
|
258
|
+
`),2;let a;try{a=It(t.budget)}catch(b){return process.stderr.write(`
|
|
259
259
|
error: ${b.message}
|
|
260
260
|
|
|
261
|
-
`),2}let p=r==="apply",i=s==="auto"?void 0:s,h=t["episodic-json"]===!0,C=[...i?[`--profile ${i}`]:[],...h?["--episodic-json"]:[],...t["only-this-folder"]===!0?["--only-this-folder"]:[]],$={budget:a,force:t.force===!0,profileName:i,episodicJson:h,discover:R};try{if(!p){let
|
|
262
|
-
`:
|
|
263
|
-
`)}else process.stdout.write(
|
|
261
|
+
`),2}let p=r==="apply",i=s==="auto"?void 0:s,h=t["episodic-json"]===!0,C=[...i?[`--profile ${i}`]:[],...h?["--episodic-json"]:[],...t["only-this-folder"]===!0?["--only-this-folder"]:[]],$={budget:a,force:t.force===!0,profileName:i,episodicJson:h,discover:R};try{if(!p){let ke=S.existsSync(d)&&S.statSync(d).isFile()?x.dirname(x.resolve(d)):x.resolve(d),N;try{let B=_(d,R);B.shape==="memory-dir"&&(N=B)}catch{N=void 0}let F=N?mt(N):pt(ke,{machine:!1,projectRoot:ke});if(t.map===!0)return process.stdout.write(t.json?`${JSON.stringify(F,null,2)}
|
|
262
|
+
`:le(F)),0;t.json||process.stdout.write(le(F));let L=ie(d,$);if(t.json){let B=JSON.parse(de(L,u,C));process.stdout.write(`${JSON.stringify({map:ft(F),...B},null,2)}
|
|
263
|
+
`)}else process.stdout.write(ae(L,{color:!1,ci:t.ci===!0,target:u,flags:C,diff:l}));let Y=L.workspace.folderRoot??x.resolve(d),ve=L.workspace.claudeMemoryFolder?Y:void 0,be=tt(process.cwd(),m?{...m,...m.memoryDir??ve?{memoryDir:m.memoryDir??ve}:{}}:void 0,Y);m&&!t.json&&process.stdout.write(be?` saved what Claude Code loads here for apply, doctor and undo: ${be}
|
|
264
264
|
|
|
265
265
|
`:` could not save the locations; pass them again to apply
|
|
266
266
|
|
|
267
|
+
`);let $e=nt(process.cwd(),Y);return $e&&process.stderr.write(` ${$e}
|
|
268
|
+
|
|
267
269
|
`),0}let b=_(d,R);if(b.shape==="memory-dir"&&!b.reported)return process.stderr.write(`
|
|
268
270
|
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.
|
|
269
271
|
|
|
270
|
-
`),2;let f=
|
|
272
|
+
`),2;let f=_e(b,{budget:a??b.manifest?.budget,profileName:i,episodicJson:h});if(t.plan!==void 0&&f.plan!==t.plan)return process.stderr.write(`
|
|
271
273
|
error: the plan on disk no longer matches --plan ${t.plan} (now ${f.plan}); run doctor again
|
|
272
274
|
|
|
273
|
-
`),2;if(f.verdict==="nothing")return process.stdout.write(
|
|
274
|
-
error: ${
|
|
275
|
+
`),2;if(f.verdict==="nothing")return process.stdout.write(te(f,{write:!0})),0;if(f.verdict==="leave"&&t.force!==!0)return process.stderr.write(`
|
|
276
|
+
error: ${Qe(f)} (${f.before} -> ${f.after} tokens; break-even ${f.bounds.breakEvenCarriedTokens} tokens of OnDemandMemory open all session)
|
|
275
277
|
Pass --force to write it anyway.
|
|
276
278
|
|
|
277
|
-
`),2;let z=
|
|
279
|
+
`),2;let z=te(f,{write:!0,target:u});return We(f,{allowSecrets:t["allow-secrets"]===!0}),process.stdout.write(z),0}catch(b){return b instanceof U||b instanceof H?(process.stderr.write(`
|
|
278
280
|
error: ${b.message}
|
|
279
281
|
|
|
280
282
|
`),2):(process.stderr.write(`
|
|
@@ -283,26 +285,26 @@ ${i.output}
|
|
|
283
285
|
`),2)}}if(r==="undo")try{let s;try{s=_(d).folderRoot}catch($){if(!($ instanceof U))throw $}if(!s)return process.stdout.write(`
|
|
284
286
|
nothing to undo
|
|
285
287
|
|
|
286
|
-
`),0;let a=
|
|
287
|
-
error: ${
|
|
288
|
+
`),0;let a=oe(s),p=a?void 0:Ze(s),i=p?Xe(s,p):!a&&re(s)?Ye(s):ze(s,a);if(i.kind==="none")return!a&&re(s)?(process.stderr.write(`
|
|
289
|
+
error: ${Je(s)}
|
|
288
290
|
|
|
289
291
|
`),2):(process.stdout.write(`
|
|
290
292
|
nothing to undo
|
|
291
293
|
|
|
292
294
|
`),0);if(i.kind==="kept-only")return process.stderr.write(`
|
|
293
|
-
error: undo has nothing left to restore here: ${
|
|
295
|
+
error: undo has nothing left to restore here: ${Ke(i.kept)}
|
|
294
296
|
|
|
295
297
|
`),2;if(i.kind==="missing-original")return process.stderr.write(`
|
|
296
|
-
error: no original copy under ${
|
|
298
|
+
error: no original copy under ${V}/original/ for: ${i.files.join(", ")}.
|
|
297
299
|
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.
|
|
298
300
|
|
|
299
|
-
`),2;let h=
|
|
301
|
+
`),2;let h=Ge(i.plan);if(h&&t.force!==!0)return process.stderr.write(`
|
|
300
302
|
error: ${h}
|
|
301
303
|
|
|
302
|
-
`),2;let C=h?
|
|
304
|
+
`),2;let C=h?qe(i.plan):void 0;return Ve(i.plan),process.stdout.write(`
|
|
303
305
|
restored ${i.plan.operations.filter($=>$.op==="write"||$.op==="move").length} file(s) in ${s}
|
|
304
|
-
deleted: ${i.plan.operations.filter($=>$.op==="delete").length} path(s), ${
|
|
305
|
-
`+(
|
|
306
|
+
deleted: ${i.plan.operations.filter($=>$.op==="delete").length} path(s), ${V}/ ${i.plan.keptBackups?.length?"kept":"included"}
|
|
307
|
+
`+(ee(i.plan)?` ${ee(i.plan)}
|
|
306
308
|
`:"")+(i.plan.left?.length?` left in place: ${i.plan.left.join(", ")} (without manifest.json undo cannot tell which files there it wrote)
|
|
307
309
|
`:"")+(C?` the files as they were before this undo are copied to ${C.split(x.sep).join("/")}
|
|
308
310
|
`:"")+`
|
|
@@ -312,35 +314,35 @@ ${i.output}
|
|
|
312
314
|
`),2):(process.stderr.write(`
|
|
313
315
|
unexpected error: ${s.stack??String(s)}
|
|
314
316
|
|
|
315
|
-
`),2)}if(r==="mcp")return
|
|
317
|
+
`),2)}if(r==="mcp")return rn?((async()=>{let[{StdioServerTransport:s},{createDisabledMcpServer:a,DISABLED_MESSAGE:p}]=await Promise.all([import("@modelcontextprotocol/sdk/server/stdio.js"),import("./chunks/mcpServer-2FYD5LS3.js")]);process.stderr.write(`
|
|
316
318
|
mcp: ${p}
|
|
317
319
|
|
|
318
320
|
`),await a().connect(new s)})().catch(s=>{process.stderr.write(`
|
|
319
321
|
mcp server failed: ${s.message??String(s)}
|
|
320
|
-
`),process.exitCode=1}),0):
|
|
322
|
+
`),process.exitCode=1}),0):cn(d,t);if(r==="recall"){let s=o.slice(2).join(" ").trim();if(!s)return process.stderr.write(`
|
|
321
323
|
error: recall needs a query: minnimemory recall <path> <query...>
|
|
322
324
|
|
|
323
325
|
`),2;let a;if(t["max-tokens"]!==void 0){let i=Number(t["max-tokens"]);if(!Number.isFinite(i)||i<=0)return process.stderr.write(`
|
|
324
326
|
error: --max-tokens must be a positive number (got "${t["max-tokens"]}")
|
|
325
327
|
|
|
326
|
-
`),2;a=Math.floor(i)}let p=x.resolve(d);try{let i=
|
|
328
|
+
`),2;a=Math.floor(i)}let p=x.resolve(d);try{let i=ne(p),h;if(i==="compiled")h=Ne(p,X(p),s,{maxTokens:a});else if(i==="memory-dir")h=it(p,s,{maxTokens:a});else return process.stderr.write(`
|
|
327
329
|
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
|
|
328
330
|
|
|
329
|
-
`),2;return process.stdout.write(
|
|
331
|
+
`),2;return process.stdout.write(an(h,t.headings===!0)),0}catch(i){return i instanceof E||i instanceof st?(process.stderr.write(`
|
|
330
332
|
error: ${i.message}
|
|
331
333
|
|
|
332
334
|
`),2):(process.stderr.write(`
|
|
333
335
|
unexpected error: ${i.stack??String(i)}
|
|
334
336
|
|
|
335
|
-
`),2)}}if(r==="hook"){let s="";try{s=S.readFileSync(0,"utf8")}catch{s=""}let a;if(t["max-tokens"]!==void 0){let p=Number(t["max-tokens"]);Number.isFinite(p)&&p>0&&(a=Math.floor(p))}try{let p=
|
|
337
|
+
`),2)}}if(r==="hook"){let s="";try{s=S.readFileSync(0,"utf8")}catch{s=""}let a;if(t["max-tokens"]!==void 0){let p=Number(t["max-tokens"]);Number.isFinite(p)&&p>0&&(a=Math.floor(p))}try{let p=se(s),i=at(p,{headings:t.headings===!0,maxTokens:a,dir:t.dir});i&&process.stdout.write(`${i}
|
|
336
338
|
`)}catch(p){process.stderr.write(`
|
|
337
339
|
hook: ${p.message??String(p)}
|
|
338
|
-
`)}return 0}if(r==="loaded"){let s="";try{s=S.readFileSync(0,"utf8")}catch{s=""}try{
|
|
340
|
+
`)}return 0}if(r==="loaded"){let s="";try{s=S.readFileSync(0,"utf8")}catch{s=""}try{ct(JSON.parse(s))}catch{}return 0}if(r==="drift"){let s="";try{s=S.readFileSync(0,"utf8")}catch{s=""}try{let a=se(s),p=dt(a);p&&process.stdout.write(`${p}
|
|
339
341
|
`)}catch(a){process.stderr.write(`
|
|
340
342
|
drift: ${a.message??String(a)}
|
|
341
|
-
`)}return 0}if(r==="bench")try{let s=x.resolve(d),a=
|
|
342
|
-
`),0):(process.stdout.write(
|
|
343
|
-
`),0):(process.stdout.write(
|
|
343
|
+
`)}return 0}if(r==="bench")try{let s=x.resolve(d),a=X(s),p=t.turns===void 0?50:Number(t.turns);if(!Number.isFinite(p))throw new D(`--turns must be a positive whole number (got "${t.turns}")`);let i=Q(a,p);if(t.workload===void 0)return t.json===!0?(process.stdout.write(`${JSON.stringify({bounds:i,tokenizer:a.tokenizer},null,2)}
|
|
344
|
+
`),0):(process.stdout.write(pe(i,a.tokenizer)),process.stdout.write(wt()),0);let h=ht(t.workload),C=gt(a,h,t["whole-files"]===!0?{}:{root:s});return t.json===!0?(process.stdout.write(`${JSON.stringify({bounds:i,model:C,tokenizer:a.tokenizer},null,2)}
|
|
345
|
+
`),0):(process.stdout.write(pe(i,a.tokenizer)),process.stdout.write(yt(C,a.tokenizer)),0)}catch(s){return s instanceof D||s instanceof E?(process.stderr.write(`
|
|
344
346
|
error: ${s.message}
|
|
345
347
|
|
|
346
348
|
`),2):(process.stderr.write(`
|
|
@@ -348,17 +350,17 @@ ${i.output}
|
|
|
348
350
|
|
|
349
351
|
`),2)}if(r!=="doctor")return process.stderr.write(`
|
|
350
352
|
error: unknown command "${r}"
|
|
351
|
-
${q}`),2;if(!
|
|
352
|
-
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 \`${
|
|
353
|
+
${q}`),2;if(!mn(d))return process.stderr.write(`
|
|
354
|
+
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 \`${Ee(d)}\`.
|
|
353
355
|
|
|
354
|
-
`),2;let A;try{let s;if(t.policy!==void 0)try{s=
|
|
356
|
+
`),2;let A;try{let s;if(t.policy!==void 0)try{s=He(t.policy)}catch(a){throw a instanceof Be?new Error(`--policy: ${a.message}`):a}A={discover:R,budget:It(t.budget)??s?.budgets.always_on_tokens,budgetFromPolicy:t.budget===void 0&&s?.budgets.always_on_tokens!==void 0,policy:s,failOn:sn(t["fail-on"],"high"),only:At(t.only),ignore:At(t.ignore),force:t.force===!0}}catch(s){return process.stderr.write(`
|
|
355
357
|
error: ${s.message}
|
|
356
358
|
|
|
357
|
-
`),2}try{let s=
|
|
358
|
-
`);else{let a=!t.ci&&!process.env.NO_COLOR&&process.stdout.isTTY===!0;process.stdout.write(
|
|
359
|
+
`),2}try{let s=ie(d,A);if(t.json)process.stdout.write(`${de(s,u)}
|
|
360
|
+
`);else{let a=!t.ci&&!process.env.NO_COLOR&&process.stdout.isTTY===!0;process.stdout.write(ae(s,{color:a,ci:t.ci===!0,target:u,diff:l}))}return lt(s.audit.findings,s.config.failOn)}catch(s){return s instanceof U||s instanceof H?(process.stderr.write(`
|
|
359
361
|
error: ${s.message}
|
|
360
362
|
|
|
361
363
|
`),2):(process.stderr.write(`
|
|
362
364
|
unexpected error: ${s.stack??String(s)}
|
|
363
365
|
|
|
364
|
-
`),2)}}function
|
|
366
|
+
`),2)}}function kn(e){try{return S.realpathSync(e)}catch{return x.resolve(e)}}function vn(){let e=process.argv[1];if(!e)return!1;try{return S.realpathSync(tn(import.meta.url))===S.realpathSync(e)}catch{return!1}}vn()&&(process.exitCode=wn(process.argv.slice(2)));export{rn as MCP_STASHED,dn as defaultCommand,wn 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-B5ETYKWT.js";import{Ea as N,Fa as H,G as E,Ga as v,H as O,Ha as A,Ia as U,Ja as W,K as S,Ka as g,La as h,Ma as B,Na as K,Oa as w,Pa as G,Qa as V,S as f,Sa as b,T as c,U as m,Ua as J,Va as Y,W as I,Wa as Z,X as F,Xa as j,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-CR5T6SUD.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};
|