minnimemory 1.4.1 → 1.4.2
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 +119 -0
- package/README.md +15 -7
- package/package.json +1 -1
- package/pkg/chunks/chunk-LN6FDCKX.js +60 -0
- package/pkg/chunks/chunk-Z7KWUKEZ.js +214 -0
- package/pkg/chunks/{mcpServer-2JD64MUD.js → mcpServer-HEZQUR7M.js} +1 -1
- package/pkg/cli.js +145 -149
- package/pkg/index.js +1 -1
- package/pkg/chunks/chunk-7JYDJPVH.js +0 -60
- package/pkg/chunks/chunk-M7V2YVAQ.js +0 -168
package/pkg/cli.js
CHANGED
|
@@ -1,46 +1,28 @@
|
|
|
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
|
|
5
|
-
`)}function
|
|
6
|
-
`)}function
|
|
7
|
-
`)}import
|
|
8
|
-
`)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
`)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
`)}
|
|
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
|
-
`)}
|
|
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
|
-
`)}
|
|
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
|
-
`)}
|
|
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
|
-
`)}
|
|
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
|
-
`)}
|
|
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
|
-
`)}
|
|
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
|
-
`)}
|
|
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
|
-
`)}
|
|
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(`
|
|
3
|
+
import{$ as Ge,$a as yt,A as se,B as Pe,Ba as q,Bb as ye,C as je,Ca as pe,Cb as ge,D as ie,Da as Y,Db as we,Ea as K,Eb as ke,Fa as nt,Ia as st,J as Ne,Ja as fe,K as Le,Ka as me,L as B,La as it,M as ae,Ma as at,N as _e,Na as dt,Oa as lt,P as Fe,Pa as ut,Q as _,Qa as V,R as de,Ra as ct,S as Ie,Sa as pt,T as le,Ta as ft,U as Ae,W as Be,Xa as mt,Y as Ue,Z as He,_ as Je,_a as ht,aa as ze,b as L,ba as We,da as X,ea as Xe,f as Te,fa as qe,g as p,ga as Ye,hb as gt,ib as wt,j as Oe,jb as he,ka as Ke,kb as kt,la as Ve,lb as bt,ma as Qe,mb as vt,n as I,na as Ze,nb as $t,o as J,oa as et,ob as xt,p as G,pa as ue,pb as Ct,q as z,qa as tt,qb as St,r as Ee,ra as ot,rb as Mt,s as Re,sb as Tt,t as re,tb as Ot,u as ne,ub as Et,vb as Rt,w as De,wa as rt,wb as Dt,x as A,y as P,ya as ce,z as W,zb as Pt}from"./chunks/chunk-Z7KWUKEZ.js";import{spawnSync as oo}from"node:child_process";import w from"node:fs";import At from"node:os";import y from"node:path";import{fileURLToPath as ro}from"node:url";import{parseArgs as no}from"node:util";import zt from"node:fs";function Wt(t){return t.split(/\r?\n/).map(n=>n.trim()).filter(n=>n!==""&&!n.startsWith("#"))}function jt(t){let n;try{n=zt.readFileSync(t,"utf8")}catch{throw new _(`cannot read workload file: ${t}`)}let e=Wt(n);if(e.length===0)throw new _(`workload file has no tasks: ${t}
|
|
4
|
+
one task description per line, # for comments`);return e}function Q(t){return`${t.onDemandFile}:${t.startLine}`}function Xt(t){return`${t.onDemandFile} > ${t.heading}`}function qt(t,n){let e=L(t).flatMap(d=>J({name:d.name,file:d.file},_e(n,d.file)));return G(e,new Map(L(t).map(d=>[d.name,d.triggers])))}function Nt(t,n,e={}){let d=e.root?qt(t,e.root):void 0,s=d?"section":"file",h=new Set,u=new Map,l=new Map,T=new Map;for(let o of L(t))u.set(o.name,o.tokens),l.set(o.name,o.name),T.set(o.name,o.name);if(d)for(let o of d.units)u.set(Q(o),o.tokens),l.set(Q(o),Xt(o)),T.set(Q(o),o.onDemandFile);let b=[],v=0;n.forEach((o,i)=>{let a=d?Ee(z(d,o)).map(c=>Q(c.unit)):Re(t,o).filter(c=>c.score>0).map(c=>c.name);a.length===0&&v++;let f=a.filter(c=>!h.has(c));for(let c of f)h.add(c);let g=[...h].reduce((c,k)=>c+(u.get(k)??0),0);b.push({turn:i+1,task:o,opened:f.map(c=>l.get(c)??c),carried:[...h].map(c=>l.get(c)??c),compiledTokens:t.prefix.after+g,baselineTokens:t.prefix.before})});let $=b.reduce((o,i)=>o+i.compiledTokens,0),m=b.reduce((o,i)=>o+i.baselineTokens,0),C=new Set([...h].map(o=>T.get(o)??o)),j=L(t).map(o=>o.name).filter(o=>C.has(o)),O=[...h].reduce((o,i)=>o+(u.get(i)??0),0),S=t.prefix.after+O,D=t.prefix.before-S,M=m-$,r;return M>=0?(r=b.findIndex((o,i)=>b.slice(0,i+1).reduce((f,g)=>f+g.baselineTokens-g.compiledTokens,0)>=0),r=r>=0?r+1:void 0):D>0&&(r=b.length+Math.ceil(-M/D)),{unit:s,turns:b,baselineTotal:m,compiledTotal:$,saving:M,savingPct:m===0?0:M/m*100,onDemandOpened:j,onDemandNeverOpened:L(t).map(o=>o.name).filter(o=>!C.has(o)),unroutedTurns:v,steadyStatePerTurn:S,steadyStateGainPerTurn:D,breakEvenTurn:r}}function Yt(t,n){return n===0?"0.0%":`${(t/n*100).toFixed(1)}%`}function be(t){return t>=0?`saves ${p(t)}`:`costs ${p(-t)} more`}function ve(t,n){let e=[""];return e.push(` exact, over ${p(t.turns)} turns. No workload, no assumptions.`),e.push(""),e.push(` original memory file ${p(t.baselinePerTurn).padStart(8)} tokens per turn`),e.push(` compiled always-loaded ${p(t.compiledPerTurn).padStart(8)} tokens per turn`),e.push(` OnDemandMemory, all of it ${p(t.totalOnDemandTokens).padStart(8)} tokens, on demand`),e.push(""),e.push(" best case, no OnDemandMemory file ever opened"),e.push(` ${p(t.baselineTotal)} -> ${p(t.bestCaseTotal)} tokens, ${be(t.bestCaseSaving)} (${Yt(t.bestCaseSaving,t.baselineTotal)})`),e.push(""),e.push(" worst case, every OnDemandMemory file opened on turn 1 and carried"),e.push(` ${p(t.baselineTotal)} -> ${p(t.worstCaseTotal)} tokens, ${be(t.worstCaseSaving)}`),e.push(""),e.push(` break-even: ${p(t.breakEvenCarriedTokens)} tokens of OnDemandMemory can sit in`),e.push(" context from turn 1 to the end and come out even. Past that the compiled"),e.push(" shape costs more than the file it replaced."),e.push(""),e.push(` tokenizer: ${n}, an offline estimate`),e.push(""),e.join(`
|
|
5
|
+
`)}function Lt(t,n){let e=[""],d=t.turns.length;if(e.push(` MODEL, not a measurement. ${p(d)} turns from the workload you supplied.`),e.push(t.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."),e.push(""),e.push(` memory tokens over the session ${p(t.baselineTotal)} -> ${p(t.compiledTotal)}`),e.push(` ${be(t.saving)}${t.saving>=0?` (${t.savingPct.toFixed(1)}%)`:""}`),e.push(""),t.onDemandOpened.length>0){e.push(` opened and carried (${t.onDemandOpened.length}):`);for(let s of t.onDemandOpened)e.push(` ${s}`);e.push("")}if(t.onDemandNeverOpened.length>0){e.push(` never opened (${t.onDemandNeverOpened.length}) - this is where the saving comes from:`);for(let s of t.onDemandNeverOpened)e.push(` ${s}`);e.push("")}return e.push(" one more turn, once everything this workload opens is in context:"),e.push(` ${p(t.steadyStatePerTurn)} vs ${p(t.turns[0]?.baselineTokens??0)} baseline, ${t.steadyStateGainPerTurn>=0?`saves ${p(t.steadyStateGainPerTurn)}`:`costs ${p(-t.steadyStateGainPerTurn)} more`} per turn`),e.push(""),t.saving<0&&t.steadyStateGainPerTurn<=0?(e.push(" this workload never breaks even. The OnDemandMemory files it opens are large enough that"),e.push(" carrying them costs more every turn than the original file did, so a longer"),e.push(" session loses more, not less. Splitting differently, or not compiling this"),e.push(" file at all, is the honest answer here."),e.push("")):t.saving<0&&t.breakEvenTurn!==void 0?(e.push(` behind by ${p(-t.saving)} at turn ${p(t.turns.length)}, recovering ${p(t.steadyStateGainPerTurn)} per turn:`),e.push(` breaks even around turn ${p(t.breakEvenTurn)} if nothing further opens.`),e.push("")):t.saving>=0&&t.breakEvenTurn!==void 0&&(e.push(` ahead from turn ${p(t.breakEvenTurn)} onward.`),e.push("")),t.unroutedTurns>0&&(e.push(` ${p(t.unroutedTurns)} of ${p(d)} turns matched no OnDemandMemory file at all.`),e.push(" Those turns are cheap here, but a real agent may have needed something and"),e.push(" not been routed to it. Check them before trusting the total."),e.push("")),e.push(" what this number is conditional on:"),e.push(" - your workload being what a real session looks like. It is your file;"),e.push(" the tool cannot tell whether it is representative."),t.unit==="section"?(e.push(" - every section recall() returns being carried for the rest of the session,"),e.push(" up to its token cap per turn. A real agent may widen with outline() or"),e.push(" read the whole file anyway.")):(e.push(" - every OnDemandMemory file whose triggers match being opened in full. A real"),e.push(" agent may read one and stop, or ignore one the list offered.")),e.push(" - memory tokens only. Reasoning, tool results and conversation are excluded"),e.push(" from both sides, so this ratio is not a session bill."),e.push(""),e.push(" For observed usage against a live agent, measure a real multi-turn session with"),e.push(" and without the compile. That is the only path allowed to call a number measured."),e.push(""),e.push(` tokenizer: ${n}, an offline estimate`),e.push(""),e.join(`
|
|
6
|
+
`)}function _t(){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 U from"node:fs";import R from"node:path";var Kt=800,Vt=1200,Ft=1024*1024;function Qt(t){try{let n=JSON.parse(t);if(n.type!=="user"||n.isMeta===!0||n.message?.role!=="user")return;let e=n.message.content;return typeof e=="string"?e.trim()||void 0:!Array.isArray(e)||e.some(s=>s?.type==="tool_result")?void 0:e.filter(s=>s?.type==="text"&&typeof s.text=="string").map(s=>s.text).join(`
|
|
8
|
+
`).trim()||void 0}catch{return}}function Zt(t){if(t)try{let n=U.statSync(t).size;for(let e of n>Ft?[n-Ft,0]:[0]){let d=U.openSync(t,"r"),s;try{let u=Buffer.alloc(n-e);U.readSync(d,u,0,u.length,e),s=u.toString("utf8")}finally{U.closeSync(d)}let h=s.split(`
|
|
9
|
+
`);for(let u=h.length-1;u>=(e>0?1:0);u--){let l=Qt(h[u]);if(l)return l}}}catch{}}function eo(t,n){if(!n)return;let e=ft(R.resolve(n));if(!e)return;let d=R.resolve(t);if(ie(R.dirname(d))!==ie(R.resolve(e)))return;let s=R.basename(d);if(!(!/\.md$/i.test(s)||/^MEMORY\.md$/i.test(s)))return{root:R.resolve(e),rel:s}}function to(t){if(!t||typeof t!="object")return;let n=t,e=n.file;if(!(n.type!=="text"||!e||typeof e.content!="string"||typeof e.filePath!="string"))return t}function It(t){try{if(t.toolName!=="Read"||!t.filePath||!t.sessionId||t.offset!==void 0||t.limit!==void 0)return"";let n=to(t.response);if(!n||n.file.startLine>1)return"";let e=Je(t.filePath)??eo(t.filePath,t.cwd);if(!e)return"";let d=U.readFileSync(R.join(e.root,e.rel),"utf8");if(Te(d)<Kt)return"";let s=Zt(t.transcriptPath);if(!s)return"";let h=new Set(I(s)).size,u=Math.min(h,Math.max(2,Math.ceil(h/2))),l=J({name:R.basename(e.rel).replace(/\.md$/i,""),file:e.rel},d),T=z(G(l),s,l.length).map(o=>({...o.unit,score:o.score,matched:o.matched})),b=l.map(o=>new Set(I(o.content))),v=[...new Set(I(s))].filter(o=>{let i=b.filter(a=>a.has(o)).length;return i>0&&i<=Math.floor(l.length/2)});if(v.length===0)return"";let $=[],m=0;for(let o of T){let i=new Set(I(o.content));if(!(o.matched<u||!v.some(a=>i.has(a)))&&!$.some(a=>o.startLine<=a.endLine&&o.endLine>=a.startLine)){if(m+o.tokens>Vt&&$.length>0)break;$.push(o),m+=o.tokens}}if($.length===0)return"";$.sort((o,i)=>o.startLine-i.startLine);let C=d.split(/\r?\n/),j=$.map(o=>`--- lines ${o.startLine}-${o.endLine} of ${C.length} ---
|
|
10
|
+
${C.slice(o.startLine-1,o.endLine).join(`
|
|
11
|
+
`)}`),O=l.filter(o=>o.kind==="section"&&o.path.length<=2&&!$.some(i=>o.startLine<=i.endLine&&o.endLine>=i.startLine)),S=[...new Map(O.map(o=>[`${o.startLine}-${o.endLine}`,`${o.path.join(" > ")} (lines ${o.startLine}-${o.endLine})`])).values()],M=`${`minnimemory: this Read shows the ${$.length} section(s) of ${e.rel} that match the current prompt.`+(S.length?` Not shown: ${S.join("; ")}. Read with offset and limit to see one.`:" Read with offset and limit to see the rest.")}
|
|
12
|
+
|
|
13
|
+
${j.join(`
|
|
14
|
+
|
|
35
15
|
`)}
|
|
36
|
-
|
|
37
|
-
|
|
16
|
+
`,r={...n,file:{...n.file,content:M,numLines:M.split(`
|
|
17
|
+
`).length,startLine:1}};return JSON.stringify({hookSpecificOutput:{hookEventName:"PostToolUse",updatedToolOutput:r}})}catch{return""}}var so=!1,Z=`
|
|
18
|
+
minnimemory ${ke} the agent memory compiler
|
|
38
19
|
|
|
39
20
|
usage: the four lifecycle verbs, the CLI and the MCP basic profile share.
|
|
40
21
|
The only difference is who writes: the CLI writes to disk itself, the MCP tools return the
|
|
41
22
|
command that does (and the operations it performs) for the agent to run.
|
|
42
|
-
minnimemory init <folder> always first: takes where
|
|
43
|
-
--from-log, --memory-dir
|
|
23
|
+
minnimemory init <folder> always first: takes where the host loads from (Claude Code:
|
|
24
|
+
--loaded, --from-log, --memory-dir, or the agent over MCP;
|
|
25
|
+
Codex: its own load rules, the agent's report over MCP),
|
|
44
26
|
checks and saves them, then the map, the audit and the diff
|
|
45
27
|
apply would write; writes only that record; ends with the
|
|
46
28
|
apply command to run. --map prints only the map
|
|
@@ -57,22 +39,28 @@ more
|
|
|
57
39
|
minnimemory mcp [path] start the MCP server. Serves init/doctor/apply/undo by
|
|
58
40
|
default; --profile full serves the seven maintainer tools
|
|
59
41
|
minnimemory install register minnimemory with the current host
|
|
60
|
-
minnimemory uninstall remove the registration and the
|
|
61
|
-
as install --remove); lists
|
|
42
|
+
minnimemory uninstall remove the registration and the hooks install added (four on
|
|
43
|
+
Claude Code, two on Codex; same as install --remove); lists
|
|
44
|
+
folders still compiled, to undo first
|
|
62
45
|
minnimemory bench <folder> what the compiled shape costs over a session
|
|
63
46
|
minnimemory recall <path> <query...>
|
|
64
47
|
recall against a compiled workspace or a manifest-less memory
|
|
65
48
|
directory (Layout B), whichever <path> is, change nothing
|
|
66
|
-
minnimemory hook Claude Code
|
|
49
|
+
minnimemory hook UserPromptSubmit hook (Claude Code, Codex): reads hook JSON from stdin,
|
|
67
50
|
prints a fenced memory block to stdout, or nothing on no hit.
|
|
68
51
|
Experimental: measured offline only, not yet in a
|
|
69
52
|
live session
|
|
70
|
-
minnimemory drift Claude Code
|
|
53
|
+
minnimemory drift UserPromptSubmit hook (Claude Code, Codex): prints a one-line notice when
|
|
71
54
|
memory files changed since the last apply, once per change,
|
|
72
55
|
nothing otherwise
|
|
73
|
-
minnimemory loaded Claude Code InstructionsLoaded hook: records which memory files
|
|
56
|
+
minnimemory loaded Claude Code only, InstructionsLoaded hook: records which memory files
|
|
74
57
|
Claude Code loaded, for the map init prints; reads hook JSON
|
|
75
58
|
from stdin, prints nothing
|
|
59
|
+
minnimemory read Claude Code only, PostToolUse hook on Read: logs which
|
|
60
|
+
OnDemandMemory files sessions open, for doctor's MM024; prints
|
|
61
|
+
nothing. --precise (install --precise-reads, off by default):
|
|
62
|
+
a whole-file Read of a large OnDemandMemory file returns only
|
|
63
|
+
the sections the prompt needs
|
|
76
64
|
|
|
77
65
|
install options
|
|
78
66
|
--scope <name> user, project or local, same meaning as claude mcp add (default user)
|
|
@@ -80,7 +68,10 @@ install options
|
|
|
80
68
|
--allow-write); the default basic profile never writes
|
|
81
69
|
--dry-run print the command without running it, exit 0
|
|
82
70
|
--force remove an existing registration first, then re-add
|
|
83
|
-
--no-hook skip the
|
|
71
|
+
--no-hook skip the hooks (memory, drift notice, and on Claude Code the load
|
|
72
|
+
log and the Read usage log); on by default
|
|
73
|
+
--precise-reads the Read hook also trims a whole-file Read of a large OnDemandMemory
|
|
74
|
+
file to the sections the prompt needs; off by default (unproven live)
|
|
84
75
|
--remove remove the MCP registration and the hooks install added (= uninstall)
|
|
85
76
|
--host <name> codex: register with Codex (codex mcp add) and write the two
|
|
86
77
|
UserPromptSubmit hooks to ~/.codex/hooks.json (--scope user) or
|
|
@@ -135,6 +126,7 @@ init and doctor options
|
|
|
135
126
|
auto same as none today, for every source
|
|
136
127
|
none structure only, embed nothing
|
|
137
128
|
routing the rules that make routing work, about 210 tokens
|
|
129
|
+
output the answer-length rules alone, about 230 tokens
|
|
138
130
|
full the complete set, about 710 tokens
|
|
139
131
|
--allow-secrets preview as if a credential-shaped source were allowed through
|
|
140
132
|
--episodic-json plan episodic OnDemandMemory files (changelogs, logs) as JSON, not
|
|
@@ -163,6 +155,7 @@ apply options
|
|
|
163
155
|
auto same as none today, for every source
|
|
164
156
|
none structure only, embed nothing
|
|
165
157
|
routing the rules that make routing work, about 210 tokens
|
|
158
|
+
output the answer-length rules alone, about 230 tokens
|
|
166
159
|
full the complete set, about 710 tokens
|
|
167
160
|
--allow-secrets compile even when the source holds a credential-shaped string
|
|
168
161
|
--episodic-json write episodic OnDemandMemory files (changelogs, logs) as JSON, not
|
|
@@ -228,182 +221,185 @@ doctor options
|
|
|
228
221
|
<folder> is required: a repo, a memory directory, or a single file. With none, minnimemory asks
|
|
229
222
|
for it (in a terminal) or stops and says so. Type . for the current folder. An @import that
|
|
230
223
|
points outside the folder is not read; the report names it.
|
|
231
|
-
`;function
|
|
232
|
-
`)}function
|
|
233
|
-
no match for "${
|
|
224
|
+
`;function io(){let t=[""," rule set",""];for(let n of We)t.push(` ${n.id.padEnd(8)}${n.severity.padEnd(6)}${n.title}`);return t.push(""),t.join(`
|
|
225
|
+
`)}function ao(t,n){if(t===void 0)return n;if(t==="low"||t==="med"||t==="high")return t;throw new Error(`--fail-on must be one of low, med, high (got "${t}")`)}function Bt(t){return t?t.split(",").map(n=>n.trim()).filter(Boolean):[]}function lo(t,n){return t.matches.length===0?`
|
|
226
|
+
no match for "${t.query}"
|
|
234
227
|
|
|
235
|
-
`:
|
|
228
|
+
`:n?`${t.matches.map(e=>`${e.onDemandFile} > ${e.path.join(" > ")} (${e.tokens} tokens)`).join(`
|
|
236
229
|
`)}
|
|
237
|
-
`:`${
|
|
230
|
+
`:`${t.matches.map(e=>`## ${e.onDemandFile} > ${e.path.join(" > ")} (lines ${e.startLine}-${e.endLine}, ${e.tokens} tokens, score ${e.score})
|
|
238
231
|
|
|
239
|
-
${
|
|
232
|
+
${e.content}`).join(`
|
|
240
233
|
|
|
241
234
|
---
|
|
242
235
|
|
|
243
236
|
`)}
|
|
244
|
-
`}function
|
|
245
|
-
error: ${
|
|
237
|
+
`}function uo(t){return t.isTTY?"usage":"serve"}function Ut(){return(t,n)=>{let e=process.platform==="win32",d=oo(t,e?St(n):n,{encoding:"utf8",shell:e});return{code:d.status,stdout:d.stdout??"",stderr:d.stderr??"",error:d.error}}}function co(t){if(t===void 0||t==="user")return"user";if(t==="project"||t==="local")return t;throw new Error(`--scope must be one of user, project, local (got "${t}")`)}function po(t){if(t!==void 0){if(t==="cursor"||t==="windsurf"||t==="json"||t==="codex")return t;throw new Error(`--host must be one of codex, cursor, windsurf, json (got "${t}")`)}}function Ht(t){if(t===void 0)return;let n=Number(t);if(!Number.isInteger(n)||n<=0||n>re)throw new Error(`--budget must be a whole number of tokens from 1 to ${re.toLocaleString("en-US")} (got "${t}")`);return Math.floor(n)}function fo(t,n){let e;try{if(e=y.resolve(t),!w.existsSync(e)||!w.statSync(e).isDirectory())throw new B(`not a directory: ${e}`)}catch(s){return s instanceof B?(process.stderr.write(`
|
|
238
|
+
error: ${s.message}
|
|
246
239
|
|
|
247
240
|
`),2):(process.stderr.write(`
|
|
248
|
-
unexpected error: ${
|
|
241
|
+
unexpected error: ${s.stack??String(s)}
|
|
249
242
|
|
|
250
|
-
`),2)}let
|
|
251
|
-
error: --profile must be one of basic, full (got "${
|
|
243
|
+
`),2)}let d=n.profile??"basic";return d!=="basic"&&d!=="full"?(process.stderr.write(`
|
|
244
|
+
error: --profile must be one of basic, full (got "${d}")
|
|
252
245
|
|
|
253
|
-
`),2):((async()=>{let[{StdioServerTransport:
|
|
254
|
-
mcp server failed: ${
|
|
255
|
-
`),process.exitCode=1}),0)}function
|
|
256
|
-
`)}var
|
|
257
|
-
error: name the folder to read: ${
|
|
246
|
+
`),2):((async()=>{let[{StdioServerTransport:s},{createMcpServer:h}]=await Promise.all([import("@modelcontextprotocol/sdk/server/stdio.js"),import("./chunks/mcpServer-HEZQUR7M.js")]);await h(e,{profile:d,allowWrite:n["allow-write"]===!0,host:P()}).connect(new s)})().catch(s=>{process.stderr.write(`
|
|
247
|
+
mcp server failed: ${s.message??String(s)}
|
|
248
|
+
`),process.exitCode=1}),0)}function mo(){let t=ut(),n=[];if(t.length>0){n.push("still compiled (they keep working without minnimemory; to put the originals back, undo each one):");for(let d of t)n.push(` ${Ne(d)}`)}let e=P()==="codex";return n.push(`kept: ${y.dirname(at())} (init records, ${e?"":"the load log, the usage log, "}undo backups); delete it yourself once you have checked undo-backups/.`),n.push(`restart ${se()}.`),n.join(`
|
|
249
|
+
`)}var ho=new Set(["init","doctor","apply","undo","bench"]);function yo(t){if(V(process.cwd()))return!0;let n=$e(t);return pe(n)==="compiled"||me(n)!==void 0||le(n)!==void 0}function $e(t){let n=y.resolve(t);return w.existsSync(n)&&w.statSync(n).isFile()?y.dirname(n):n}function go(t){if(V(process.cwd()))return;let n=$e(t);return le(n)?Ie(n):void 0}function wo(t){let n=`minnimemory ${t} <folder>`;if(process.stdin.isTTY!==!0){process.stderr.write(`
|
|
250
|
+
error: name the folder to read: ${n} (type . for the current folder)
|
|
258
251
|
|
|
259
252
|
`);return}process.stdout.write(`
|
|
260
|
-
Which folder should minnimemory ${
|
|
261
|
-
folder: `);let
|
|
262
|
-
error: no folder given; run ${
|
|
253
|
+
Which folder should minnimemory ${t} read? Only that folder and the folders below it are read.
|
|
254
|
+
folder: `);let e=ko().trim();if(e===""){process.stderr.write(`
|
|
255
|
+
error: no folder given; run ${n}
|
|
263
256
|
|
|
264
|
-
`);return}return
|
|
265
|
-
`)break;
|
|
257
|
+
`);return}return e}function ko(){let t=Buffer.alloc(1),n="";for(;;){let e;try{e=w.readSync(0,t,0,1,null)}catch{break}if(e===0)break;let d=t.toString("utf8");if(d===`
|
|
258
|
+
`)break;d!=="\r"&&(n+=d)}return n}function bo(t){let n;try{n=no({args:t,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},"precise-reads":{type:"boolean",default:!1},precise:{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(r){let o=r.message,i=/argument is ambiguous/.test(o)?`
|
|
266
259
|
(a value that starts with '-' must be written as --option=value; --budget must be positive anyway)`:"";return process.stderr.write(`
|
|
267
|
-
error: ${
|
|
268
|
-
${Z}`),2}let{values:
|
|
269
|
-
`),0;if(
|
|
270
|
-
`);let
|
|
271
|
-
error: --host must be claude or codex for ${
|
|
260
|
+
error: ${o}${i}
|
|
261
|
+
${Z}`),2}let{values:e,positionals:d}=n;if(e.help)return process.stdout.write(Z),0;if(e.version)return process.stdout.write(`${ke}
|
|
262
|
+
`),0;if(e.rules)return process.stdout.write(io()),0;let s;if(d[0]===void 0){if(uo({isTTY:process.stdin.isTTY===!0})==="usage")return process.stdout.write(Z),0;s="mcp"}else s=d[0];let h=["include-auto-memory","follow-external-imports","auto-memory"].filter(r=>e[r]===!0);h.length>0&&process.stderr.write(` note: ${h.map(r=>`--${r}`).join(", ")} no longer does anything: minnimemory reads only the folder you name
|
|
263
|
+
`);let u=d[1]===void 0?void 0:/^~($|[\\/])/.test(d[1])?Y(d[1]):d[1];if(u===void 0&&typeof e["memory-dir"]=="string"&&(u=e["memory-dir"]),u===void 0&&["doctor","apply","undo"].includes(s)){let r=V(process.cwd());r&&(u=r.target??r.memoryDir??r.project)}if(u===void 0&&ho.has(s)&&(u=wo(s),u===void 0))return 2;let l=u??".";if(s!=="install"&&s!=="uninstall")if(e.host!==void 0){if(!De(e.host))return process.stderr.write(`
|
|
264
|
+
error: --host must be claude or codex for ${s} (got "${e.host}")
|
|
272
265
|
|
|
273
|
-
`),2;
|
|
266
|
+
`),2;A(e.host)}else["init","doctor","apply","undo","mcp"].includes(s)?A(Pe({env:process.env,home:At.homedir(),cwd:process.cwd()})):A("claude");if(e.policy!==void 0&&s!=="doctor")return process.stderr.write(`
|
|
274
267
|
error: --policy is a doctor option: \`minnimemory doctor <folder> --policy <file>\`
|
|
275
268
|
|
|
276
|
-
`),2;if(
|
|
277
|
-
error: --diff takes summary or full, not "${
|
|
269
|
+
`),2;if(e.diff!==void 0&&e.diff!=="summary"&&e.diff!=="full")return process.stderr.write(`
|
|
270
|
+
error: --diff takes summary or full, not "${e.diff}"
|
|
278
271
|
|
|
279
|
-
`),2;let
|
|
272
|
+
`),2;let T=e.diff,b=[...e.loaded??[],...e["host-file"]??[]].map(r=>Y(r));if(e["from-log"]===!0){let r=kt(process.cwd());if(!r)return process.stderr.write(`
|
|
280
273
|
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
274
|
|
|
282
|
-
`),2;for(let
|
|
283
|
-
error: ${
|
|
275
|
+
`),2;for(let o of Object.keys(r.files))/\.md$/i.test(o)&&w.existsSync(o)&&b.push(y.resolve(o))}let v=typeof e["memory-dir"]=="string"?Y(e["memory-dir"]):void 0;if(v&&P()==="codex"&&Be(W("codex"),v))return process.stderr.write(`
|
|
276
|
+
error: ${v.split(y.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.
|
|
284
277
|
|
|
285
|
-
`),2;let
|
|
286
|
-
`);let
|
|
287
|
-
|
|
278
|
+
`),2;let m=b.length>0||v!==void 0||e["only-this-folder"]===!0?{files:[...new Set(b)],...v?{memoryDir:v}:{},source:e["from-log"]===!0&&(e.loaded??[]).length===0?"log":"terminal",...e["only-this-folder"]===!0?{onlyThisFolder:!0}:{}}:void 0,C=m||!["doctor","apply"].includes(s)?void 0:go(l),j=m?void 0:ct(process.cwd())??(C?Ae($e(l)):void 0);C&&process.stderr.write(` note: this machine has no init record for this project, so ${s} uses the one in the repo: ${y.relative(process.cwd(),C).split(y.sep).join("/")||C}
|
|
279
|
+
`);let O={cwd:process.cwd(),...m?{reported:m}:j?{reported:j}:{}},S,D;if(["init","doctor","apply","undo"].includes(s)){let r=nt(l,{reported:m});r&&(S=st(l,r),D=y.resolve(l),l=r.dir,u=r.dir,s!=="init"&&e.json!==!0&&process.stdout.write(`
|
|
280
|
+
${S}
|
|
281
|
+
`))}if(s==="install"||s==="uninstall"){let r;try{r={write:e.write===!0,scope:co(e.scope),dryRun:e["dry-run"]===!0,force:e.force===!0,host:po(e.host),hook:(e.host===void 0||e.host==="codex")&&e["no-hook"]!==!0,preciseReads:e["precise-reads"]===!0,cliPath:process.argv[1]?vo(process.argv[1]):void 0}}catch(g){return process.stderr.write(`
|
|
282
|
+
error: ${g.message}
|
|
288
283
|
|
|
289
|
-
`),2}let
|
|
290
|
-
${
|
|
291
|
-
`),
|
|
284
|
+
`),2}let o={home:At.homedir(),platform:process.platform,cwd:process.cwd(),configDir:je(),codexConfigDir:W("codex"),...process.env.CODEX_HOME?{codexHome:process.env.CODEX_HOME}:{}},i=s==="uninstall"||e.remove===!0;i&&r.host==="codex"&&A("codex");let a=i?Mt(r,o,Ut()):Tt(r,o,Ut()),f=a.exitCode===0?process.stdout:process.stderr;return f.write(`
|
|
285
|
+
${a.output}
|
|
286
|
+
`),i&&f.write(`${mo()}
|
|
292
287
|
|
|
293
|
-
`),
|
|
288
|
+
`),a.exitCode}if(s==="init"||s==="apply"){if(s==="init"&&(e.write===!0||e.update===!0))return process.stderr.write(`
|
|
294
289
|
error: init never writes; use apply
|
|
295
290
|
|
|
296
|
-
`),2;let
|
|
297
|
-
error: --profile must be one of auto, none, routing, full (got "${
|
|
291
|
+
`),2;let r=e.profile??"auto";if(r!=="auto"&&!Oe(r))return process.stderr.write(`
|
|
292
|
+
error: --profile must be one of auto, none, routing, output, full (got "${r}")
|
|
298
293
|
|
|
299
|
-
`),2;let
|
|
300
|
-
error: ${
|
|
294
|
+
`),2;let o;try{o=Ht(e.budget)}catch(k){return process.stderr.write(`
|
|
295
|
+
error: ${k.message}
|
|
301
296
|
|
|
302
|
-
`),2}let
|
|
303
|
-
`:
|
|
297
|
+
`),2}let i=s==="apply",a=r==="auto"?void 0:r,f=e["episodic-json"]===!0,g=[...P()==="codex"?["--host codex"]:[],...a?[`--profile ${a}`]:[],...f?["--episodic-json"]:[],...e["only-this-folder"]===!0?["--only-this-folder"]:[]],c={budget:o,force:e.force===!0,profileName:a,episodicJson:f,discover:O};try{if(!i){let ee=w.existsSync(l)&&w.statSync(l).isFile()?y.dirname(y.resolve(l)):y.resolve(l),F;try{let N=K(l,O);N.shape==="memory-dir"&&(F=N)}catch{F=void 0}let E=!F&&P()==="codex"?Et(process.cwd(),{projectRoot:D??ee}):void 0,te=E?void 0:F?xt(F):vt(ee,{machine:!1,projectRoot:ee}),xe=E?Rt(E):Ct(te),Gt=()=>E?Dt(E):$t(te);if(e.map===!0)return process.stdout.write(e.json?`${JSON.stringify(E??te,null,2)}
|
|
298
|
+
`:xe),0;e.json||process.stdout.write(xe),S&&!e.json&&process.stdout.write(` ${S}
|
|
304
299
|
|
|
305
|
-
`);let
|
|
306
|
-
`)}else process.stdout.write(ge(
|
|
300
|
+
`);let H=ye(l,c);if(e.json){let N=JSON.parse(we(H,u,g));process.stdout.write(`${JSON.stringify({map:Gt(),...N},null,2)}
|
|
301
|
+
`)}else process.stdout.write(ge(H,{color:!1,ci:e.ci===!0,target:u,flags:g,diff:T}));let oe=H.workspace.folderRoot??y.resolve(l),Ce=H.workspace.claudeMemoryFolder?oe:void 0,Se=dt(process.cwd(),m?{...m,...m.memoryDir??Ce?{memoryDir:m.memoryDir??Ce}:{}}:void 0,oe);!m&&E&&pt(process.cwd(),E.chain.map(N=>N.abs)),m&&!e.json&&process.stdout.write(Se?` saved what ${se()} loads here for apply, doctor and undo: ${Se}
|
|
307
302
|
|
|
308
303
|
`:` could not save the locations; pass them again to apply
|
|
309
304
|
|
|
310
|
-
`);let
|
|
305
|
+
`);let Me=lt(process.cwd(),oe);return Me&&process.stderr.write(` ${Me}
|
|
311
306
|
|
|
312
|
-
`),0}let
|
|
307
|
+
`),0}let k=K(l,O);if(k.shape==="memory-dir"&&!k.reported)return process.stderr.write(`
|
|
313
308
|
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.
|
|
314
309
|
|
|
315
|
-
`),2;let
|
|
316
|
-
error: the plan on disk no longer matches --plan ${
|
|
310
|
+
`),2;let x=qe(k,{budget:o??k.manifest?.budget,profileName:a,episodicJson:f,sortAnyway:e.force===!0});if(e.plan!==void 0&&x.plan!==e.plan)return process.stderr.write(`
|
|
311
|
+
error: the plan on disk no longer matches --plan ${e.plan} (now ${x.plan}); run doctor again
|
|
317
312
|
|
|
318
|
-
`),2;if(
|
|
319
|
-
error: ${
|
|
313
|
+
`),2;if(x.verdict==="nothing")return process.stdout.write(ce(x,{write:!0})),0;if(x.verdict==="leave"&&e.force!==!0)return process.stderr.write(`
|
|
314
|
+
error: ${rt(x)} (${x.before} -> ${x.after} tokens; break-even ${x.bounds.breakEvenCarriedTokens} tokens of OnDemandMemory open all session)
|
|
320
315
|
Pass --force to write it anyway.
|
|
321
316
|
|
|
322
|
-
`),2;let
|
|
323
|
-
error: ${
|
|
317
|
+
`),2;let Jt=ce(x,{write:!0,target:u});return Ye(x,{allowSecrets:e["allow-secrets"]===!0}),process.stdout.write(Jt),0}catch(k){return k instanceof q||k instanceof X?(process.stderr.write(`
|
|
318
|
+
error: ${k.message}
|
|
324
319
|
|
|
325
320
|
`),2):(process.stderr.write(`
|
|
326
|
-
unexpected error: ${
|
|
321
|
+
unexpected error: ${k.stack??String(k)}
|
|
327
322
|
|
|
328
|
-
`),2)}}if(
|
|
323
|
+
`),2)}}if(s==="undo")try{let r;try{r=K(l).folderRoot}catch(c){if(!(c instanceof q))throw c}if(!r)return process.stdout.write(`
|
|
329
324
|
nothing to undo
|
|
330
325
|
|
|
331
|
-
`),0;let
|
|
332
|
-
error: ${
|
|
326
|
+
`),0;let o=me(r),i=o?void 0:it(r),a=i?ot(r,i):!o&&fe(r)?Ze(r):Qe(r,o);if(a.kind==="none")return!o&&fe(r)?(process.stderr.write(`
|
|
327
|
+
error: ${Xe(r)}
|
|
333
328
|
|
|
334
329
|
`),2):(process.stdout.write(`
|
|
335
330
|
nothing to undo
|
|
336
331
|
|
|
337
|
-
`),0);if(
|
|
338
|
-
error: undo has nothing left to restore here: ${
|
|
332
|
+
`),0);if(a.kind==="kept-only")return process.stderr.write(`
|
|
333
|
+
error: undo has nothing left to restore here: ${et(a.kept)}
|
|
339
334
|
|
|
340
|
-
`),2;if(
|
|
341
|
-
error: no original copy under ${ne}/original/ for: ${
|
|
335
|
+
`),2;if(a.kind==="missing-original")return process.stderr.write(`
|
|
336
|
+
error: no original copy under ${ne}/original/ for: ${a.files.join(", ")}.
|
|
342
337
|
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.
|
|
343
338
|
|
|
344
|
-
`),2;let
|
|
345
|
-
error: ${
|
|
339
|
+
`),2;let f=Ke(a.plan);if(f&&e.force!==!0)return process.stderr.write(`
|
|
340
|
+
error: ${f}
|
|
346
341
|
|
|
347
|
-
`),2;let
|
|
348
|
-
restored ${
|
|
349
|
-
deleted: ${
|
|
350
|
-
`+(
|
|
351
|
-
`:"")+(
|
|
352
|
-
`:"")+(
|
|
342
|
+
`),2;let g=f?Ve(a.plan):void 0;return tt(a.plan),process.stdout.write(`
|
|
343
|
+
restored ${a.plan.operations.filter(c=>c.op==="write"||c.op==="move").length} file(s) in ${r}
|
|
344
|
+
deleted: ${a.plan.operations.filter(c=>c.op==="delete").length} path(s), ${ne}/ ${a.plan.keptBackups?.length?"kept":"included"}
|
|
345
|
+
`+(ue(a.plan)?` ${ue(a.plan)}
|
|
346
|
+
`:"")+(a.plan.left?.length?` left in place: ${a.plan.left.join(", ")} (without manifest.json undo cannot tell which files there it wrote)
|
|
347
|
+
`:"")+(g?` the files as they were before this undo are copied to ${g.split(y.sep).join("/")}
|
|
353
348
|
`:"")+`
|
|
354
|
-
`),0}catch(
|
|
355
|
-
error: ${
|
|
349
|
+
`),0}catch(r){return r instanceof X?(process.stderr.write(`
|
|
350
|
+
error: ${r.message}
|
|
356
351
|
|
|
357
352
|
`),2):(process.stderr.write(`
|
|
358
|
-
unexpected error: ${
|
|
353
|
+
unexpected error: ${r.stack??String(r)}
|
|
359
354
|
|
|
360
|
-
`),2)}if(
|
|
361
|
-
mcp: ${
|
|
355
|
+
`),2)}if(s==="mcp")return so?((async()=>{let[{StdioServerTransport:r},{createDisabledMcpServer:o,DISABLED_MESSAGE:i}]=await Promise.all([import("@modelcontextprotocol/sdk/server/stdio.js"),import("./chunks/mcpServer-HEZQUR7M.js")]);process.stderr.write(`
|
|
356
|
+
mcp: ${i}
|
|
362
357
|
|
|
363
|
-
`),await
|
|
364
|
-
mcp server failed: ${
|
|
365
|
-
`),process.exitCode=1}),0):
|
|
358
|
+
`),await o().connect(new r)})().catch(r=>{process.stderr.write(`
|
|
359
|
+
mcp server failed: ${r.message??String(r)}
|
|
360
|
+
`),process.exitCode=1}),0):fo(l,e);if(s==="recall"){let r=d.slice(2).join(" ").trim();if(!r)return process.stderr.write(`
|
|
366
361
|
error: recall needs a query: minnimemory recall <path> <query...>
|
|
367
362
|
|
|
368
|
-
`),2;let
|
|
369
|
-
error: --max-tokens must be a positive number (got "${
|
|
363
|
+
`),2;let o;if(e["max-tokens"]!==void 0){let a=Number(e["max-tokens"]);if(!Number.isFinite(a)||a<=0)return process.stderr.write(`
|
|
364
|
+
error: --max-tokens must be a positive number (got "${e["max-tokens"]}")
|
|
370
365
|
|
|
371
|
-
`),2;
|
|
372
|
-
error: ${
|
|
366
|
+
`),2;o=Math.floor(a)}let i=y.resolve(l);try{let a=pe(i),f;if(a==="compiled")f=Fe(i,ae(i),r,{maxTokens:o});else if(a==="memory-dir")f=ht(i,r,{maxTokens:o});else return process.stderr.write(`
|
|
367
|
+
error: ${i} 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
|
|
373
368
|
|
|
374
|
-
`),2;return process.stdout.write(
|
|
375
|
-
error: ${
|
|
369
|
+
`),2;return process.stdout.write(lo(f,e.headings===!0)),0}catch(a){return a instanceof B||a instanceof mt?(process.stderr.write(`
|
|
370
|
+
error: ${a.message}
|
|
376
371
|
|
|
377
372
|
`),2):(process.stderr.write(`
|
|
378
|
-
unexpected error: ${
|
|
373
|
+
unexpected error: ${a.stack??String(a)}
|
|
379
374
|
|
|
380
|
-
`),2)}}if(
|
|
381
|
-
`)}catch(p){process.stderr.write(`
|
|
382
|
-
hook: ${p.message??String(p)}
|
|
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}
|
|
375
|
+
`),2)}}if(s==="hook"){let r="";try{r=w.readFileSync(0,"utf8")}catch{r=""}let o;if(e["max-tokens"]!==void 0){let i=Number(e["max-tokens"]);Number.isFinite(i)&&i>0&&(o=Math.floor(i))}try{let i=he(r);if(P()==="codex")try{Ot(W("codex"),i.cwd??process.cwd())}catch{}let a=gt(i,{headings:e.headings===!0,maxTokens:o,dir:e.dir});a&&process.stdout.write(`${a}
|
|
384
376
|
`)}catch(i){process.stderr.write(`
|
|
385
|
-
|
|
386
|
-
`)}return 0}if(
|
|
387
|
-
`)
|
|
388
|
-
`)
|
|
389
|
-
|
|
377
|
+
hook: ${i.message??String(i)}
|
|
378
|
+
`)}return 0}if(s==="loaded"){let r="";try{r=w.readFileSync(0,"utf8")}catch{r=""}try{let o=JSON.parse(r);bt(o),o.load_reason==="compact"&&typeof o.session_id=="string"&&yt(o.session_id)}catch{}return 0}if(s==="read"){let r="";try{r=w.readFileSync(0,"utf8")}catch{r=""}let o=Ge(r);if(ze(o),e.precise===!0){let i=It(o);i&&process.stdout.write(`${i}
|
|
379
|
+
`)}return 0}if(s==="drift"){let r="";try{r=w.readFileSync(0,"utf8")}catch{r=""}try{let o=he(r),i=wt(o);i&&process.stdout.write(`${i}
|
|
380
|
+
`)}catch(o){process.stderr.write(`
|
|
381
|
+
drift: ${o.message??String(o)}
|
|
382
|
+
`)}return 0}if(s==="bench")try{let r=y.resolve(l),o=ae(r),i=e.turns===void 0?50:Number(e.turns);if(!Number.isFinite(i))throw new _(`--turns must be a positive whole number (got "${e.turns}")`);let a=de(o,i);if(e.workload===void 0)return e.json===!0?(process.stdout.write(`${JSON.stringify({bounds:a,tokenizer:o.tokenizer},null,2)}
|
|
383
|
+
`),0):(process.stdout.write(ve(a,o.tokenizer)),process.stdout.write(_t()),0);let f=jt(e.workload),g=Nt(o,f,e["whole-files"]===!0?{}:{root:r});return e.json===!0?(process.stdout.write(`${JSON.stringify({bounds:a,model:g,tokenizer:o.tokenizer},null,2)}
|
|
384
|
+
`),0):(process.stdout.write(ve(a,o.tokenizer)),process.stdout.write(Lt(g,o.tokenizer)),0)}catch(r){return r instanceof _||r instanceof B?(process.stderr.write(`
|
|
385
|
+
error: ${r.message}
|
|
390
386
|
|
|
391
387
|
`),2):(process.stderr.write(`
|
|
392
|
-
unexpected error: ${
|
|
388
|
+
unexpected error: ${r.stack??String(r)}
|
|
393
389
|
|
|
394
|
-
`),2)}if(
|
|
395
|
-
error: unknown command "${
|
|
396
|
-
${Z}`),2;if(!
|
|
397
|
-
error: run init first: doctor checks memory init has already looked at, and init has no record for this project and ${
|
|
390
|
+
`),2)}if(s!=="doctor")return process.stderr.write(`
|
|
391
|
+
error: unknown command "${s}"
|
|
392
|
+
${Z}`),2;if(!yo(l))return process.stderr.write(`
|
|
393
|
+
error: run init first: doctor checks memory init has already looked at, and init has no record for this project and ${l} has not been compiled. Run \`${Le(l)}\`.
|
|
398
394
|
|
|
399
|
-
`),2;let
|
|
400
|
-
error: ${
|
|
395
|
+
`),2;let M;try{let r;if(e.policy!==void 0)try{r=He(e.policy)}catch(o){throw o instanceof Ue?new Error(`--policy: ${o.message}`):o}M={discover:O,budget:Ht(e.budget)??r?.budgets.always_on_tokens,budgetFromPolicy:e.budget===void 0&&r?.budgets.always_on_tokens!==void 0,policy:r,failOn:ao(e["fail-on"],"high"),only:Bt(e.only),ignore:Bt(e.ignore),force:e.force===!0}}catch(r){return process.stderr.write(`
|
|
396
|
+
error: ${r.message}
|
|
401
397
|
|
|
402
|
-
`),2}try{let
|
|
403
|
-
`);else{let
|
|
404
|
-
error: ${
|
|
398
|
+
`),2}try{let r=ye(l,M);if(e.json)process.stdout.write(`${we(r,u)}
|
|
399
|
+
`);else{let o=!e.ci&&!process.env.NO_COLOR&&process.stdout.isTTY===!0;process.stdout.write(ge(r,{color:o,ci:e.ci===!0,target:u,diff:T}))}return Pt(r.audit.findings,r.config.failOn)}catch(r){return r instanceof q||r instanceof X?(process.stderr.write(`
|
|
400
|
+
error: ${r.message}
|
|
405
401
|
|
|
406
402
|
`),2):(process.stderr.write(`
|
|
407
|
-
unexpected error: ${
|
|
403
|
+
unexpected error: ${r.stack??String(r)}
|
|
408
404
|
|
|
409
|
-
`),2)}}function
|
|
405
|
+
`),2)}}function vo(t){try{return w.realpathSync(t)}catch{return y.resolve(t)}}function $o(){let t=process.argv[1];if(!t)return!1;try{return w.realpathSync(ro(import.meta.url))===w.realpathSync(t)}catch{return!1}}$o()&&(process.exitCode=bo(process.argv.slice(2)));export{so as MCP_STASHED,uo as defaultCommand,bo as main};
|