nex-code 0.5.20 → 0.5.21

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.
@@ -105,7 +105,7 @@ run()
105
105
 
106
106
  module.exports = { port };
107
107
  `},"g4"),Ie("write_file",{path:"README.md",content:`Run the service with PORT=3001 node service.js.
108
- `},"g5")]}):{content:"Resolved the simulated multi-file git conflict while preserving the configurable port behavior.",tool_calls:[]}}return{content:"No mock scenario matched this prompt. Set a Scenario A\u2013G prompt (or enable malformed mode) to run deterministic E2E flows.",tool_calls:[]}}var Xl=class extends W_{constructor(e={}){super({name:"mock",baseUrl:"mock://",models:{"mock-model":{id:"mock-model",name:"Mock Model",maxTokens:4096,contextWindow:8192}},defaultModel:"mock-model",...e})}isConfigured(){return process.env.NEX_MOCK_PROVIDER==="1"}async chat(e,n,o={}){return Vf(e)}async stream(e,n,o={}){let s=typeof o.onToken=="function"?o.onToken:()=>{},r=Vf(e),i=String(r.content||""),a=Math.min(i.length,Math.max(1,Math.floor(i.length/2)));return i&&(s(i.slice(0,a)),s(i.slice(a))),r}normalizeResponse(e){return e}};Jf.exports={MockProvider:Xl}});var Zl=J((XO,e$)=>{e$.exports={name:"nex-code",version:"0.5.20",description:"Run 400B+ open coding models on your codebase without the hardware bill. Ollama Cloud first \u2014 OpenAI, Anthropic, and Gemini when you need them.",bin:{"nex-code":"./dist/nex-code.js"},files:["dist/","examples/","README.md","LICENSE"],engines:{node:">=18.0.0"},scripts:{start:"node dist/nex-code.js",build:"node scripts/build.js",dev:"node scripts/build.js --dev",test:"jest --runInBand","test:orchestrator":"jest tests/orchestrator.test.js --forceExit",coverage:"jest --coverage --forceExit","test:watch":"jest --watch",typecheck:"tsc --noEmit",format:"prettier --write .","scan:secrets":"node scripts/secret-scan.js --staged","install-hooks":"ln -sf ../../hooks/pre-commit .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit && ln -sf ../../hooks/pre-push .git/hooks/pre-push && chmod +x .git/hooks/pre-push && ln -sf ../../hooks/post-merge .git/hooks/post-merge && chmod +x .git/hooks/post-merge && echo 'Hooks installed (pre-commit, pre-push, post-merge).'",prepublishOnly:"npm run build && npm test","merge-to-main":"bash scripts/merge-to-main.sh",improve:"node scripts/improve.js","extract-examples":"node scripts/extract-examples.js","benchmark:realworld":"node scripts/benchmark-realworld.js","benchmark:reallife":"node scripts/benchmark-reallife.js","benchmark:report":"node scripts/benchmark-reallife-report.js","improve:reallife":"node scripts/improve-reallife.js","benchmark:gate":"node scripts/benchmark-gate.js",release:"bash scripts/release.sh"},keywords:["ai","cli","coding","agent","ollama","ollama-cloud","openai","anthropic","gemini","llm","gpt","agentic","terminal","coding-assistant","open-source","free","qwen3","devstral","kimi-k2","deepseek","local-llm","mcp","model-context-protocol","multi-provider"],repository:{type:"git",url:"https://github.com/hybridpicker/nex-code.git"},bugs:{url:"https://github.com/hybridpicker/nex-code/issues"},homepage:"https://github.com/hybridpicker/nex-code#readme",license:"MIT",dependencies:{axios:"^1.15.0",dotenv:"^16.4.0",pixelmatch:"^7.1.0",pngjs:"^7.0.0"},devDependencies:{esbuild:"^0.27.3",jest:"^29.7.0",prettier:"^3.8.1",typescript:"^5.9.3"},overrides:{"brace-expansion":">=5.0.5",picomatch:">=4.0.4"},jest:{coverageThreshold:{global:{lines:45,functions:30,branches:35},"./cli/sub-agent.js":{lines:70,functions:60,branches:55}}}}});var vs=J((JO,sp)=>{var{T:z}=pn(),Ql=5,wo=(()=>{let t=[];for(let e=0;e<Ql;e++)t.push(e);for(let e=Ql-2;e>=1;e--)t.push(e);return t})(),Zf=["\u273D","\u2726","\u2727","\u2726"],Qf=["\xB7 ","\xB7\xB7 ","\xB7\xB7\xB7"," \xB7\xB7"];function ep(t=""){let e=String(t).toLowerCase();return e.includes("search")||e.includes("read")||e.includes("list")||e.includes("inspect")?{glyph:"\u25CC",color:z.cyan,accent:"scan"}:e.includes("write")||e.includes("edit")||e.includes("patch")||e.includes("build")?{glyph:"\u2726",color:z.yellow,accent:"shape"}:e.includes("test")||e.includes("diff")||e.includes("check")||e.includes("verify")?{glyph:"\u25A3",color:z.green,accent:"verify"}:e.includes("wait")||e.includes("github")||e.includes("fetch")||e.includes("browser")?{glyph:"\u25CD",color:z.blue,accent:"wait"}:{glyph:"\u25CF",color:z.cyan,accent:"think"}}function tp(t,e,n){let o="";for(let s=0;s<Ql;s++)s===t?o+=`${n}${e}${z.reset}`:s===t-1||s===t+1?o+=`${z.dim}\xB7${z.reset}`:o+=`${z.dim}\xB7${z.reset}`;return o}function np(t){return`${z.dim}${Qf[t%Qf.length]}${z.reset}`}var ec=class{constructor(e="Thinking..."){this.text=e,this.frame=0,this.interval=null,this.startTime=null}_render(){if(this._stopped)return;let e=wo[this.frame%wo.length],n=ep(this.text),o=tp(e,n.glyph,n.color),s=np(this.frame),r="";if(this.startTime){let i=Math.floor((Date.now()-this.startTime)/1e3);if(i>=60){let a=Math.floor(i/60),l=i%60;r=` ${z.dim}${a}m ${String(l).padStart(2,"0")}s${z.reset}`}else i>=1&&(r=` ${z.dim}${i}s${z.reset}`)}process.stderr.write(`\x1B[2K\r${n.color}${n.accent.toUpperCase()}${z.reset}${s} ${o} ${z.dim}${this.text}${z.reset}${r}`),this.frame++}start(){this._stopped=!1,this.startTime=Date.now(),process.stderr.isTTY&&(process.stderr.write("\x1B[?25l"),this._render(),this.interval=setInterval(()=>this._render(),100))}update(e){this.text=e}stop(){this._stopped=!0,this.interval&&(clearInterval(this.interval),this.interval=null),process.stderr.isTTY&&process.stderr.write("\x1B[2K\r\x1B[?25h"),this.startTime=null}},tc=class{constructor(e){this.labels=e,this.statuses=e.map(()=>"running"),this.frame=0,this.interval=null,this.startTime=null,this.lineCount=e.length}_formatElapsed(){if(!this.startTime)return"";let e=Math.floor((Date.now()-this.startTime)/1e3);if(e<1)return"";let n=Math.floor(e/60),o=e%60;return n>0?`${n}m ${String(o).padStart(2,"0")}s`:`${o}s`}_render(){if(this._stopped)return;let e=wo[this.frame%wo.length],n=`${z.cyan}\u25CC${z.reset}`,o=this._formatElapsed(),s=o?` ${z.dim}${o}${z.reset}`:"",r=process.stderr.columns||80,i="";for(let a=0;a<this.labels.length;a++){let l,c;switch(this.statuses[a]){case"done":l=`${z.green}\u2713${z.reset}`,c=z.dim;break;case"error":l=`${z.red}\u2717${z.reset}`,c=z.dim;break;case"retry":l=`${z.yellow}\u21BB${z.reset}`,c=z.yellow;break;default:l=a===e?n:`${z.dim}\xB7${z.reset}`,c=""}let u=a===this.labels.length-1?s:"",d=r-4-(u?o.length+1:0),f=this.labels[a].length>d?this.labels[a].substring(0,Math.max(10,d-3))+"...":this.labels[a];i+=`\x1B[2K ${l} ${c}${f}${z.reset}${u}
108
+ `},"g5")]}):{content:"Resolved the simulated multi-file git conflict while preserving the configurable port behavior.",tool_calls:[]}}return{content:"No mock scenario matched this prompt. Set a Scenario A\u2013G prompt (or enable malformed mode) to run deterministic E2E flows.",tool_calls:[]}}var Xl=class extends W_{constructor(e={}){super({name:"mock",baseUrl:"mock://",models:{"mock-model":{id:"mock-model",name:"Mock Model",maxTokens:4096,contextWindow:8192}},defaultModel:"mock-model",...e})}isConfigured(){return process.env.NEX_MOCK_PROVIDER==="1"}async chat(e,n,o={}){return Vf(e)}async stream(e,n,o={}){let s=typeof o.onToken=="function"?o.onToken:()=>{},r=Vf(e),i=String(r.content||""),a=Math.min(i.length,Math.max(1,Math.floor(i.length/2)));return i&&(s(i.slice(0,a)),s(i.slice(a))),r}normalizeResponse(e){return e}};Jf.exports={MockProvider:Xl}});var Zl=J((XO,e$)=>{e$.exports={name:"nex-code",version:"0.5.21",description:"Run 400B+ open coding models on your codebase without the hardware bill. Ollama Cloud first \u2014 OpenAI, Anthropic, and Gemini when you need them.",bin:{"nex-code":"./dist/nex-code.js"},files:["dist/","examples/","README.md","LICENSE"],engines:{node:">=18.0.0"},scripts:{start:"node dist/nex-code.js",build:"node scripts/build.js",dev:"node scripts/build.js --dev",test:"jest --runInBand","test:orchestrator":"jest tests/orchestrator.test.js --forceExit",coverage:"jest --coverage --forceExit","test:watch":"jest --watch",typecheck:"tsc --noEmit",format:"prettier --write .","scan:secrets":"node scripts/secret-scan.js --staged","install-hooks":"ln -sf ../../hooks/pre-commit .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit && ln -sf ../../hooks/pre-push .git/hooks/pre-push && chmod +x .git/hooks/pre-push && ln -sf ../../hooks/post-merge .git/hooks/post-merge && chmod +x .git/hooks/post-merge && echo 'Hooks installed (pre-commit, pre-push, post-merge).'",prepublishOnly:"npm run build && npm test","merge-to-main":"bash scripts/merge-to-main.sh",improve:"node scripts/improve.js","extract-examples":"node scripts/extract-examples.js","benchmark:realworld":"node scripts/benchmark-realworld.js","benchmark:reallife":"node scripts/benchmark-reallife.js","benchmark:report":"node scripts/benchmark-reallife-report.js","improve:reallife":"node scripts/improve-reallife.js","benchmark:gate":"node scripts/benchmark-gate.js",release:"bash scripts/release.sh"},keywords:["ai","cli","coding","agent","ollama","ollama-cloud","openai","anthropic","gemini","llm","gpt","agentic","terminal","coding-assistant","open-source","free","qwen3","devstral","kimi-k2","deepseek","local-llm","mcp","model-context-protocol","multi-provider"],repository:{type:"git",url:"https://github.com/hybridpicker/nex-code.git"},bugs:{url:"https://github.com/hybridpicker/nex-code/issues"},homepage:"https://github.com/hybridpicker/nex-code#readme",license:"MIT",dependencies:{axios:"^1.15.0",dotenv:"^16.4.0",pixelmatch:"^7.1.0",pngjs:"^7.0.0"},devDependencies:{esbuild:"^0.27.3",jest:"^29.7.0",prettier:"^3.8.1",typescript:"^5.9.3"},overrides:{"brace-expansion":">=5.0.5",picomatch:">=4.0.4"},jest:{coverageThreshold:{global:{lines:45,functions:30,branches:35},"./cli/sub-agent.js":{lines:70,functions:60,branches:55}}}}});var vs=J((JO,sp)=>{var{T:z}=pn(),Ql=5,wo=(()=>{let t=[];for(let e=0;e<Ql;e++)t.push(e);for(let e=Ql-2;e>=1;e--)t.push(e);return t})(),Zf=["\u273D","\u2726","\u2727","\u2726"],Qf=["\xB7 ","\xB7\xB7 ","\xB7\xB7\xB7"," \xB7\xB7"];function ep(t=""){let e=String(t).toLowerCase();return e.includes("search")||e.includes("read")||e.includes("list")||e.includes("inspect")?{glyph:"\u25CC",color:z.cyan,accent:"scan"}:e.includes("write")||e.includes("edit")||e.includes("patch")||e.includes("build")?{glyph:"\u2726",color:z.yellow,accent:"shape"}:e.includes("test")||e.includes("diff")||e.includes("check")||e.includes("verify")?{glyph:"\u25A3",color:z.green,accent:"verify"}:e.includes("wait")||e.includes("github")||e.includes("fetch")||e.includes("browser")?{glyph:"\u25CD",color:z.blue,accent:"wait"}:{glyph:"\u25CF",color:z.cyan,accent:"think"}}function tp(t,e,n){let o="";for(let s=0;s<Ql;s++)s===t?o+=`${n}${e}${z.reset}`:s===t-1||s===t+1?o+=`${z.dim}\xB7${z.reset}`:o+=`${z.dim}\xB7${z.reset}`;return o}function np(t){return`${z.dim}${Qf[t%Qf.length]}${z.reset}`}var ec=class{constructor(e="Thinking..."){this.text=e,this.frame=0,this.interval=null,this.startTime=null}_render(){if(this._stopped)return;let e=wo[this.frame%wo.length],n=ep(this.text),o=tp(e,n.glyph,n.color),s=np(this.frame),r="";if(this.startTime){let i=Math.floor((Date.now()-this.startTime)/1e3);if(i>=60){let a=Math.floor(i/60),l=i%60;r=` ${z.dim}${a}m ${String(l).padStart(2,"0")}s${z.reset}`}else i>=1&&(r=` ${z.dim}${i}s${z.reset}`)}process.stderr.write(`\x1B[2K\r${n.color}${n.accent.toUpperCase()}${z.reset}${s} ${o} ${z.dim}${this.text}${z.reset}${r}`),this.frame++}start(){this._stopped=!1,this.startTime=Date.now(),process.stderr.isTTY&&(process.stderr.write("\x1B[?25l"),this._render(),this.interval=setInterval(()=>this._render(),100))}update(e){this.text=e}stop(){this._stopped=!0,this.interval&&(clearInterval(this.interval),this.interval=null),process.stderr.isTTY&&process.stderr.write("\x1B[2K\r\x1B[?25h"),this.startTime=null}},tc=class{constructor(e){this.labels=e,this.statuses=e.map(()=>"running"),this.frame=0,this.interval=null,this.startTime=null,this.lineCount=e.length}_formatElapsed(){if(!this.startTime)return"";let e=Math.floor((Date.now()-this.startTime)/1e3);if(e<1)return"";let n=Math.floor(e/60),o=e%60;return n>0?`${n}m ${String(o).padStart(2,"0")}s`:`${o}s`}_render(){if(this._stopped)return;let e=wo[this.frame%wo.length],n=`${z.cyan}\u25CC${z.reset}`,o=this._formatElapsed(),s=o?` ${z.dim}${o}${z.reset}`:"",r=process.stderr.columns||80,i="";for(let a=0;a<this.labels.length;a++){let l,c;switch(this.statuses[a]){case"done":l=`${z.green}\u2713${z.reset}`,c=z.dim;break;case"error":l=`${z.red}\u2717${z.reset}`,c=z.dim;break;case"retry":l=`${z.yellow}\u21BB${z.reset}`,c=z.yellow;break;default:l=a===e?n:`${z.dim}\xB7${z.reset}`,c=""}let u=a===this.labels.length-1?s:"",d=r-4-(u?o.length+1:0),f=this.labels[a].length>d?this.labels[a].substring(0,Math.max(10,d-3))+"...":this.labels[a];i+=`\x1B[2K ${l} ${c}${f}${z.reset}${u}
109
109
  `}this.lineCount>0&&(i+=`\x1B[${this.lineCount}A`),process.stderr.write(i),this.frame++}start(){this._stopped=!1,this.startTime=Date.now();let e="\x1B[?25l";for(let n=0;n<this.lineCount;n++)e+=`
110
110
  `;this.lineCount>0&&(e+=`\x1B[${this.lineCount}A`),process.stderr.write(e),this._render(),this.interval=setInterval(()=>this._render(),100)}update(e,n){e>=0&&e<this.statuses.length&&(this.statuses[e]=n)}stop(e={}){if(this._stopped=!0,this.interval&&(clearInterval(this.interval),this.interval=null),!e.silent)this._renderFinal();else{let n="";for(let o=0;o<this.lineCount;o++)n+=`\x1B[2K
111
111
  `;this.lineCount>0&&(n+=`\x1B[${this.lineCount}A`),process.stderr.write(n)}process.stderr.write("\x1B[?25h")}_renderFinal(){let e=this._formatElapsed(),n=e?` ${z.dim}${e}${z.reset}`:"",o=process.stderr.columns||80,s="";for(let r=0;r<this.labels.length;r++){let i;switch(this.statuses[r]){case"done":i=`${z.green}\u2713${z.reset}`;break;case"error":i=`${z.red}\u2717${z.reset}`;break;case"retry":i=`${z.yellow}\u21BB${z.reset}`;break;default:i=`${z.yellow}\u25CB${z.reset}`}let a=r===this.labels.length-1?n:"",l=o-4-(a?e.length+1:0),c=this.labels[r].length>l?this.labels[r].substring(0,Math.max(10,l-3))+"...":this.labels[r];s+=`\x1B[2K ${i} ${z.dim}${c}${z.reset}${a}
@@ -941,7 +941,7 @@ end try`],{timeout:3e3});if(o.stdout&&o.stdout.toString().trim()==="has_image"){
941
941
  [SYSTEM: Output repetition detected \u2014 response truncated (${s}\xD7 repeated paragraph)]`,a;if(t.length>8e3)a=t.slice(0,3e3)+i;else{let l=0,c=-1,u=0;for(;l<2;){let d=t.indexOf(r,u);if(d===-1)break;l++,c=d+r.length,u=d+1}a=c>0?t.slice(0,c)+i:t.slice(0,3e3)+i}return{text:a,truncated:!0,repeatCount:s}}function gd(t,e=5){if(!t||t.length<40)return{text:t,truncated:!1,repeatCount:0};let n=t.split(`
942
942
  `),o=new Map;for(let h of n){let m=h.trim();m.length>=20&&o.set(m,(o.get(m)||0)+1)}let s=0,r="";for(let[h,m]of o)m>s&&(s=m,r=h);let a=r.toLowerCase().includes("read_file")||r.toLowerCase().includes("reading")?2:e;if(s<=a)return{text:t,truncated:!1,repeatCount:s};let l=`
943
943
 
944
- \u26A0 [Response truncated: repeated paragraph detected (${s}\xD7)]`,c=0,u=-1,d=0;for(;c<e;){let h=t.indexOf(r,d);if(h===-1)break;c++,u=h+r.length,d=h+1}return{text:u>0?t.slice(0,u)+l:t.slice(0,2e3)+l,truncated:!0,repeatCount:s}}var od=null,rd=null,id=null;function Bt(){if(od===null){let{TOOL_DEFINITIONS:t}=cr();od=t}return rd===null&&(rd=LC()),id===null&&(id=NC()),[...od,...rd,...id]}var yd=50;function XC(t){Number.isFinite(t)&&t>0&&(yd=t)}function ad(t=In()){if(process.env.NEX_DISABLE_TOOL_BUDGET==="1")return 1/0;let e=process.env.NEX_MAX_TOOL_CALLS;if(e){let n=parseInt(e,10);if(Number.isFinite(n)&&n>0)return n}return t==="local"?5:30}function uw(t,e){return`[SYSTEM STOP] Tool-call budget reached (${t}/${e}). You MUST stop calling tools now. Provide your final answer based only on the information already in the conversation. If the task cannot be completed from the gathered evidence, state the blocker plainly and do not invent facts.`}var Ja=()=>null;function JC(t){Ja=t}var Kr=null,bd=null,Uo=null,Wo="",Ho=0,wd="",_d=0,Za=new Map,ZC=1e4,QC=6e3,eA=/\b((?:API|ACCESS|AUTH|BEARER|CLIENT|GITHUB|GITLAB|SLACK|STRIPE|TWILIO|SENDGRID|AWS|GCP|AZURE|OPENAI|ANTHROPIC|GEMINI|OLLAMA)[_A-Z0-9]*(?:KEY|TOKEN|SECRET|PASS(?:WORD)?|CREDENTIAL)[_A-Z0-9]*)\s*=\s*["']?([A-Za-z0-9\-_.+/=]{10,})["']?/g;function tA(t){return!t||typeof t!="string"?t:t.replace(eA,(e,n)=>`${n}=***REDACTED***`)}var nA=7e3,sA=4e3;function oA(t,e=null){let n=tA(t),o=rC(n),s=e==="read_file"?nA:ZC,r=e==="read_file"?sA:QC;if(o>s)try{let{compressToolResult:i}=Pn();return i(n,r)}catch{return n}return n}function Ew(t){try{let{getActiveModel:e}=$t(),n=e(),o=n?`${n.provider}:${n.id}`:"default";if(Za.has(o))return Za.get(o);let s=iw(t);return Za.set(o,s),s}catch{return iw(t)}}function rA(){Za.clear()}function iA(t,e){let n=new Set(e);return(t||[]).some(o=>o.role!=="assistant"?!1:Array.isArray(o.tool_calls)?o.tool_calls.some(s=>n.has(s?.function?.name||s?.name)):Array.isArray(o.content)?o.content.some(s=>s?.type==="tool_use"&&n.has(s?.name)):!1)}var Vr={hash:null,ts:0},aA=3e4;async function Tw(){if(Vr.hash&&Date.now()-Vr.ts<aA)return Vr.hash;try{let t=require("fs").promises,e=require("path"),n=[e.join(process.cwd(),"package.json"),e.join(process.cwd(),".git","HEAD"),e.join(process.cwd(),"README.md"),e.join(process.cwd(),"NEX.md")],s=(await Promise.allSettled(n.map(i=>t.stat(i).then(a=>`${i}:${a.mtimeMs}`)))).filter(i=>i.status==="fulfilled").map(i=>i.value);try{let{getMemoryContextHash:i}=Sr(),a=i();a&&s.push(`memory:${a}`)}catch{}try{let i=e.join(process.cwd(),".nex","brain");if(tt.existsSync(i)){let a=await t.stat(i);s.push(`brain:${a.mtimeMs}`)}}catch{}let r=s.join("|");return Vr={hash:r,ts:Date.now()},r}catch{return`fallback:${Date.now()}`}}function $d(){Kr=null,bd=null,Vr={hash:null,ts:0},Uo=null}var lA=new Set(["spawn_agents"]),ld=10,cd=10,Ka=5,dw=6e4,ud=12e4,cA=process.env.NEX_STALE_AUTO_SWITCH!=="0";function uA(t){try{let e=require("fs"),n=require("path"),o=n.join(process.cwd(),".nex","plans");e.existsSync(o)||e.mkdirSync(o,{recursive:!0});let s=n.join(o,"current-plan.md");e.writeFileSync(s,t,"utf-8")}catch{}}SC(t=>{kC(t,"allow"),xC(),console.log(`${p.green} \u2713 ${t}: always allow${p.reset}`)});async function dA(t){let e=t.function.name,n=e;if(typeof e=="string"&&e.includes(".")){let d=e.split(".").pop(),f={exec:"bash",find:"search_files",search:"search_files",grep_search:"grep",read:"read_file"};Bt().some(m=>m.function.name===d)?n=d:f[d]&&(n=f[d])}let o=nC(t.function.arguments),s=t.id||`cli-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;if(!o){let f=Bt().find(m=>m.function.name===n),h=f?JSON.stringify(f.function.parameters,null,2):"unknown";return P(`${p.yellow} \u26A0 ${n}: malformed arguments, sending schema hint${p.reset}`),{callId:s,fnName:n,args:null,canExecute:!1,errorResult:{role:"tool",content:`ERROR: Malformed tool arguments. Could not parse your arguments as JSON.
944
+ \u26A0 [Response truncated: repeated paragraph detected (${s}\xD7)]`,c=0,u=-1,d=0;for(;c<e;){let h=t.indexOf(r,d);if(h===-1)break;c++,u=h+r.length,d=h+1}return{text:u>0?t.slice(0,u)+l:t.slice(0,2e3)+l,truncated:!0,repeatCount:s}}var od=null,rd=null,id=null;function Bt(){if(od===null){let{TOOL_DEFINITIONS:t}=cr();od=t}return rd===null&&(rd=LC()),id===null&&(id=NC()),[...od,...rd,...id]}var yd=50;function XC(t){Number.isFinite(t)&&t>0&&(yd=t)}function ad(t=In()){if(process.env.NEX_DISABLE_TOOL_BUDGET==="1")return 1/0;let e=process.env.NEX_MAX_TOOL_CALLS;if(e){let n=parseInt(e,10);if(Number.isFinite(n)&&n>0)return n}return t==="local"?5:30}function uw(t,e){return`[SYSTEM STOP] Tool-call budget reached (${t}/${e}). You MUST stop calling tools now. Provide your final answer based only on the information already in the conversation. If the task cannot be completed from the gathered evidence, state the blocker plainly and do not invent facts.`}var Ja=()=>null;function JC(t){Ja=t}var Kr=null,bd=null,Uo=null,Wo="",Ho=0,wd="",_d=0,Za=new Map,ZC=1e4,QC=6e3,eA=/\b((?:API|ACCESS|AUTH|BEARER|CLIENT|GITHUB|GITLAB|SLACK|STRIPE|TWILIO|SENDGRID|AWS|GCP|AZURE|OPENAI|ANTHROPIC|GEMINI|OLLAMA)[_A-Z0-9]*(?:KEY|TOKEN|SECRET|PASS(?:WORD)?|CREDENTIAL)[_A-Z0-9]*)\s*=\s*["']?([A-Za-z0-9\-_.+/=]{10,})["']?/g;function tA(t){return!t||typeof t!="string"?t:t.replace(eA,(e,n)=>`${n}=***REDACTED***`)}var nA=7e3,sA=4e3;function oA(t,e=null){let n=tA(t),o=rC(n),s=e==="read_file"?nA:ZC,r=e==="read_file"?sA:QC;if(o>s)try{let{compressToolResult:i}=Pn();return i(n,r)}catch{return n}return n}function Ew(t){try{let{getActiveModel:e}=$t(),n=e(),o=n?`${n.provider}:${n.id}`:"default";if(Za.has(o))return Za.get(o);let s=iw(t);return Za.set(o,s),s}catch{return iw(t)}}function rA(){Za.clear()}function iA(t,e){let n=new Set(e);return(t||[]).some(o=>o.role!=="assistant"?!1:Array.isArray(o.tool_calls)?o.tool_calls.some(s=>n.has(s?.function?.name||s?.name)):Array.isArray(o.content)?o.content.some(s=>s?.type==="tool_use"&&n.has(s?.name)):!1)}var Vr={hash:null,ts:0},aA=3e4;async function Tw(){if(Vr.hash&&Date.now()-Vr.ts<aA)return Vr.hash;try{let t=require("fs").promises,e=require("path"),n=[e.join(process.cwd(),"package.json"),e.join(process.cwd(),".git","HEAD"),e.join(process.cwd(),"README.md"),e.join(process.cwd(),"NEX.md")],s=(await Promise.allSettled(n.map(i=>t.stat(i).then(a=>`${i}:${a.mtimeMs}`)))).filter(i=>i.status==="fulfilled").map(i=>i.value);try{let{getMemoryContextHash:i}=Sr(),a=i();a&&s.push(`memory:${a}`)}catch{}try{let i=e.join(process.cwd(),".nex","brain");if(tt.existsSync(i)){let a=await t.stat(i);s.push(`brain:${a.mtimeMs}`)}}catch{}let r=s.join("|");return Vr={hash:r,ts:Date.now()},r}catch{return`fallback:${Date.now()}`}}function $d(){Kr=null,bd=null,Vr={hash:null,ts:0},Uo=null}var lA=new Set(["spawn_agents"]),ld=10,cd=10,Ka=5,dw=6e4,ud=12e4,cA=process.env.NEX_STALE_AUTO_SWITCH!=="0";function uA(t){try{let e=require("fs"),n=require("path"),o=n.join(process.cwd(),".nex","plans");e.existsSync(o)||e.mkdirSync(o,{recursive:!0});let s=n.join(o,"current-plan.md");e.writeFileSync(s,t,"utf-8")}catch{}}SC(t=>{kC(t,"allow"),xC(),console.log(`${p.green} \u2713 ${t}: always allow${p.reset}`)});async function dA(t){let e=t.function.name,n=e;if(typeof e=="string"&&e.includes(".")){let d=e.split(".").pop(),f={exec:"bash",find:"search_files",search:"search_files",grep_search:"grep",list:"list_directory",print_tree:"list_directory",read:"read_file",tree:"list_directory"};Bt().some(m=>m.function.name===d)?n=d:f[d]&&(n=f[d])}let o=nC(t.function.arguments),s=t.id||`cli-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;if(!o){let f=Bt().find(m=>m.function.name===n),h=f?JSON.stringify(f.function.parameters,null,2):"unknown";return P(`${p.yellow} \u26A0 ${n}: malformed arguments, sending schema hint${p.reset}`),{callId:s,fnName:n,args:null,canExecute:!1,errorResult:{role:"tool",content:`ERROR: Malformed tool arguments. Could not parse your arguments as JSON.
945
945
  Raw input: ${typeof t.function.arguments=="string"?t.function.arguments.substring(0,200):"N/A"}
946
946
 
947
947
  Expected JSON schema for "${n}":
package/dist/benchmark.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";var zl=Object.defineProperty;var __=Object.getOwnPropertyDescriptor;var $_=Object.getOwnPropertyNames;var k_=Object.prototype.hasOwnProperty;var x_=(t,e)=>()=>(t&&(e=t(t=0)),e);var Z=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),v_=(t,e)=>{for(var n in e)zl(t,n,{get:e[n],enumerable:!0})},S_=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of $_(e))!k_.call(t,s)&&s!==n&&zl(t,s,{get:()=>e[s],enumerable:!(o=__(e,s))||o.enumerable});return t};var E_=t=>S_(zl({},"__esModule",{value:!0}),t);var hn=Z((RP,Mf)=>{"use strict";var Rf="\x1B[0m",Cf="\x1B[1m",bo="\x1B[2m";function z(t,e,n){return`\x1B[38;2;${t};${e};${n}m`}function T_(){if(!process.stdout.isTTY)return null;try{let{execFileSync:t}=require("child_process"),e=["import sys,os,tty,termios,select","f=open('/dev/tty','r+b',buffering=0)","fd=f.fileno()","s=termios.tcgetattr(fd)","try:"," tty.setraw(fd)"," f.write(bytes([0x1b,0x5d,0x31,0x31,0x3b,0x3f,0x1b,0x5c]))"," r=select.select([fd],[],[],0.1)[0]"," d=b''"," if r:"," while True:"," r2=select.select([fd],[],[],0.05)[0]"," if not r2:break"," c=os.read(fd,1)"," d+=c"," if d[-1:]==bytes([0x07]) or d[-2:]==bytes([0x1b,0x5c]):break"," sys.stdout.buffer.write(d)","finally:"," termios.tcsetattr(fd,termios.TCSADRAIN,s)"," f.close()"].join(`
2
- `),s=t("python3",["-c",e],{encoding:"buffer",timeout:400,stdio:["ignore","pipe","ignore"]}).toString("utf8").match(/rgb:([0-9a-fA-F]+)\/([0-9a-fA-F]+)\/([0-9a-fA-F]+)/);if(s){let r=parseInt(s[1].slice(0,2),16),i=parseInt(s[2].slice(0,2),16),a=parseInt(s[3].slice(0,2),16);return .299*r+.587*i+.114*a<128}}catch{}return null}function Af(){let t=require("os");return require("path").join(t.homedir(),".nex-code",".theme_cache.json")}function R_(t){try{let n=require("fs").readFileSync(Af(),"utf8"),o=JSON.parse(n);if(o&&typeof o[t]=="boolean")return o[t]}catch(e){console.error("readThemeCache failed:",e.message)}return null}function C_(t,e){try{let n=require("fs"),o=require("path"),s=Af(),r=o.dirname(s),i={};try{i=JSON.parse(n.readFileSync(s,"utf8"))}catch(l){console.error("theme cache failed:",l.message)}i[t]=e;let a=Object.keys(i);a.length>50&&a.slice(0,a.length-50).forEach(l=>delete i[l]),n.existsSync(r)||n.mkdirSync(r,{recursive:!0}),n.writeFileSync(s,JSON.stringify(i),"utf8")}catch{}}function A_(){let t=(process.env.NEX_THEME||"").toLowerCase();if(t==="light")return!1;if(t==="dark")return!0;let e=process.env.COLORFGBG;if(e){let i=e.split(";"),a=parseInt(i[i.length-1],10);if(!isNaN(a))return a<8}let n=process.env.TERM_SESSION_ID||"default",o=R_(n);if(o!==null)return o;let s=T_(),r=s!==null?s:!0;return C_(n,r),r}var Of=A_(),Pf={reset:Rf,bold:Cf,dim:bo,primary:z(80,190,255),secondary:z(60,170,190),success:z(80,210,120),warning:z(245,175,50),error:z(230,80,80),muted:bo,subtle:z(130,130,145),tool_read:z(80,190,255),tool_write:z(245,165,55),tool_exec:z(185,100,235),tool_search:z(70,185,190),tool_git:z(90,210,100),tool_web:z(100,215,250),tool_sysadmin:z(225,150,75),tool_default:z(100,205,115),syn_keyword:z(185,100,235),syn_string:z(90,210,120),syn_number:z(245,175,50),syn_comment:bo,syn_key:z(80,190,255),diff_add:z(80,210,120),diff_rem:z(230,80,80),banner_logo:z(80,200,255),banner_name:z(80,200,255),banner_version:bo,banner_model:bo,banner_yolo:z(245,175,50),banner_gemini:z(138,180,248),footer_sep:bo,footer_model:z(80,175,235),footer_branch:z(80,210,100),footer_project:z(130,130,145),footer_divider:z(80,80,95),footer_mode:z(210,150,50),white:z(210,210,220),red:z(220,85,85),green:z(80,200,110),yellow:z(230,185,60),blue:z(70,140,230),magenta:z(200,120,190),cyan:z(90,200,215),gray:z(120,120,135),bgRed:"\x1B[48;2;140;40;40m",bgGreen:"\x1B[48;2;30;100;50m",diff_add_bg:"\x1B[48;2;10;46;20m",diff_rem_bg:"\x1B[48;2;58;16;16m",brightCyan:z(110,215,230),brightMagenta:z(220,140,210),brightBlue:z(100,160,240)},Nf={reset:Rf,bold:Cf,dim:z(110,110,120),primary:z(0,110,190),secondary:z(0,125,148),success:z(0,148,62),warning:z(168,92,0),error:z(188,32,32),muted:z(110,110,120),subtle:z(155,155,165),tool_read:z(0,110,190),tool_write:z(168,92,0),tool_exec:z(128,42,188),tool_search:z(0,122,148),tool_git:z(0,138,62),tool_web:z(0,112,178),tool_sysadmin:z(168,82,0),tool_default:z(0,138,62),syn_keyword:z(128,42,188),syn_string:z(0,138,62),syn_number:z(168,92,0),syn_comment:z(135,135,148),syn_key:z(0,110,190),diff_add:z(0,148,62),diff_rem:z(188,32,32),banner_logo:z(0,122,205),banner_name:z(0,122,205),banner_version:z(100,100,118),banner_model:z(100,100,118),banner_yolo:z(168,62,0),banner_gemini:z(26,115,232),footer_sep:z(168,168,178),footer_model:z(0,102,175),footer_branch:z(0,138,62),footer_project:z(135,135,148),footer_divider:z(168,168,178),footer_mode:z(148,88,0),white:z(40,40,52),red:z(188,32,32),green:z(0,148,62),yellow:z(168,92,0),blue:z(0,110,190),magenta:z(128,42,188),cyan:z(0,125,148),gray:z(132,132,142),bgRed:"\x1B[48;2;180;50;50m",bgGreen:"\x1B[48;2;30;130;60m",diff_add_bg:"\x1B[48;2;215;245;220m",diff_rem_bg:"\x1B[48;2;255;215;215m",brightCyan:z(0,158,182),brightMagenta:z(158,52,208),brightBlue:z(0,112,208)},O_=Of?Pf:Nf;Mf.exports={T:O_,isDark:Of,DARK:Pf,LIGHT:Nf}});var Ai=Z((CP,P_)=>{P_.exports={name:"nex-code",version:"0.5.20",description:"Run 400B+ open coding models on your codebase without the hardware bill. Ollama Cloud first \u2014 OpenAI, Anthropic, and Gemini when you need them.",bin:{"nex-code":"./dist/nex-code.js"},files:["dist/","examples/","README.md","LICENSE"],engines:{node:">=18.0.0"},scripts:{start:"node dist/nex-code.js",build:"node scripts/build.js",dev:"node scripts/build.js --dev",test:"jest --runInBand","test:orchestrator":"jest tests/orchestrator.test.js --forceExit",coverage:"jest --coverage --forceExit","test:watch":"jest --watch",typecheck:"tsc --noEmit",format:"prettier --write .","scan:secrets":"node scripts/secret-scan.js --staged","install-hooks":"ln -sf ../../hooks/pre-commit .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit && ln -sf ../../hooks/pre-push .git/hooks/pre-push && chmod +x .git/hooks/pre-push && ln -sf ../../hooks/post-merge .git/hooks/post-merge && chmod +x .git/hooks/post-merge && echo 'Hooks installed (pre-commit, pre-push, post-merge).'",prepublishOnly:"npm run build && npm test","merge-to-main":"bash scripts/merge-to-main.sh",improve:"node scripts/improve.js","extract-examples":"node scripts/extract-examples.js","benchmark:realworld":"node scripts/benchmark-realworld.js","benchmark:reallife":"node scripts/benchmark-reallife.js","benchmark:report":"node scripts/benchmark-reallife-report.js","improve:reallife":"node scripts/improve-reallife.js","benchmark:gate":"node scripts/benchmark-gate.js",release:"bash scripts/release.sh"},keywords:["ai","cli","coding","agent","ollama","ollama-cloud","openai","anthropic","gemini","llm","gpt","agentic","terminal","coding-assistant","open-source","free","qwen3","devstral","kimi-k2","deepseek","local-llm","mcp","model-context-protocol","multi-provider"],repository:{type:"git",url:"https://github.com/hybridpicker/nex-code.git"},bugs:{url:"https://github.com/hybridpicker/nex-code/issues"},homepage:"https://github.com/hybridpicker/nex-code#readme",license:"MIT",dependencies:{axios:"^1.15.0",dotenv:"^16.4.0",pixelmatch:"^7.1.0",pngjs:"^7.0.0"},devDependencies:{esbuild:"^0.27.3",jest:"^29.7.0",prettier:"^3.8.1",typescript:"^5.9.3"},overrides:{"brace-expansion":">=5.0.5",picomatch:">=4.0.4"},jest:{coverageThreshold:{global:{lines:45,functions:30,branches:35},"./cli/sub-agent.js":{lines:70,functions:60,branches:55}}}}});var ks=Z((AP,Ff)=>{var{T:K}=hn(),Kl=5,wo=(()=>{let t=[];for(let e=0;e<Kl;e++)t.push(e);for(let e=Kl-2;e>=1;e--)t.push(e);return t})(),Lf=["\u273D","\u2726","\u2727","\u2726"],If=["\xB7 ","\xB7\xB7 ","\xB7\xB7\xB7"," \xB7\xB7"];function jf(t=""){let e=String(t).toLowerCase();return e.includes("search")||e.includes("read")||e.includes("list")||e.includes("inspect")?{glyph:"\u25CC",color:K.cyan,accent:"scan"}:e.includes("write")||e.includes("edit")||e.includes("patch")||e.includes("build")?{glyph:"\u2726",color:K.yellow,accent:"shape"}:e.includes("test")||e.includes("diff")||e.includes("check")||e.includes("verify")?{glyph:"\u25A3",color:K.green,accent:"verify"}:e.includes("wait")||e.includes("github")||e.includes("fetch")||e.includes("browser")?{glyph:"\u25CD",color:K.blue,accent:"wait"}:{glyph:"\u25CF",color:K.cyan,accent:"think"}}function Df(t,e,n){let o="";for(let s=0;s<Kl;s++)s===t?o+=`${n}${e}${K.reset}`:s===t-1||s===t+1?o+=`${K.dim}\xB7${K.reset}`:o+=`${K.dim}\xB7${K.reset}`;return o}function qf(t){return`${K.dim}${If[t%If.length]}${K.reset}`}var Vl=class{constructor(e="Thinking..."){this.text=e,this.frame=0,this.interval=null,this.startTime=null}_render(){if(this._stopped)return;let e=wo[this.frame%wo.length],n=jf(this.text),o=Df(e,n.glyph,n.color),s=qf(this.frame),r="";if(this.startTime){let i=Math.floor((Date.now()-this.startTime)/1e3);if(i>=60){let a=Math.floor(i/60),l=i%60;r=` ${K.dim}${a}m ${String(l).padStart(2,"0")}s${K.reset}`}else i>=1&&(r=` ${K.dim}${i}s${K.reset}`)}process.stderr.write(`\x1B[2K\r${n.color}${n.accent.toUpperCase()}${K.reset}${s} ${o} ${K.dim}${this.text}${K.reset}${r}`),this.frame++}start(){this._stopped=!1,this.startTime=Date.now(),process.stderr.isTTY&&(process.stderr.write("\x1B[?25l"),this._render(),this.interval=setInterval(()=>this._render(),100))}update(e){this.text=e}stop(){this._stopped=!0,this.interval&&(clearInterval(this.interval),this.interval=null),process.stderr.isTTY&&process.stderr.write("\x1B[2K\r\x1B[?25h"),this.startTime=null}},Xl=class{constructor(e){this.labels=e,this.statuses=e.map(()=>"running"),this.frame=0,this.interval=null,this.startTime=null,this.lineCount=e.length}_formatElapsed(){if(!this.startTime)return"";let e=Math.floor((Date.now()-this.startTime)/1e3);if(e<1)return"";let n=Math.floor(e/60),o=e%60;return n>0?`${n}m ${String(o).padStart(2,"0")}s`:`${o}s`}_render(){if(this._stopped)return;let e=wo[this.frame%wo.length],n=`${K.cyan}\u25CC${K.reset}`,o=this._formatElapsed(),s=o?` ${K.dim}${o}${K.reset}`:"",r=process.stderr.columns||80,i="";for(let a=0;a<this.labels.length;a++){let l,c;switch(this.statuses[a]){case"done":l=`${K.green}\u2713${K.reset}`,c=K.dim;break;case"error":l=`${K.red}\u2717${K.reset}`,c=K.dim;break;case"retry":l=`${K.yellow}\u21BB${K.reset}`,c=K.yellow;break;default:l=a===e?n:`${K.dim}\xB7${K.reset}`,c=""}let u=a===this.labels.length-1?s:"",d=r-4-(u?o.length+1:0),f=this.labels[a].length>d?this.labels[a].substring(0,Math.max(10,d-3))+"...":this.labels[a];i+=`\x1B[2K ${l} ${c}${f}${K.reset}${u}
2
+ `),s=t("python3",["-c",e],{encoding:"buffer",timeout:400,stdio:["ignore","pipe","ignore"]}).toString("utf8").match(/rgb:([0-9a-fA-F]+)\/([0-9a-fA-F]+)\/([0-9a-fA-F]+)/);if(s){let r=parseInt(s[1].slice(0,2),16),i=parseInt(s[2].slice(0,2),16),a=parseInt(s[3].slice(0,2),16);return .299*r+.587*i+.114*a<128}}catch{}return null}function Af(){let t=require("os");return require("path").join(t.homedir(),".nex-code",".theme_cache.json")}function R_(t){try{let n=require("fs").readFileSync(Af(),"utf8"),o=JSON.parse(n);if(o&&typeof o[t]=="boolean")return o[t]}catch(e){console.error("readThemeCache failed:",e.message)}return null}function C_(t,e){try{let n=require("fs"),o=require("path"),s=Af(),r=o.dirname(s),i={};try{i=JSON.parse(n.readFileSync(s,"utf8"))}catch(l){console.error("theme cache failed:",l.message)}i[t]=e;let a=Object.keys(i);a.length>50&&a.slice(0,a.length-50).forEach(l=>delete i[l]),n.existsSync(r)||n.mkdirSync(r,{recursive:!0}),n.writeFileSync(s,JSON.stringify(i),"utf8")}catch{}}function A_(){let t=(process.env.NEX_THEME||"").toLowerCase();if(t==="light")return!1;if(t==="dark")return!0;let e=process.env.COLORFGBG;if(e){let i=e.split(";"),a=parseInt(i[i.length-1],10);if(!isNaN(a))return a<8}let n=process.env.TERM_SESSION_ID||"default",o=R_(n);if(o!==null)return o;let s=T_(),r=s!==null?s:!0;return C_(n,r),r}var Of=A_(),Pf={reset:Rf,bold:Cf,dim:bo,primary:z(80,190,255),secondary:z(60,170,190),success:z(80,210,120),warning:z(245,175,50),error:z(230,80,80),muted:bo,subtle:z(130,130,145),tool_read:z(80,190,255),tool_write:z(245,165,55),tool_exec:z(185,100,235),tool_search:z(70,185,190),tool_git:z(90,210,100),tool_web:z(100,215,250),tool_sysadmin:z(225,150,75),tool_default:z(100,205,115),syn_keyword:z(185,100,235),syn_string:z(90,210,120),syn_number:z(245,175,50),syn_comment:bo,syn_key:z(80,190,255),diff_add:z(80,210,120),diff_rem:z(230,80,80),banner_logo:z(80,200,255),banner_name:z(80,200,255),banner_version:bo,banner_model:bo,banner_yolo:z(245,175,50),banner_gemini:z(138,180,248),footer_sep:bo,footer_model:z(80,175,235),footer_branch:z(80,210,100),footer_project:z(130,130,145),footer_divider:z(80,80,95),footer_mode:z(210,150,50),white:z(210,210,220),red:z(220,85,85),green:z(80,200,110),yellow:z(230,185,60),blue:z(70,140,230),magenta:z(200,120,190),cyan:z(90,200,215),gray:z(120,120,135),bgRed:"\x1B[48;2;140;40;40m",bgGreen:"\x1B[48;2;30;100;50m",diff_add_bg:"\x1B[48;2;10;46;20m",diff_rem_bg:"\x1B[48;2;58;16;16m",brightCyan:z(110,215,230),brightMagenta:z(220,140,210),brightBlue:z(100,160,240)},Nf={reset:Rf,bold:Cf,dim:z(110,110,120),primary:z(0,110,190),secondary:z(0,125,148),success:z(0,148,62),warning:z(168,92,0),error:z(188,32,32),muted:z(110,110,120),subtle:z(155,155,165),tool_read:z(0,110,190),tool_write:z(168,92,0),tool_exec:z(128,42,188),tool_search:z(0,122,148),tool_git:z(0,138,62),tool_web:z(0,112,178),tool_sysadmin:z(168,82,0),tool_default:z(0,138,62),syn_keyword:z(128,42,188),syn_string:z(0,138,62),syn_number:z(168,92,0),syn_comment:z(135,135,148),syn_key:z(0,110,190),diff_add:z(0,148,62),diff_rem:z(188,32,32),banner_logo:z(0,122,205),banner_name:z(0,122,205),banner_version:z(100,100,118),banner_model:z(100,100,118),banner_yolo:z(168,62,0),banner_gemini:z(26,115,232),footer_sep:z(168,168,178),footer_model:z(0,102,175),footer_branch:z(0,138,62),footer_project:z(135,135,148),footer_divider:z(168,168,178),footer_mode:z(148,88,0),white:z(40,40,52),red:z(188,32,32),green:z(0,148,62),yellow:z(168,92,0),blue:z(0,110,190),magenta:z(128,42,188),cyan:z(0,125,148),gray:z(132,132,142),bgRed:"\x1B[48;2;180;50;50m",bgGreen:"\x1B[48;2;30;130;60m",diff_add_bg:"\x1B[48;2;215;245;220m",diff_rem_bg:"\x1B[48;2;255;215;215m",brightCyan:z(0,158,182),brightMagenta:z(158,52,208),brightBlue:z(0,112,208)},O_=Of?Pf:Nf;Mf.exports={T:O_,isDark:Of,DARK:Pf,LIGHT:Nf}});var Ai=Z((CP,P_)=>{P_.exports={name:"nex-code",version:"0.5.21",description:"Run 400B+ open coding models on your codebase without the hardware bill. Ollama Cloud first \u2014 OpenAI, Anthropic, and Gemini when you need them.",bin:{"nex-code":"./dist/nex-code.js"},files:["dist/","examples/","README.md","LICENSE"],engines:{node:">=18.0.0"},scripts:{start:"node dist/nex-code.js",build:"node scripts/build.js",dev:"node scripts/build.js --dev",test:"jest --runInBand","test:orchestrator":"jest tests/orchestrator.test.js --forceExit",coverage:"jest --coverage --forceExit","test:watch":"jest --watch",typecheck:"tsc --noEmit",format:"prettier --write .","scan:secrets":"node scripts/secret-scan.js --staged","install-hooks":"ln -sf ../../hooks/pre-commit .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit && ln -sf ../../hooks/pre-push .git/hooks/pre-push && chmod +x .git/hooks/pre-push && ln -sf ../../hooks/post-merge .git/hooks/post-merge && chmod +x .git/hooks/post-merge && echo 'Hooks installed (pre-commit, pre-push, post-merge).'",prepublishOnly:"npm run build && npm test","merge-to-main":"bash scripts/merge-to-main.sh",improve:"node scripts/improve.js","extract-examples":"node scripts/extract-examples.js","benchmark:realworld":"node scripts/benchmark-realworld.js","benchmark:reallife":"node scripts/benchmark-reallife.js","benchmark:report":"node scripts/benchmark-reallife-report.js","improve:reallife":"node scripts/improve-reallife.js","benchmark:gate":"node scripts/benchmark-gate.js",release:"bash scripts/release.sh"},keywords:["ai","cli","coding","agent","ollama","ollama-cloud","openai","anthropic","gemini","llm","gpt","agentic","terminal","coding-assistant","open-source","free","qwen3","devstral","kimi-k2","deepseek","local-llm","mcp","model-context-protocol","multi-provider"],repository:{type:"git",url:"https://github.com/hybridpicker/nex-code.git"},bugs:{url:"https://github.com/hybridpicker/nex-code/issues"},homepage:"https://github.com/hybridpicker/nex-code#readme",license:"MIT",dependencies:{axios:"^1.15.0",dotenv:"^16.4.0",pixelmatch:"^7.1.0",pngjs:"^7.0.0"},devDependencies:{esbuild:"^0.27.3",jest:"^29.7.0",prettier:"^3.8.1",typescript:"^5.9.3"},overrides:{"brace-expansion":">=5.0.5",picomatch:">=4.0.4"},jest:{coverageThreshold:{global:{lines:45,functions:30,branches:35},"./cli/sub-agent.js":{lines:70,functions:60,branches:55}}}}});var ks=Z((AP,Ff)=>{var{T:K}=hn(),Kl=5,wo=(()=>{let t=[];for(let e=0;e<Kl;e++)t.push(e);for(let e=Kl-2;e>=1;e--)t.push(e);return t})(),Lf=["\u273D","\u2726","\u2727","\u2726"],If=["\xB7 ","\xB7\xB7 ","\xB7\xB7\xB7"," \xB7\xB7"];function jf(t=""){let e=String(t).toLowerCase();return e.includes("search")||e.includes("read")||e.includes("list")||e.includes("inspect")?{glyph:"\u25CC",color:K.cyan,accent:"scan"}:e.includes("write")||e.includes("edit")||e.includes("patch")||e.includes("build")?{glyph:"\u2726",color:K.yellow,accent:"shape"}:e.includes("test")||e.includes("diff")||e.includes("check")||e.includes("verify")?{glyph:"\u25A3",color:K.green,accent:"verify"}:e.includes("wait")||e.includes("github")||e.includes("fetch")||e.includes("browser")?{glyph:"\u25CD",color:K.blue,accent:"wait"}:{glyph:"\u25CF",color:K.cyan,accent:"think"}}function Df(t,e,n){let o="";for(let s=0;s<Kl;s++)s===t?o+=`${n}${e}${K.reset}`:s===t-1||s===t+1?o+=`${K.dim}\xB7${K.reset}`:o+=`${K.dim}\xB7${K.reset}`;return o}function qf(t){return`${K.dim}${If[t%If.length]}${K.reset}`}var Vl=class{constructor(e="Thinking..."){this.text=e,this.frame=0,this.interval=null,this.startTime=null}_render(){if(this._stopped)return;let e=wo[this.frame%wo.length],n=jf(this.text),o=Df(e,n.glyph,n.color),s=qf(this.frame),r="";if(this.startTime){let i=Math.floor((Date.now()-this.startTime)/1e3);if(i>=60){let a=Math.floor(i/60),l=i%60;r=` ${K.dim}${a}m ${String(l).padStart(2,"0")}s${K.reset}`}else i>=1&&(r=` ${K.dim}${i}s${K.reset}`)}process.stderr.write(`\x1B[2K\r${n.color}${n.accent.toUpperCase()}${K.reset}${s} ${o} ${K.dim}${this.text}${K.reset}${r}`),this.frame++}start(){this._stopped=!1,this.startTime=Date.now(),process.stderr.isTTY&&(process.stderr.write("\x1B[?25l"),this._render(),this.interval=setInterval(()=>this._render(),100))}update(e){this.text=e}stop(){this._stopped=!0,this.interval&&(clearInterval(this.interval),this.interval=null),process.stderr.isTTY&&process.stderr.write("\x1B[2K\r\x1B[?25h"),this.startTime=null}},Xl=class{constructor(e){this.labels=e,this.statuses=e.map(()=>"running"),this.frame=0,this.interval=null,this.startTime=null,this.lineCount=e.length}_formatElapsed(){if(!this.startTime)return"";let e=Math.floor((Date.now()-this.startTime)/1e3);if(e<1)return"";let n=Math.floor(e/60),o=e%60;return n>0?`${n}m ${String(o).padStart(2,"0")}s`:`${o}s`}_render(){if(this._stopped)return;let e=wo[this.frame%wo.length],n=`${K.cyan}\u25CC${K.reset}`,o=this._formatElapsed(),s=o?` ${K.dim}${o}${K.reset}`:"",r=process.stderr.columns||80,i="";for(let a=0;a<this.labels.length;a++){let l,c;switch(this.statuses[a]){case"done":l=`${K.green}\u2713${K.reset}`,c=K.dim;break;case"error":l=`${K.red}\u2717${K.reset}`,c=K.dim;break;case"retry":l=`${K.yellow}\u21BB${K.reset}`,c=K.yellow;break;default:l=a===e?n:`${K.dim}\xB7${K.reset}`,c=""}let u=a===this.labels.length-1?s:"",d=r-4-(u?o.length+1:0),f=this.labels[a].length>d?this.labels[a].substring(0,Math.max(10,d-3))+"...":this.labels[a];i+=`\x1B[2K ${l} ${c}${f}${K.reset}${u}
3
3
  `}this.lineCount>0&&(i+=`\x1B[${this.lineCount}A`),process.stderr.write(i),this.frame++}start(){this._stopped=!1,this.startTime=Date.now();let e="\x1B[?25l";for(let n=0;n<this.lineCount;n++)e+=`
4
4
  `;this.lineCount>0&&(e+=`\x1B[${this.lineCount}A`),process.stderr.write(e),this._render(),this.interval=setInterval(()=>this._render(),100)}update(e,n){e>=0&&e<this.statuses.length&&(this.statuses[e]=n)}stop(e={}){if(this._stopped=!0,this.interval&&(clearInterval(this.interval),this.interval=null),!e.silent)this._renderFinal();else{let n="";for(let o=0;o<this.lineCount;o++)n+=`\x1B[2K
5
5
  `;this.lineCount>0&&(n+=`\x1B[${this.lineCount}A`),process.stderr.write(n)}process.stderr.write("\x1B[?25h")}_renderFinal(){let e=this._formatElapsed(),n=e?` ${K.dim}${e}${K.reset}`:"",o=process.stderr.columns||80,s="";for(let r=0;r<this.labels.length;r++){let i;switch(this.statuses[r]){case"done":i=`${K.green}\u2713${K.reset}`;break;case"error":i=`${K.red}\u2717${K.reset}`;break;case"retry":i=`${K.yellow}\u21BB${K.reset}`;break;default:i=`${K.yellow}\u25CB${K.reset}`}let a=r===this.labels.length-1?n:"",l=o-4-(a?e.length+1:0),c=this.labels[r].length>l?this.labels[r].substring(0,Math.max(10,l-3))+"...":this.labels[r];s+=`\x1B[2K ${i} ${K.dim}${c}${K.reset}${a}
@@ -982,7 +982,7 @@ end try`],{timeout:3e3});if(o.stdout&&o.stdout.toString().trim()==="has_image"){
982
982
  [SYSTEM: Output repetition detected \u2014 response truncated (${s}\xD7 repeated paragraph)]`,a;if(t.length>8e3)a=t.slice(0,3e3)+i;else{let l=0,c=-1,u=0;for(;l<2;){let d=t.indexOf(r,u);if(d===-1)break;l++,c=d+r.length,u=d+1}a=c>0?t.slice(0,c)+i:t.slice(0,3e3)+i}return{text:a,truncated:!0,repeatCount:s}}function Cd(t,e=5){if(!t||t.length<40)return{text:t,truncated:!1,repeatCount:0};let n=t.split(`
983
983
  `),o=new Map;for(let p of n){let m=p.trim();m.length>=20&&o.set(m,(o.get(m)||0)+1)}let s=0,r="";for(let[p,m]of o)m>s&&(s=m,r=p);let a=r.toLowerCase().includes("read_file")||r.toLowerCase().includes("reading")?2:e;if(s<=a)return{text:t,truncated:!1,repeatCount:s};let l=`
984
984
 
985
- \u26A0 [Response truncated: repeated paragraph detected (${s}\xD7)]`,c=0,u=-1,d=0;for(;c<e;){let p=t.indexOf(r,d);if(p===-1)break;c++,u=p+r.length,d=p+1}return{text:u>0?t.slice(0,u)+l:t.slice(0,2e3)+l,truncated:!0,repeatCount:s}}var yd=null,bd=null,wd=null;function Ut(){if(yd===null){let{TOOL_DEFINITIONS:t}=So();yd=t}return bd===null&&(bd=xA()),wd===null&&(wd=$A()),[...yd,...bd,...wd]}var Ad=50;function DA(t){Number.isFinite(t)&&t>0&&(Ad=t)}function _d(t=jn()){if(process.env.NEX_DISABLE_TOOL_BUDGET==="1")return 1/0;let e=process.env.NEX_MAX_TOOL_CALLS;if(e){let n=parseInt(e,10);if(Number.isFinite(n)&&n>0)return n}return t==="local"?5:30}function zw(t,e){return`[SYSTEM STOP] Tool-call budget reached (${t}/${e}). You MUST stop calling tools now. Provide your final answer based only on the information already in the conversation. If the task cannot be completed from the gathered evidence, state the blocker plainly and do not invent facts.`}var al=()=>null;function qA(t){al=t}var ei=null,Od=null,zo=null,Ko="",Vo=0,Pd="",Nd=0,ll=new Map,FA=1e4,BA=6e3,UA=/\b((?:API|ACCESS|AUTH|BEARER|CLIENT|GITHUB|GITLAB|SLACK|STRIPE|TWILIO|SENDGRID|AWS|GCP|AZURE|OPENAI|ANTHROPIC|GEMINI|OLLAMA)[_A-Z0-9]*(?:KEY|TOKEN|SECRET|PASS(?:WORD)?|CREDENTIAL)[_A-Z0-9]*)\s*=\s*["']?([A-Za-z0-9\-_.+/=]{10,})["']?/g;function WA(t){return!t||typeof t!="string"?t:t.replace(UA,(e,n)=>`${n}=***REDACTED***`)}var HA=7e3,GA=4e3;function YA(t,e=null){let n=WA(t),o=zC(n),s=e==="read_file"?HA:FA,r=e==="read_file"?GA:BA;if(o>s)try{let{compressToolResult:i}=Nn();return i(n,r)}catch{return n}return n}function c0(t){try{let{getActiveModel:e}=$t(),n=e(),o=n?`${n.provider}:${n.id}`:"default";if(ll.has(o))return ll.get(o);let s=Ww(t);return ll.set(o,s),s}catch{return Ww(t)}}function zA(){ll.clear()}function KA(t,e){let n=new Set(e);return(t||[]).some(o=>o.role!=="assistant"?!1:Array.isArray(o.tool_calls)?o.tool_calls.some(s=>n.has(s?.function?.name||s?.name)):Array.isArray(o.content)?o.content.some(s=>s?.type==="tool_use"&&n.has(s?.name)):!1)}var ti={hash:null,ts:0},VA=3e4;async function u0(){if(ti.hash&&Date.now()-ti.ts<VA)return ti.hash;try{let t=require("fs").promises,e=require("path"),n=[e.join(process.cwd(),"package.json"),e.join(process.cwd(),".git","HEAD"),e.join(process.cwd(),"README.md"),e.join(process.cwd(),"NEX.md")],s=(await Promise.allSettled(n.map(i=>t.stat(i).then(a=>`${i}:${a.mtimeMs}`)))).filter(i=>i.status==="fulfilled").map(i=>i.value);try{let{getMemoryContextHash:i}=Pr(),a=i();a&&s.push(`memory:${a}`)}catch{}try{let i=e.join(process.cwd(),".nex","brain");if(nt.existsSync(i)){let a=await t.stat(i);s.push(`brain:${a.mtimeMs}`)}}catch{}let r=s.join("|");return ti={hash:r,ts:Date.now()},r}catch{return`fallback:${Date.now()}`}}function Md(){ei=null,Od=null,ti={hash:null,ts:0},zo=null}var XA=new Set(["spawn_agents"]),$d=10,kd=10,ol=5,Kw=6e4,xd=12e4,JA=process.env.NEX_STALE_AUTO_SWITCH!=="0";function ZA(t){try{let e=require("fs"),n=require("path"),o=n.join(process.cwd(),".nex","plans");e.existsSync(o)||e.mkdirSync(o,{recursive:!0});let s=n.join(o,"current-plan.md");e.writeFileSync(s,t,"utf-8")}catch{}}fA(t=>{uA(t,"allow"),dA(),console.log(`${h.green} \u2713 ${t}: always allow${h.reset}`)});async function QA(t){let e=t.function.name,n=e;if(typeof e=="string"&&e.includes(".")){let d=e.split(".").pop(),f={exec:"bash",find:"search_files",search:"search_files",grep_search:"grep",read:"read_file"};Ut().some(m=>m.function.name===d)?n=d:f[d]&&(n=f[d])}let o=HC(t.function.arguments),s=t.id||`cli-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;if(!o){let f=Ut().find(m=>m.function.name===n),p=f?JSON.stringify(f.function.parameters,null,2):"unknown";return P(`${h.yellow} \u26A0 ${n}: malformed arguments, sending schema hint${h.reset}`),{callId:s,fnName:n,args:null,canExecute:!1,errorResult:{role:"tool",content:`ERROR: Malformed tool arguments. Could not parse your arguments as JSON.
985
+ \u26A0 [Response truncated: repeated paragraph detected (${s}\xD7)]`,c=0,u=-1,d=0;for(;c<e;){let p=t.indexOf(r,d);if(p===-1)break;c++,u=p+r.length,d=p+1}return{text:u>0?t.slice(0,u)+l:t.slice(0,2e3)+l,truncated:!0,repeatCount:s}}var yd=null,bd=null,wd=null;function Ut(){if(yd===null){let{TOOL_DEFINITIONS:t}=So();yd=t}return bd===null&&(bd=xA()),wd===null&&(wd=$A()),[...yd,...bd,...wd]}var Ad=50;function DA(t){Number.isFinite(t)&&t>0&&(Ad=t)}function _d(t=jn()){if(process.env.NEX_DISABLE_TOOL_BUDGET==="1")return 1/0;let e=process.env.NEX_MAX_TOOL_CALLS;if(e){let n=parseInt(e,10);if(Number.isFinite(n)&&n>0)return n}return t==="local"?5:30}function zw(t,e){return`[SYSTEM STOP] Tool-call budget reached (${t}/${e}). You MUST stop calling tools now. Provide your final answer based only on the information already in the conversation. If the task cannot be completed from the gathered evidence, state the blocker plainly and do not invent facts.`}var al=()=>null;function qA(t){al=t}var ei=null,Od=null,zo=null,Ko="",Vo=0,Pd="",Nd=0,ll=new Map,FA=1e4,BA=6e3,UA=/\b((?:API|ACCESS|AUTH|BEARER|CLIENT|GITHUB|GITLAB|SLACK|STRIPE|TWILIO|SENDGRID|AWS|GCP|AZURE|OPENAI|ANTHROPIC|GEMINI|OLLAMA)[_A-Z0-9]*(?:KEY|TOKEN|SECRET|PASS(?:WORD)?|CREDENTIAL)[_A-Z0-9]*)\s*=\s*["']?([A-Za-z0-9\-_.+/=]{10,})["']?/g;function WA(t){return!t||typeof t!="string"?t:t.replace(UA,(e,n)=>`${n}=***REDACTED***`)}var HA=7e3,GA=4e3;function YA(t,e=null){let n=WA(t),o=zC(n),s=e==="read_file"?HA:FA,r=e==="read_file"?GA:BA;if(o>s)try{let{compressToolResult:i}=Nn();return i(n,r)}catch{return n}return n}function c0(t){try{let{getActiveModel:e}=$t(),n=e(),o=n?`${n.provider}:${n.id}`:"default";if(ll.has(o))return ll.get(o);let s=Ww(t);return ll.set(o,s),s}catch{return Ww(t)}}function zA(){ll.clear()}function KA(t,e){let n=new Set(e);return(t||[]).some(o=>o.role!=="assistant"?!1:Array.isArray(o.tool_calls)?o.tool_calls.some(s=>n.has(s?.function?.name||s?.name)):Array.isArray(o.content)?o.content.some(s=>s?.type==="tool_use"&&n.has(s?.name)):!1)}var ti={hash:null,ts:0},VA=3e4;async function u0(){if(ti.hash&&Date.now()-ti.ts<VA)return ti.hash;try{let t=require("fs").promises,e=require("path"),n=[e.join(process.cwd(),"package.json"),e.join(process.cwd(),".git","HEAD"),e.join(process.cwd(),"README.md"),e.join(process.cwd(),"NEX.md")],s=(await Promise.allSettled(n.map(i=>t.stat(i).then(a=>`${i}:${a.mtimeMs}`)))).filter(i=>i.status==="fulfilled").map(i=>i.value);try{let{getMemoryContextHash:i}=Pr(),a=i();a&&s.push(`memory:${a}`)}catch{}try{let i=e.join(process.cwd(),".nex","brain");if(nt.existsSync(i)){let a=await t.stat(i);s.push(`brain:${a.mtimeMs}`)}}catch{}let r=s.join("|");return ti={hash:r,ts:Date.now()},r}catch{return`fallback:${Date.now()}`}}function Md(){ei=null,Od=null,ti={hash:null,ts:0},zo=null}var XA=new Set(["spawn_agents"]),$d=10,kd=10,ol=5,Kw=6e4,xd=12e4,JA=process.env.NEX_STALE_AUTO_SWITCH!=="0";function ZA(t){try{let e=require("fs"),n=require("path"),o=n.join(process.cwd(),".nex","plans");e.existsSync(o)||e.mkdirSync(o,{recursive:!0});let s=n.join(o,"current-plan.md");e.writeFileSync(s,t,"utf-8")}catch{}}fA(t=>{uA(t,"allow"),dA(),console.log(`${h.green} \u2713 ${t}: always allow${h.reset}`)});async function QA(t){let e=t.function.name,n=e;if(typeof e=="string"&&e.includes(".")){let d=e.split(".").pop(),f={exec:"bash",find:"search_files",search:"search_files",grep_search:"grep",list:"list_directory",print_tree:"list_directory",read:"read_file",tree:"list_directory"};Ut().some(m=>m.function.name===d)?n=d:f[d]&&(n=f[d])}let o=HC(t.function.arguments),s=t.id||`cli-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;if(!o){let f=Ut().find(m=>m.function.name===n),p=f?JSON.stringify(f.function.parameters,null,2):"unknown";return P(`${h.yellow} \u26A0 ${n}: malformed arguments, sending schema hint${h.reset}`),{callId:s,fnName:n,args:null,canExecute:!1,errorResult:{role:"tool",content:`ERROR: Malformed tool arguments. Could not parse your arguments as JSON.
986
986
  Raw input: ${typeof t.function.arguments=="string"?t.function.arguments.substring(0,200):"N/A"}
987
987
 
988
988
  Expected JSON schema for "${n}":
package/dist/nex-code.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- var Au=Object.defineProperty;var lv=Object.getOwnPropertyDescriptor;var uv=Object.getOwnPropertyNames;var dv=Object.prototype.hasOwnProperty;var fv=(e,t)=>()=>(e&&(t=e(e=0)),t);var Z=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),pv=(e,t)=>{for(var n in t)Au(e,n,{get:t[n],enumerable:!0})},hv=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of uv(t))!dv.call(e,s)&&s!==n&&Au(e,s,{get:()=>t[s],enumerable:!(o=lv(t,s))||o.enumerable});return e};var mv=e=>hv(Au({},"__esModule",{value:!0}),e);var gr=Z((zj,gv)=>{gv.exports={name:"nex-code",version:"0.5.20",description:"Run 400B+ open coding models on your codebase without the hardware bill. Ollama Cloud first \u2014 OpenAI, Anthropic, and Gemini when you need them.",bin:{"nex-code":"./dist/nex-code.js"},files:["dist/","examples/","README.md","LICENSE"],engines:{node:">=18.0.0"},scripts:{start:"node dist/nex-code.js",build:"node scripts/build.js",dev:"node scripts/build.js --dev",test:"jest --runInBand","test:orchestrator":"jest tests/orchestrator.test.js --forceExit",coverage:"jest --coverage --forceExit","test:watch":"jest --watch",typecheck:"tsc --noEmit",format:"prettier --write .","scan:secrets":"node scripts/secret-scan.js --staged","install-hooks":"ln -sf ../../hooks/pre-commit .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit && ln -sf ../../hooks/pre-push .git/hooks/pre-push && chmod +x .git/hooks/pre-push && ln -sf ../../hooks/post-merge .git/hooks/post-merge && chmod +x .git/hooks/post-merge && echo 'Hooks installed (pre-commit, pre-push, post-merge).'",prepublishOnly:"npm run build && npm test","merge-to-main":"bash scripts/merge-to-main.sh",improve:"node scripts/improve.js","extract-examples":"node scripts/extract-examples.js","benchmark:realworld":"node scripts/benchmark-realworld.js","benchmark:reallife":"node scripts/benchmark-reallife.js","benchmark:report":"node scripts/benchmark-reallife-report.js","improve:reallife":"node scripts/improve-reallife.js","benchmark:gate":"node scripts/benchmark-gate.js",release:"bash scripts/release.sh"},keywords:["ai","cli","coding","agent","ollama","ollama-cloud","openai","anthropic","gemini","llm","gpt","agentic","terminal","coding-assistant","open-source","free","qwen3","devstral","kimi-k2","deepseek","local-llm","mcp","model-context-protocol","multi-provider"],repository:{type:"git",url:"https://github.com/hybridpicker/nex-code.git"},bugs:{url:"https://github.com/hybridpicker/nex-code/issues"},homepage:"https://github.com/hybridpicker/nex-code#readme",license:"MIT",dependencies:{axios:"^1.15.0",dotenv:"^16.4.0",pixelmatch:"^7.1.0",pngjs:"^7.0.0"},devDependencies:{esbuild:"^0.27.3",jest:"^29.7.0",prettier:"^3.8.1",typescript:"^5.9.3"},overrides:{"brace-expansion":">=5.0.5",picomatch:">=4.0.4"},jest:{coverageThreshold:{global:{lines:45,functions:30,branches:35},"./cli/sub-agent.js":{lines:70,functions:60,branches:55}}}}});var Qt=Z((Kj,Kh)=>{"use strict";var Uh="\x1B[0m",Wh="\x1B[1m",yr="\x1B[2m";function se(e,t,n){return`\x1B[38;2;${e};${t};${n}m`}function yv(){if(!process.stdout.isTTY)return null;try{let{execFileSync:e}=require("child_process"),t=["import sys,os,tty,termios,select","f=open('/dev/tty','r+b',buffering=0)","fd=f.fileno()","s=termios.tcgetattr(fd)","try:"," tty.setraw(fd)"," f.write(bytes([0x1b,0x5d,0x31,0x31,0x3b,0x3f,0x1b,0x5c]))"," r=select.select([fd],[],[],0.1)[0]"," d=b''"," if r:"," while True:"," r2=select.select([fd],[],[],0.05)[0]"," if not r2:break"," c=os.read(fd,1)"," d+=c"," if d[-1:]==bytes([0x07]) or d[-2:]==bytes([0x1b,0x5c]):break"," sys.stdout.buffer.write(d)","finally:"," termios.tcsetattr(fd,termios.TCSADRAIN,s)"," f.close()"].join(`
2
+ var Au=Object.defineProperty;var lv=Object.getOwnPropertyDescriptor;var uv=Object.getOwnPropertyNames;var dv=Object.prototype.hasOwnProperty;var fv=(e,t)=>()=>(e&&(t=e(e=0)),t);var Z=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),pv=(e,t)=>{for(var n in t)Au(e,n,{get:t[n],enumerable:!0})},hv=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of uv(t))!dv.call(e,s)&&s!==n&&Au(e,s,{get:()=>t[s],enumerable:!(o=lv(t,s))||o.enumerable});return e};var mv=e=>hv(Au({},"__esModule",{value:!0}),e);var gr=Z((zj,gv)=>{gv.exports={name:"nex-code",version:"0.5.21",description:"Run 400B+ open coding models on your codebase without the hardware bill. Ollama Cloud first \u2014 OpenAI, Anthropic, and Gemini when you need them.",bin:{"nex-code":"./dist/nex-code.js"},files:["dist/","examples/","README.md","LICENSE"],engines:{node:">=18.0.0"},scripts:{start:"node dist/nex-code.js",build:"node scripts/build.js",dev:"node scripts/build.js --dev",test:"jest --runInBand","test:orchestrator":"jest tests/orchestrator.test.js --forceExit",coverage:"jest --coverage --forceExit","test:watch":"jest --watch",typecheck:"tsc --noEmit",format:"prettier --write .","scan:secrets":"node scripts/secret-scan.js --staged","install-hooks":"ln -sf ../../hooks/pre-commit .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit && ln -sf ../../hooks/pre-push .git/hooks/pre-push && chmod +x .git/hooks/pre-push && ln -sf ../../hooks/post-merge .git/hooks/post-merge && chmod +x .git/hooks/post-merge && echo 'Hooks installed (pre-commit, pre-push, post-merge).'",prepublishOnly:"npm run build && npm test","merge-to-main":"bash scripts/merge-to-main.sh",improve:"node scripts/improve.js","extract-examples":"node scripts/extract-examples.js","benchmark:realworld":"node scripts/benchmark-realworld.js","benchmark:reallife":"node scripts/benchmark-reallife.js","benchmark:report":"node scripts/benchmark-reallife-report.js","improve:reallife":"node scripts/improve-reallife.js","benchmark:gate":"node scripts/benchmark-gate.js",release:"bash scripts/release.sh"},keywords:["ai","cli","coding","agent","ollama","ollama-cloud","openai","anthropic","gemini","llm","gpt","agentic","terminal","coding-assistant","open-source","free","qwen3","devstral","kimi-k2","deepseek","local-llm","mcp","model-context-protocol","multi-provider"],repository:{type:"git",url:"https://github.com/hybridpicker/nex-code.git"},bugs:{url:"https://github.com/hybridpicker/nex-code/issues"},homepage:"https://github.com/hybridpicker/nex-code#readme",license:"MIT",dependencies:{axios:"^1.15.0",dotenv:"^16.4.0",pixelmatch:"^7.1.0",pngjs:"^7.0.0"},devDependencies:{esbuild:"^0.27.3",jest:"^29.7.0",prettier:"^3.8.1",typescript:"^5.9.3"},overrides:{"brace-expansion":">=5.0.5",picomatch:">=4.0.4"},jest:{coverageThreshold:{global:{lines:45,functions:30,branches:35},"./cli/sub-agent.js":{lines:70,functions:60,branches:55}}}}});var Qt=Z((Kj,Kh)=>{"use strict";var Uh="\x1B[0m",Wh="\x1B[1m",yr="\x1B[2m";function se(e,t,n){return`\x1B[38;2;${e};${t};${n}m`}function yv(){if(!process.stdout.isTTY)return null;try{let{execFileSync:e}=require("child_process"),t=["import sys,os,tty,termios,select","f=open('/dev/tty','r+b',buffering=0)","fd=f.fileno()","s=termios.tcgetattr(fd)","try:"," tty.setraw(fd)"," f.write(bytes([0x1b,0x5d,0x31,0x31,0x3b,0x3f,0x1b,0x5c]))"," r=select.select([fd],[],[],0.1)[0]"," d=b''"," if r:"," while True:"," r2=select.select([fd],[],[],0.05)[0]"," if not r2:break"," c=os.read(fd,1)"," d+=c"," if d[-1:]==bytes([0x07]) or d[-2:]==bytes([0x1b,0x5c]):break"," sys.stdout.buffer.write(d)","finally:"," termios.tcsetattr(fd,termios.TCSADRAIN,s)"," f.close()"].join(`
3
3
  `),s=e("python3",["-c",t],{encoding:"buffer",timeout:400,stdio:["ignore","pipe","ignore"]}).toString("utf8").match(/rgb:([0-9a-fA-F]+)\/([0-9a-fA-F]+)\/([0-9a-fA-F]+)/);if(s){let r=parseInt(s[1].slice(0,2),16),i=parseInt(s[2].slice(0,2),16),a=parseInt(s[3].slice(0,2),16);return .299*r+.587*i+.114*a<128}}catch{}return null}function Hh(){let e=require("os");return require("path").join(e.homedir(),".nex-code",".theme_cache.json")}function $v(e){try{let n=require("fs").readFileSync(Hh(),"utf8"),o=JSON.parse(n);if(o&&typeof o[e]=="boolean")return o[e]}catch(t){console.error("readThemeCache failed:",t.message)}return null}function bv(e,t){try{let n=require("fs"),o=require("path"),s=Hh(),r=o.dirname(s),i={};try{i=JSON.parse(n.readFileSync(s,"utf8"))}catch(c){console.error("theme cache failed:",c.message)}i[e]=t;let a=Object.keys(i);a.length>50&&a.slice(0,a.length-50).forEach(c=>delete i[c]),n.existsSync(r)||n.mkdirSync(r,{recursive:!0}),n.writeFileSync(s,JSON.stringify(i),"utf8")}catch{}}function wv(){let e=(process.env.NEX_THEME||"").toLowerCase();if(e==="light")return!1;if(e==="dark")return!0;let t=process.env.COLORFGBG;if(t){let i=t.split(";"),a=parseInt(i[i.length-1],10);if(!isNaN(a))return a<8}let n=process.env.TERM_SESSION_ID||"default",o=$v(n);if(o!==null)return o;let s=yv(),r=s!==null?s:!0;return bv(n,r),r}var Gh=wv(),Yh={reset:Uh,bold:Wh,dim:yr,primary:se(80,190,255),secondary:se(60,170,190),success:se(80,210,120),warning:se(245,175,50),error:se(230,80,80),muted:yr,subtle:se(130,130,145),tool_read:se(80,190,255),tool_write:se(245,165,55),tool_exec:se(185,100,235),tool_search:se(70,185,190),tool_git:se(90,210,100),tool_web:se(100,215,250),tool_sysadmin:se(225,150,75),tool_default:se(100,205,115),syn_keyword:se(185,100,235),syn_string:se(90,210,120),syn_number:se(245,175,50),syn_comment:yr,syn_key:se(80,190,255),diff_add:se(80,210,120),diff_rem:se(230,80,80),banner_logo:se(80,200,255),banner_name:se(80,200,255),banner_version:yr,banner_model:yr,banner_yolo:se(245,175,50),banner_gemini:se(138,180,248),footer_sep:yr,footer_model:se(80,175,235),footer_branch:se(80,210,100),footer_project:se(130,130,145),footer_divider:se(80,80,95),footer_mode:se(210,150,50),white:se(210,210,220),red:se(220,85,85),green:se(80,200,110),yellow:se(230,185,60),blue:se(70,140,230),magenta:se(200,120,190),cyan:se(90,200,215),gray:se(120,120,135),bgRed:"\x1B[48;2;140;40;40m",bgGreen:"\x1B[48;2;30;100;50m",diff_add_bg:"\x1B[48;2;10;46;20m",diff_rem_bg:"\x1B[48;2;58;16;16m",brightCyan:se(110,215,230),brightMagenta:se(220,140,210),brightBlue:se(100,160,240)},zh={reset:Uh,bold:Wh,dim:se(110,110,120),primary:se(0,110,190),secondary:se(0,125,148),success:se(0,148,62),warning:se(168,92,0),error:se(188,32,32),muted:se(110,110,120),subtle:se(155,155,165),tool_read:se(0,110,190),tool_write:se(168,92,0),tool_exec:se(128,42,188),tool_search:se(0,122,148),tool_git:se(0,138,62),tool_web:se(0,112,178),tool_sysadmin:se(168,82,0),tool_default:se(0,138,62),syn_keyword:se(128,42,188),syn_string:se(0,138,62),syn_number:se(168,92,0),syn_comment:se(135,135,148),syn_key:se(0,110,190),diff_add:se(0,148,62),diff_rem:se(188,32,32),banner_logo:se(0,122,205),banner_name:se(0,122,205),banner_version:se(100,100,118),banner_model:se(100,100,118),banner_yolo:se(168,62,0),banner_gemini:se(26,115,232),footer_sep:se(168,168,178),footer_model:se(0,102,175),footer_branch:se(0,138,62),footer_project:se(135,135,148),footer_divider:se(168,168,178),footer_mode:se(148,88,0),white:se(40,40,52),red:se(188,32,32),green:se(0,148,62),yellow:se(168,92,0),blue:se(0,110,190),magenta:se(128,42,188),cyan:se(0,125,148),gray:se(132,132,142),bgRed:"\x1B[48;2;180;50;50m",bgGreen:"\x1B[48;2;30;130;60m",diff_add_bg:"\x1B[48;2;215;245;220m",diff_rem_bg:"\x1B[48;2;255;215;215m",brightCyan:se(0,158,182),brightMagenta:se(158,52,208),brightBlue:se(0,112,208)},_v=Gh?Yh:zh;Kh.exports={T:_v,isDark:Gh,DARK:Yh,LIGHT:zh}});var xo=Z((Xj,em)=>{var{T:re}=Qt(),Ou=5,$r=(()=>{let e=[];for(let t=0;t<Ou;t++)e.push(t);for(let t=Ou-2;t>=1;t--)e.push(t);return e})(),Xh=["\u273D","\u2726","\u2727","\u2726"],Vh=["\xB7 ","\xB7\xB7 ","\xB7\xB7\xB7"," \xB7\xB7"];function Jh(e=""){let t=String(e).toLowerCase();return t.includes("search")||t.includes("read")||t.includes("list")||t.includes("inspect")?{glyph:"\u25CC",color:re.cyan,accent:"scan"}:t.includes("write")||t.includes("edit")||t.includes("patch")||t.includes("build")?{glyph:"\u2726",color:re.yellow,accent:"shape"}:t.includes("test")||t.includes("diff")||t.includes("check")||t.includes("verify")?{glyph:"\u25A3",color:re.green,accent:"verify"}:t.includes("wait")||t.includes("github")||t.includes("fetch")||t.includes("browser")?{glyph:"\u25CD",color:re.blue,accent:"wait"}:{glyph:"\u25CF",color:re.cyan,accent:"think"}}function Zh(e,t,n){let o="";for(let s=0;s<Ou;s++)s===e?o+=`${n}${t}${re.reset}`:s===e-1||s===e+1?o+=`${re.dim}\xB7${re.reset}`:o+=`${re.dim}\xB7${re.reset}`;return o}function Qh(e){return`${re.dim}${Vh[e%Vh.length]}${re.reset}`}var Mu=class{constructor(t="Thinking..."){this.text=t,this.frame=0,this.interval=null,this.startTime=null}_render(){if(this._stopped)return;let t=$r[this.frame%$r.length],n=Jh(this.text),o=Zh(t,n.glyph,n.color),s=Qh(this.frame),r="";if(this.startTime){let i=Math.floor((Date.now()-this.startTime)/1e3);if(i>=60){let a=Math.floor(i/60),c=i%60;r=` ${re.dim}${a}m ${String(c).padStart(2,"0")}s${re.reset}`}else i>=1&&(r=` ${re.dim}${i}s${re.reset}`)}process.stderr.write(`\x1B[2K\r${n.color}${n.accent.toUpperCase()}${re.reset}${s} ${o} ${re.dim}${this.text}${re.reset}${r}`),this.frame++}start(){this._stopped=!1,this.startTime=Date.now(),process.stderr.isTTY&&(process.stderr.write("\x1B[?25l"),this._render(),this.interval=setInterval(()=>this._render(),100))}update(t){this.text=t}stop(){this._stopped=!0,this.interval&&(clearInterval(this.interval),this.interval=null),process.stderr.isTTY&&process.stderr.write("\x1B[2K\r\x1B[?25h"),this.startTime=null}},Pu=class{constructor(t){this.labels=t,this.statuses=t.map(()=>"running"),this.frame=0,this.interval=null,this.startTime=null,this.lineCount=t.length}_formatElapsed(){if(!this.startTime)return"";let t=Math.floor((Date.now()-this.startTime)/1e3);if(t<1)return"";let n=Math.floor(t/60),o=t%60;return n>0?`${n}m ${String(o).padStart(2,"0")}s`:`${o}s`}_render(){if(this._stopped)return;let t=$r[this.frame%$r.length],n=`${re.cyan}\u25CC${re.reset}`,o=this._formatElapsed(),s=o?` ${re.dim}${o}${re.reset}`:"",r=process.stderr.columns||80,i="";for(let a=0;a<this.labels.length;a++){let c,u;switch(this.statuses[a]){case"done":c=`${re.green}\u2713${re.reset}`,u=re.dim;break;case"error":c=`${re.red}\u2717${re.reset}`,u=re.dim;break;case"retry":c=`${re.yellow}\u21BB${re.reset}`,u=re.yellow;break;default:c=a===t?n:`${re.dim}\xB7${re.reset}`,u=""}let d=a===this.labels.length-1?s:"",f=r-4-(d?o.length+1:0),p=this.labels[a].length>f?this.labels[a].substring(0,Math.max(10,f-3))+"...":this.labels[a];i+=`\x1B[2K ${c} ${u}${p}${re.reset}${d}
4
4
  `}this.lineCount>0&&(i+=`\x1B[${this.lineCount}A`),process.stderr.write(i),this.frame++}start(){this._stopped=!1,this.startTime=Date.now();let t="\x1B[?25l";for(let n=0;n<this.lineCount;n++)t+=`
5
5
  `;this.lineCount>0&&(t+=`\x1B[${this.lineCount}A`),process.stderr.write(t),this._render(),this.interval=setInterval(()=>this._render(),100)}update(t,n){t>=0&&t<this.statuses.length&&(this.statuses[t]=n)}stop(t={}){if(this._stopped=!0,this.interval&&(clearInterval(this.interval),this.interval=null),!t.silent)this._renderFinal();else{let n="";for(let o=0;o<this.lineCount;o++)n+=`\x1B[2K
@@ -983,7 +983,7 @@ end try`],{timeout:3e3});if(o.stdout&&o.stdout.toString().trim()==="has_image"){
983
983
  [SYSTEM: Output repetition detected \u2014 response truncated (${s}\xD7 repeated paragraph)]`,a;if(e.length>8e3)a=e.slice(0,3e3)+i;else{let c=0,u=-1,d=0;for(;c<2;){let f=e.indexOf(r,d);if(f===-1)break;c++,u=f+r.length,d=f+1}a=u>0?e.slice(0,u)+i:e.slice(0,3e3)+i}return{text:a,truncated:!0,repeatCount:s}}function lp(e,t=5){if(!e||e.length<40)return{text:e,truncated:!1,repeatCount:0};let n=e.split(`
984
984
  `),o=new Map;for(let h of n){let m=h.trim();m.length>=20&&o.set(m,(o.get(m)||0)+1)}let s=0,r="";for(let[h,m]of o)m>s&&(s=m,r=h);let a=r.toLowerCase().includes("read_file")||r.toLowerCase().includes("reading")?2:t;if(s<=a)return{text:e,truncated:!1,repeatCount:s};let c=`
985
985
 
986
- \u26A0 [Response truncated: repeated paragraph detected (${s}\xD7)]`,u=0,d=-1,f=0;for(;u<t;){let h=e.indexOf(r,f);if(h===-1)break;u++,d=h+r.length,f=h+1}return{text:d>0?e.slice(0,d)+c:e.slice(0,2e3)+c,truncated:!0,repeatCount:s}}var Jf=null,Zf=null,Qf=null;function gn(){if(Jf===null){let{TOOL_DEFINITIONS:e}=Kn();Jf=e}return Zf===null&&(Zf=fN()),Qf===null&&(Qf=uN()),[...Jf,...Zf,...Qf]}var up=50;function TN(e){Number.isFinite(e)&&e>0&&(up=e)}function ep(e=xs()){if(process.env.NEX_DISABLE_TOOL_BUDGET==="1")return 1/0;let t=process.env.NEX_MAX_TOOL_CALLS;if(t){let n=parseInt(t,10);if(Number.isFinite(n)&&n>0)return n}return e==="local"?5:30}function Q0(e,t){return`[SYSTEM STOP] Tool-call budget reached (${e}/${t}). You MUST stop calling tools now. Provide your final answer based only on the information already in the conversation. If the task cannot be completed from the gathered evidence, state the blocker plainly and do not invent facts.`}var El=()=>null;function RN(e){El=e}var ia=null,dp=null,Gr=null,Yr="",zr=0,fp="",pp=0,Tl=new Map,CN=1e4,AN=6e3,ON=/\b((?:API|ACCESS|AUTH|BEARER|CLIENT|GITHUB|GITLAB|SLACK|STRIPE|TWILIO|SENDGRID|AWS|GCP|AZURE|OPENAI|ANTHROPIC|GEMINI|OLLAMA)[_A-Z0-9]*(?:KEY|TOKEN|SECRET|PASS(?:WORD)?|CREDENTIAL)[_A-Z0-9]*)\s*=\s*["']?([A-Za-z0-9\-_.+/=]{10,})["']?/g;function MN(e){return!e||typeof e!="string"?e:e.replace(ON,(t,n)=>`${n}=***REDACTED***`)}var PN=7e3,NN=4e3;function LN(e,t=null){let n=MN(e),o=IP(n),s=t==="read_file"?PN:CN,r=t==="read_file"?NN:AN;if(o>s)try{let{compressToolResult:i}=wn();return i(n,r)}catch{return n}return n}function m_(e){try{let{getActiveModel:t}=it(),n=t(),o=n?`${n.provider}:${n.id}`:"default";if(Tl.has(o))return Tl.get(o);let s=X0(e);return Tl.set(o,s),s}catch{return X0(e)}}function IN(){Tl.clear()}function jN(e,t){let n=new Set(t);return(e||[]).some(o=>o.role!=="assistant"?!1:Array.isArray(o.tool_calls)?o.tool_calls.some(s=>n.has(s?.function?.name||s?.name)):Array.isArray(o.content)?o.content.some(s=>s?.type==="tool_use"&&n.has(s?.name)):!1)}var aa={hash:null,ts:0},DN=3e4;async function g_(){if(aa.hash&&Date.now()-aa.ts<DN)return aa.hash;try{let e=require("fs").promises,t=require("path"),n=[t.join(process.cwd(),"package.json"),t.join(process.cwd(),".git","HEAD"),t.join(process.cwd(),"README.md"),t.join(process.cwd(),"NEX.md")],s=(await Promise.allSettled(n.map(i=>e.stat(i).then(a=>`${i}:${a.mtimeMs}`)))).filter(i=>i.status==="fulfilled").map(i=>i.value);try{let{getMemoryContextHash:i}=Jn(),a=i();a&&s.push(`memory:${a}`)}catch{}try{let i=t.join(process.cwd(),".nex","brain");if(_t.existsSync(i)){let a=await e.stat(i);s.push(`brain:${a.mtimeMs}`)}}catch{}let r=s.join("|");return aa={hash:r,ts:Date.now()},r}catch{return`fallback:${Date.now()}`}}function hp(){ia=null,dp=null,aa={hash:null,ts:0},Gr=null}var qN=new Set(["spawn_agents"]),tp=10,np=10,xl=5,e_=6e4,sp=12e4,FN=process.env.NEX_STALE_AUTO_SWITCH!=="0";function BN(e){try{let t=require("fs"),n=require("path"),o=n.join(process.cwd(),".nex","plans");t.existsSync(o)||t.mkdirSync(o,{recursive:!0});let s=n.join(o,"current-plan.md");t.writeFileSync(s,e,"utf-8")}catch{}}tN(e=>{QP(e,"allow"),eN(),console.log(`${y.green} \u2713 ${e}: always allow${y.reset}`)});async function UN(e){let t=e.function.name,n=t;if(typeof t=="string"&&t.includes(".")){let f=t.split(".").pop(),p={exec:"bash",find:"search_files",search:"search_files",grep_search:"grep",read:"read_file"};gn().some(m=>m.function.name===f)?n=f:p[f]&&(n=p[f])}let o=PP(e.function.arguments),s=e.id||`cli-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;if(!o){let p=gn().find(m=>m.function.name===n),h=p?JSON.stringify(p.function.parameters,null,2):"unknown";return N(`${y.yellow} \u26A0 ${n}: malformed arguments, sending schema hint${y.reset}`),{callId:s,fnName:n,args:null,canExecute:!1,errorResult:{role:"tool",content:`ERROR: Malformed tool arguments. Could not parse your arguments as JSON.
986
+ \u26A0 [Response truncated: repeated paragraph detected (${s}\xD7)]`,u=0,d=-1,f=0;for(;u<t;){let h=e.indexOf(r,f);if(h===-1)break;u++,d=h+r.length,f=h+1}return{text:d>0?e.slice(0,d)+c:e.slice(0,2e3)+c,truncated:!0,repeatCount:s}}var Jf=null,Zf=null,Qf=null;function gn(){if(Jf===null){let{TOOL_DEFINITIONS:e}=Kn();Jf=e}return Zf===null&&(Zf=fN()),Qf===null&&(Qf=uN()),[...Jf,...Zf,...Qf]}var up=50;function TN(e){Number.isFinite(e)&&e>0&&(up=e)}function ep(e=xs()){if(process.env.NEX_DISABLE_TOOL_BUDGET==="1")return 1/0;let t=process.env.NEX_MAX_TOOL_CALLS;if(t){let n=parseInt(t,10);if(Number.isFinite(n)&&n>0)return n}return e==="local"?5:30}function Q0(e,t){return`[SYSTEM STOP] Tool-call budget reached (${e}/${t}). You MUST stop calling tools now. Provide your final answer based only on the information already in the conversation. If the task cannot be completed from the gathered evidence, state the blocker plainly and do not invent facts.`}var El=()=>null;function RN(e){El=e}var ia=null,dp=null,Gr=null,Yr="",zr=0,fp="",pp=0,Tl=new Map,CN=1e4,AN=6e3,ON=/\b((?:API|ACCESS|AUTH|BEARER|CLIENT|GITHUB|GITLAB|SLACK|STRIPE|TWILIO|SENDGRID|AWS|GCP|AZURE|OPENAI|ANTHROPIC|GEMINI|OLLAMA)[_A-Z0-9]*(?:KEY|TOKEN|SECRET|PASS(?:WORD)?|CREDENTIAL)[_A-Z0-9]*)\s*=\s*["']?([A-Za-z0-9\-_.+/=]{10,})["']?/g;function MN(e){return!e||typeof e!="string"?e:e.replace(ON,(t,n)=>`${n}=***REDACTED***`)}var PN=7e3,NN=4e3;function LN(e,t=null){let n=MN(e),o=IP(n),s=t==="read_file"?PN:CN,r=t==="read_file"?NN:AN;if(o>s)try{let{compressToolResult:i}=wn();return i(n,r)}catch{return n}return n}function m_(e){try{let{getActiveModel:t}=it(),n=t(),o=n?`${n.provider}:${n.id}`:"default";if(Tl.has(o))return Tl.get(o);let s=X0(e);return Tl.set(o,s),s}catch{return X0(e)}}function IN(){Tl.clear()}function jN(e,t){let n=new Set(t);return(e||[]).some(o=>o.role!=="assistant"?!1:Array.isArray(o.tool_calls)?o.tool_calls.some(s=>n.has(s?.function?.name||s?.name)):Array.isArray(o.content)?o.content.some(s=>s?.type==="tool_use"&&n.has(s?.name)):!1)}var aa={hash:null,ts:0},DN=3e4;async function g_(){if(aa.hash&&Date.now()-aa.ts<DN)return aa.hash;try{let e=require("fs").promises,t=require("path"),n=[t.join(process.cwd(),"package.json"),t.join(process.cwd(),".git","HEAD"),t.join(process.cwd(),"README.md"),t.join(process.cwd(),"NEX.md")],s=(await Promise.allSettled(n.map(i=>e.stat(i).then(a=>`${i}:${a.mtimeMs}`)))).filter(i=>i.status==="fulfilled").map(i=>i.value);try{let{getMemoryContextHash:i}=Jn(),a=i();a&&s.push(`memory:${a}`)}catch{}try{let i=t.join(process.cwd(),".nex","brain");if(_t.existsSync(i)){let a=await e.stat(i);s.push(`brain:${a.mtimeMs}`)}}catch{}let r=s.join("|");return aa={hash:r,ts:Date.now()},r}catch{return`fallback:${Date.now()}`}}function hp(){ia=null,dp=null,aa={hash:null,ts:0},Gr=null}var qN=new Set(["spawn_agents"]),tp=10,np=10,xl=5,e_=6e4,sp=12e4,FN=process.env.NEX_STALE_AUTO_SWITCH!=="0";function BN(e){try{let t=require("fs"),n=require("path"),o=n.join(process.cwd(),".nex","plans");t.existsSync(o)||t.mkdirSync(o,{recursive:!0});let s=n.join(o,"current-plan.md");t.writeFileSync(s,e,"utf-8")}catch{}}tN(e=>{QP(e,"allow"),eN(),console.log(`${y.green} \u2713 ${e}: always allow${y.reset}`)});async function UN(e){let t=e.function.name,n=t;if(typeof t=="string"&&t.includes(".")){let f=t.split(".").pop(),p={exec:"bash",find:"search_files",search:"search_files",grep_search:"grep",list:"list_directory",print_tree:"list_directory",read:"read_file",tree:"list_directory"};gn().some(m=>m.function.name===f)?n=f:p[f]&&(n=p[f])}let o=PP(e.function.arguments),s=e.id||`cli-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;if(!o){let p=gn().find(m=>m.function.name===n),h=p?JSON.stringify(p.function.parameters,null,2):"unknown";return N(`${y.yellow} \u26A0 ${n}: malformed arguments, sending schema hint${y.reset}`),{callId:s,fnName:n,args:null,canExecute:!1,errorResult:{role:"tool",content:`ERROR: Malformed tool arguments. Could not parse your arguments as JSON.
987
987
  Raw input: ${typeof e.function.arguments=="string"?e.function.arguments.substring(0,200):"N/A"}
988
988
 
989
989
  Expected JSON schema for "${n}":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nex-code",
3
- "version": "0.5.20",
3
+ "version": "0.5.21",
4
4
  "description": "Run 400B+ open coding models on your codebase without the hardware bill. Ollama Cloud first — OpenAI, Anthropic, and Gemini when you need them.",
5
5
  "bin": {
6
6
  "nex-code": "./dist/nex-code.js"