nex-code 0.5.7 → 0.5.9

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/README.md CHANGED
@@ -140,6 +140,14 @@ DEFAULT_PROVIDER=ollama
140
140
  DEFAULT_MODEL=devstral-2:123b
141
141
  ```
142
142
 
143
+ **Env file precedence.** nex-code loads `.env` from three places in this order:
144
+
145
+ 1. Install directory `.env` — non-override, fills blanks only
146
+ 2. `~/.nex-code/.env` — **override**, wins over ambient `process.env`
147
+ 3. Current working directory `.env` — non-override, cannot clobber the global config
148
+
149
+ `~/.nex-code/.env` is the authoritative location for long-lived config like `OLLAMA_API_KEY`. The `override:true` on that file exists so that a rotated key written there takes effect on the next `nex-code` launch, even when nex-code is spawned by a long-running parent process (systemd daemon, supervisor agent, test runner) whose own environment was captured earlier and is now stale. If you rotate an API key, update `~/.nex-code/.env` **and** restart any long-running daemon that spawns nex-code — the `override:true` fixes subprocess launches but cannot refresh the parent's own captured `process.env`.
150
+
143
151
  **Install from source:**
144
152
 
145
153
  ```bash
@@ -7,7 +7,7 @@ var ua=Object.defineProperty;var My=Object.getOwnPropertyDescriptor;var Py=Objec
7
7
  `)};return o.length>0&&(r.images=o),r}return s})}async chat(e,s,n={}){this._modelsLoaded||await this.loadModels();let o=n.model||this.defaultModel;if(!o)throw new Error("No local model available. Is Ollama running?");let r=Dn.buildRequestBody({model:o,messages:this._formatMessages(e),tools:s,maxTokens:n.maxTokens||8192,temperature:n.temperature??this.temperature,stream:!1}),i;try{i=await Er.post(`${this.baseUrl}${Dn.getEndpoint()}`,r,{timeout:n.timeout||this.timeout})}catch(a){if(a.name==="CanceledError"||a.name==="AbortError"||a.code==="ERR_CANCELED")throw a;let l=a.response?.status?` [HTTP ${a.response.status}]`:"",c=a.response?.data?.error||a.message;throw new Error(`API Error${l}: ${c}`)}return Dn.normalizeResponse(i.data)}async stream(e,s,n={}){this._modelsLoaded||await this.loadModels();let o=n.model||this.defaultModel;if(!o)throw new Error("No local model available. Is Ollama running?");let r=n.onToken||(()=>{}),i=Dn.buildRequestBody({model:o,messages:this._formatMessages(e),tools:s,maxTokens:n.maxTokens||8192,temperature:n.temperature??this.temperature,stream:!0}),a;try{a=await Er.post(`${this.baseUrl}${Dn.getEndpoint()}`,i,{timeout:n.timeout||this.timeout,responseType:"stream",signal:n.signal})}catch(c){if(c.name==="CanceledError"||c.name==="AbortError"||c.code==="ERR_CANCELED")throw c;let u=c.response?.status?` [HTTP ${c.response.status}]`:"",d=await n0(c,f=>f?.error);throw new Error(`API Error${u}: ${d}`)}let l=Dn.createStreamParser(r);return new Promise((c,u)=>{n.signal&&n.signal.addEventListener("abort",()=>{a.data.destroy(),u(new DOMException("The operation was aborted","AbortError"))},{once:!0}),a.data.on("data",d=>{let{done:f,result:p}=l.feed(d.toString());f&&c(p)}),a.data.on("error",d=>{n.signal?.aborted||u(new Error(`Stream error: ${d.message}`))}),a.data.on("end",()=>{c(l.flush())})})}normalizeResponse(e){return Dn.normalizeResponse(e)}_parseContextFromModelfile(e){if(!e)return null;let s=e.match(/PARAMETER\s+num_ctx\s+(\d+)/i);return s?parseInt(s[1],10):null}};Au.exports={LocalProvider:ya,DEFAULT_LOCAL_URL:Cu}});var Ft=Z((UT,ju)=>{"use strict";var Nu="\x1B[0m",Mu="\x1B[1m",xs="\x1B[2m";function G(t,e,s){return`\x1B[38;2;${t};${e};${s}m`}function s0(){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(`
8
8
  `),o=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(o){let r=parseInt(o[1].slice(0,2),16),i=parseInt(o[2].slice(0,2),16),a=parseInt(o[3].slice(0,2),16);return .299*r+.587*i+.114*a<128}}catch{}return null}function Pu(){let t=require("os");return require("path").join(t.homedir(),".nex-code",".theme_cache.json")}function o0(t){try{let s=require("fs").readFileSync(Pu(),"utf8"),n=JSON.parse(s);if(n&&typeof n[t]=="boolean")return n[t]}catch{}return null}function r0(t,e){try{let s=require("fs"),n=require("path"),o=Pu(),r=n.dirname(o),i={};try{i=JSON.parse(s.readFileSync(o,"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]),s.existsSync(r)||s.mkdirSync(r,{recursive:!0}),s.writeFileSync(o,JSON.stringify(i),"utf8")}catch{}}function i0(){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 s=process.env.TERM_SESSION_ID||"default",n=o0(s);if(n!==null)return n;let o=s0(),r=o!==null?o:!0;return r0(s,r),r}var Lu=i0(),Iu={reset:Nu,bold:Mu,dim:xs,primary:G(80,190,255),secondary:G(60,170,190),success:G(80,210,120),warning:G(245,175,50),error:G(230,80,80),muted:xs,subtle:G(130,130,145),tool_read:G(80,190,255),tool_write:G(245,165,55),tool_exec:G(185,100,235),tool_search:G(70,185,190),tool_git:G(90,210,100),tool_web:G(100,215,250),tool_sysadmin:G(225,150,75),tool_default:G(100,205,115),syn_keyword:G(185,100,235),syn_string:G(90,210,120),syn_number:G(245,175,50),syn_comment:xs,syn_key:G(80,190,255),diff_add:G(80,210,120),diff_rem:G(230,80,80),banner_logo:G(80,200,255),banner_name:G(80,200,255),banner_version:xs,banner_model:xs,banner_yolo:G(245,175,50),banner_gemini:G(138,180,248),footer_sep:xs,footer_model:G(80,175,235),footer_branch:G(80,210,100),footer_project:G(130,130,145),footer_divider:G(80,80,95),footer_mode:G(210,150,50),white:G(210,210,220),red:G(220,85,85),green:G(80,200,110),yellow:G(230,185,60),blue:G(70,140,230),magenta:G(200,120,190),cyan:G(90,200,215),gray:G(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:G(110,215,230),brightMagenta:G(220,140,210),brightBlue:G(100,160,240)},Du={reset:Nu,bold:Mu,dim:G(110,110,120),primary:G(0,110,190),secondary:G(0,125,148),success:G(0,148,62),warning:G(168,92,0),error:G(188,32,32),muted:G(110,110,120),subtle:G(155,155,165),tool_read:G(0,110,190),tool_write:G(168,92,0),tool_exec:G(128,42,188),tool_search:G(0,122,148),tool_git:G(0,138,62),tool_web:G(0,112,178),tool_sysadmin:G(168,82,0),tool_default:G(0,138,62),syn_keyword:G(128,42,188),syn_string:G(0,138,62),syn_number:G(168,92,0),syn_comment:G(135,135,148),syn_key:G(0,110,190),diff_add:G(0,148,62),diff_rem:G(188,32,32),banner_logo:G(0,122,205),banner_name:G(0,122,205),banner_version:G(100,100,118),banner_model:G(100,100,118),banner_yolo:G(168,62,0),banner_gemini:G(26,115,232),footer_sep:G(168,168,178),footer_model:G(0,102,175),footer_branch:G(0,138,62),footer_project:G(135,135,148),footer_divider:G(168,168,178),footer_mode:G(148,88,0),white:G(40,40,52),red:G(188,32,32),green:G(0,148,62),yellow:G(168,92,0),blue:G(0,110,190),magenta:G(128,42,188),cyan:G(0,125,148),gray:G(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:G(0,158,182),brightMagenta:G(158,52,208),brightBlue:G(0,112,208)},a0=Lu?Iu:Du;ju.exports={T:a0,isDark:Lu,DARK:Iu,LIGHT:Du}});var jn=Z((WT,Fu)=>{"use strict";var bt=require("fs"),qu=require("path");function l0(t){if(!t||isNaN(t))return!1;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}function c0(t){try{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,t)}catch{let e=Date.now()+t;for(;Date.now()<e;);}}function u0(t,e){let s=qu.dirname(t),n=qu.join(s,`.nex-tmp.${process.pid}.${Date.now()}`);try{bt.existsSync(s)||bt.mkdirSync(s,{recursive:!0,mode:448}),bt.writeFileSync(n,e,{encoding:"utf-8",mode:384}),bt.renameSync(n,t)}catch(o){try{bt.unlinkSync(n)}catch{}throw o}}function d0(t,e,{timeout:s=5e3,retryMs:n=50}={}){let o=t+".lock",r=Date.now()+s;for(;;){let i=-1;try{i=bt.openSync(o,"wx"),bt.writeSync(i,Buffer.from(String(process.pid))),bt.closeSync(i),i=-1;try{return e()}finally{try{bt.unlinkSync(o)}catch{}}}catch(a){if(i!==-1)try{bt.closeSync(i)}catch{}if(a.code!=="EEXIST")throw a;try{let l=bt.readFileSync(o,"utf-8").trim(),c=parseInt(l,10);if(!l0(c)){try{bt.unlinkSync(o)}catch{}continue}}catch(l){if(l.code&&l.code!=="ENOENT")throw l;continue}if(Date.now()>=r){try{bt.unlinkSync(o)}catch{}return e()}c0(n)}}}Fu.exports={atomicWrite:u0,withFileLockSync:d0}});var Tr=Z((HT,Ku)=>{var Ss=require("fs"),wa=require("path"),{T:Bu}=Ft(),{atomicWrite:f0,withFileLockSync:h0}=jn(),Uu={openai:{"gpt-4o":{input:2.5,output:10},"gpt-4o-mini":{input:.15,output:.6},"gpt-4.1":{input:2,output:8},"gpt-4.1-mini":{input:.4,output:1.6},"gpt-4.1-nano":{input:.1,output:.4},o1:{input:15,output:60},o3:{input:10,output:40},"o3-mini":{input:1.1,output:4.4},"o4-mini":{input:1.1,output:4.4}},anthropic:{"claude-sonnet":{input:3,output:15},"claude-opus":{input:5,output:25},"claude-haiku":{input:.8,output:4},"claude-sonnet-4-5":{input:3,output:15},"claude-sonnet-4":{input:3,output:15}},gemini:{"gemini-2.5-pro":{input:1.25,output:10},"gemini-2.5-flash":{input:.15,output:.6},"gemini-2.0-flash":{input:.1,output:.4},"gemini-2.0-flash-lite":{input:.075,output:.3}},ollama:{"qwen3-coder:480b":{input:0,output:0},"qwen3-coder-next":{input:0,output:0},"devstral-2:123b":{input:0,output:0},"devstral-small-2:24b":{input:0,output:0},"kimi-k2.5":{input:0,output:0},"kimi-k2:1t":{input:0,output:0},"deepseek-v3.2":{input:0,output:0},"minimax-m2.5":{input:0,output:0},"glm-5":{input:0,output:0},"glm-4.7":{input:0,output:0},"gpt-oss:120b":{input:0,output:0}},local:{}},vr=[],wn={};function p0(t,e,s,n,o=0){if(vr.push({provider:t,model:e,input:s,output:n,cacheRead:o}),wn[t]!==void 0){let r=Gu(t);r.allowed||process.stderr.write(`${Bu.yellow}\u26A0 Budget limit reached for ${t}: $${r.spent.toFixed(2)} / $${r.limit.toFixed(2)}${Bu.reset}
9
9
  `)}}function _a(t,e){let s=Uu[t];return s?s[e]||{input:0,output:0}:{input:0,output:0}}function Wu(t){let e=_a(t.provider,t.model);return(t.input*e.input+t.output*e.output)/1e6}function Hu(){let t={};for(let i of vr){let a=`${i.provider}:${i.model}`;t[a]||(t[a]={provider:i.provider,model:i.model,requests:0,input:0,output:0,cacheRead:0}),t[a].requests++,t[a].input+=i.input,t[a].output+=i.output,t[a].cacheRead+=i.cacheRead||0}let e=Object.values(t).map(i=>({...i,cost:Wu(i)})),s=e.reduce((i,a)=>i+a.cost,0),n=e.reduce((i,a)=>i+a.input,0),o=e.reduce((i,a)=>i+a.output,0),r=e.reduce((i,a)=>i+(a.cacheRead||0),0);return{totalCost:s,totalInput:n,totalOutput:o,totalCacheRead:r,breakdown:e}}function m0(){let{totalCost:t,totalInput:e,totalOutput:s,breakdown:n}=Hu();if(n.length===0)return"No token usage recorded this session.";let o=[];o.push("Session Token Usage:"),o.push("");for(let r of n){let i=r.cost>0?`$${r.cost.toFixed(4)}`:"free";o.push(` ${r.provider}:${r.model}`),o.push(` Input: ${r.input.toLocaleString()} tokens`),o.push(` Output: ${r.output.toLocaleString()} tokens`),o.push(` Cost: ${i}`)}return o.push(""),o.push(` Total: ${e.toLocaleString()} in + ${s.toLocaleString()} out = $${t.toFixed(4)}`),o.join(`
10
- `)}function g0(t){return!t||typeof t!="string"?0:Math.ceil(t.length/4)}function y0(t,e,s,n){let o=_a(t,e),r=(s*o.input+n*o.output)/1e6;return r<=0?"":`[~$${r.toFixed(4)}]`}function w0(){vr=[]}function _0(t,e){wn[t]=e}function $0(t){delete wn[t]}function b0(){return{...wn}}function Yu(t){let e=0;for(let s of vr)s.provider===t&&(e+=Wu(s));return e}function Gu(t){let e=Yu(t),s=wn[t];if(s===void 0)return{allowed:!0,spent:e,limit:null,remaining:null};let n=Math.max(0,s-e);return{allowed:e<s,spent:e,limit:s,remaining:n}}function zu(){let t=wa.join(process.cwd(),".nex","config.json");if(Ss.existsSync(t))try{let e=JSON.parse(Ss.readFileSync(t,"utf-8"));e.costLimits&&typeof e.costLimits=="object"&&(wn={...e.costLimits})}catch{}}function k0(){let t=wa.join(process.cwd(),".nex"),e=wa.join(t,"config.json");Ss.existsSync(t)||Ss.mkdirSync(t,{recursive:!0}),h0(e,()=>{let s={};if(Ss.existsSync(e))try{s=JSON.parse(Ss.readFileSync(e,"utf-8"))}catch{s={}}s.costLimits=wn,f0(e,JSON.stringify(s,null,2))})}function x0(){wn={}}zu();Ku.exports={PRICING:Uu,trackUsage:p0,getSessionCosts:Hu,formatCosts:m0,formatCostHint:y0,resetCosts:w0,getPricing:_a,setCostLimit:_0,removeCostLimit:$0,getCostLimits:b0,getProviderSpend:Yu,checkBudget:Gu,loadCostLimits:zu,saveCostLimits:k0,resetCostLimits:x0,estimateTokens:g0}});var $a=Z((YT,S0)=>{S0.exports={name:"nex-code",version:"0.5.7",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 --forceExit --maxWorkers=50%","test:orchestrator":"jest tests/orchestrator.test.js --forceExit",coverage:"jest --coverage --forceExit","test:watch":"jest --watch",typecheck:"tsc --noEmit",format:"prettier --write .","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=Z((GT,Vu)=>{var{T:se}=Ft(),Ar=5,Es=(()=>{let t=[];for(let e=0;e<Ar;e++)t.push(e);for(let e=Ar-2;e>=1;e--)t.push(e);return t})(),Xu=["\u273D","\u2726","\u2727","\u2726"],ba=class{constructor(e="Thinking..."){this.text=e,this.frame=0,this.interval=null,this.startTime=null}_render(){if(this._stopped)return;let e=Es[this.frame%Es.length],s="";for(let o=0;o<Ar;o++)s+=o===e?`${se.cyan}\u25CF${se.reset}`:" ";let n="";if(this.startTime){let o=Math.floor((Date.now()-this.startTime)/1e3);if(o>=60){let r=Math.floor(o/60),i=o%60;n=` ${se.dim}${r}m ${String(i).padStart(2,"0")}s${se.reset}`}else o>=1&&(n=` ${se.dim}${o}s${se.reset}`)}process.stderr.write(`\x1B[2K\r${s} ${se.dim}${this.text}${se.reset}${n}`),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}},ka=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 s=Math.floor(e/60),n=e%60;return s>0?`${s}m ${String(n).padStart(2,"0")}s`:`${n}s`}_render(){if(this._stopped)return;let e=Es[this.frame%Es.length],s=`${se.cyan}\u25CF${se.reset}`,n=this._formatElapsed(),o=n?` ${se.dim}${n}${se.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=`${se.green}\u2713${se.reset}`,c=se.dim;break;case"error":l=`${se.red}\u2717${se.reset}`,c=se.dim;break;case"retry":l=`${se.yellow}\u21BB${se.reset}`,c=se.yellow;break;default:l=a===e?s:" ",c=""}let u=a===this.labels.length-1?o:"",d=r-4-(u?n.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}${se.reset}${u}
10
+ `)}function g0(t){return!t||typeof t!="string"?0:Math.ceil(t.length/4)}function y0(t,e,s,n){let o=_a(t,e),r=(s*o.input+n*o.output)/1e6;return r<=0?"":`[~$${r.toFixed(4)}]`}function w0(){vr=[]}function _0(t,e){wn[t]=e}function $0(t){delete wn[t]}function b0(){return{...wn}}function Yu(t){let e=0;for(let s of vr)s.provider===t&&(e+=Wu(s));return e}function Gu(t){let e=Yu(t),s=wn[t];if(s===void 0)return{allowed:!0,spent:e,limit:null,remaining:null};let n=Math.max(0,s-e);return{allowed:e<s,spent:e,limit:s,remaining:n}}function zu(){let t=wa.join(process.cwd(),".nex","config.json");if(Ss.existsSync(t))try{let e=JSON.parse(Ss.readFileSync(t,"utf-8"));e.costLimits&&typeof e.costLimits=="object"&&(wn={...e.costLimits})}catch{}}function k0(){let t=wa.join(process.cwd(),".nex"),e=wa.join(t,"config.json");Ss.existsSync(t)||Ss.mkdirSync(t,{recursive:!0}),h0(e,()=>{let s={};if(Ss.existsSync(e))try{s=JSON.parse(Ss.readFileSync(e,"utf-8"))}catch{s={}}s.costLimits=wn,f0(e,JSON.stringify(s,null,2))})}function x0(){wn={}}zu();Ku.exports={PRICING:Uu,trackUsage:p0,getSessionCosts:Hu,formatCosts:m0,formatCostHint:y0,resetCosts:w0,getPricing:_a,setCostLimit:_0,removeCostLimit:$0,getCostLimits:b0,getProviderSpend:Yu,checkBudget:Gu,loadCostLimits:zu,saveCostLimits:k0,resetCostLimits:x0,estimateTokens:g0}});var $a=Z((YT,S0)=>{S0.exports={name:"nex-code",version:"0.5.9",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 --forceExit --maxWorkers=50%","test:orchestrator":"jest tests/orchestrator.test.js --forceExit",coverage:"jest --coverage --forceExit","test:watch":"jest --watch",typecheck:"tsc --noEmit",format:"prettier --write .","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=Z((GT,Vu)=>{var{T:se}=Ft(),Ar=5,Es=(()=>{let t=[];for(let e=0;e<Ar;e++)t.push(e);for(let e=Ar-2;e>=1;e--)t.push(e);return t})(),Xu=["\u273D","\u2726","\u2727","\u2726"],ba=class{constructor(e="Thinking..."){this.text=e,this.frame=0,this.interval=null,this.startTime=null}_render(){if(this._stopped)return;let e=Es[this.frame%Es.length],s="";for(let o=0;o<Ar;o++)s+=o===e?`${se.cyan}\u25CF${se.reset}`:" ";let n="";if(this.startTime){let o=Math.floor((Date.now()-this.startTime)/1e3);if(o>=60){let r=Math.floor(o/60),i=o%60;n=` ${se.dim}${r}m ${String(i).padStart(2,"0")}s${se.reset}`}else o>=1&&(n=` ${se.dim}${o}s${se.reset}`)}process.stderr.write(`\x1B[2K\r${s} ${se.dim}${this.text}${se.reset}${n}`),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}},ka=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 s=Math.floor(e/60),n=e%60;return s>0?`${s}m ${String(n).padStart(2,"0")}s`:`${n}s`}_render(){if(this._stopped)return;let e=Es[this.frame%Es.length],s=`${se.cyan}\u25CF${se.reset}`,n=this._formatElapsed(),o=n?` ${se.dim}${n}${se.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=`${se.green}\u2713${se.reset}`,c=se.dim;break;case"error":l=`${se.red}\u2717${se.reset}`,c=se.dim;break;case"retry":l=`${se.yellow}\u21BB${se.reset}`,c=se.yellow;break;default:l=a===e?s:" ",c=""}let u=a===this.labels.length-1?o:"",d=r-4-(u?n.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}${se.reset}${u}
11
11
  `}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 s=0;s<this.lineCount;s++)e+=`
12
12
  `;this.lineCount>0&&(e+=`\x1B[${this.lineCount}A`),process.stderr.write(e),this._render(),this.interval=setInterval(()=>this._render(),100)}update(e,s){e>=0&&e<this.statuses.length&&(this.statuses[e]=s)}stop(e={}){if(this._stopped=!0,this.interval&&(clearInterval(this.interval),this.interval=null),!e.silent)this._renderFinal();else{let s="";for(let n=0;n<this.lineCount;n++)s+=`\x1B[2K
13
13
  `;this.lineCount>0&&(s+=`\x1B[${this.lineCount}A`),process.stderr.write(s)}process.stderr.write("\x1B[?25h")}_renderFinal(){let e=this._formatElapsed(),s=e?` ${se.dim}${e}${se.reset}`:"",n=process.stderr.columns||80,o="";for(let r=0;r<this.labels.length;r++){let i;switch(this.statuses[r]){case"done":i=`${se.green}\u2713${se.reset}`;break;case"error":i=`${se.red}\u2717${se.reset}`;break;case"retry":i=`${se.yellow}\u21BB${se.reset}`;break;default:i=`${se.yellow}\u25CB${se.reset}`}let a=r===this.labels.length-1?s:"",l=n-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];o+=`\x1B[2K ${i} ${se.dim}${c}${se.reset}${a}
@@ -1210,7 +1210,7 @@ class MyListView(ListAPIView):
1210
1210
  \`\`\`python
1211
1211
  # \u2705 CORRECT - Fail immediately if environment variable missing
1212
1212
  SECRET_KEY = os.environ['DJANGO_SECRET_KEY']
1213
- DEBUG = os.environ.get('DEBUG', 'False') == 'True'
1213
+ DEBUG = os.environ['DEBUG'] == 'True'
1214
1214
 
1215
1215
  # \u274C WRONG - Insecure defaults allow production deployment with dev settings
1216
1216
  SECRET_KEY = os.getenv('SECRET_KEY', 'insecure-dev-key')
package/dist/benchmark.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";var ga=Object.defineProperty;var Zy=Object.getOwnPropertyDescriptor;var Qy=Object.getOwnPropertyNames;var e0=Object.prototype.hasOwnProperty;var t0=(t,e)=>()=>(t&&(e=t(t=0)),e);var Q=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),n0=(t,e)=>{for(var s in e)ga(t,s,{get:e[s],enumerable:!0})},s0=(t,e,s,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Qy(e))!e0.call(t,o)&&o!==s&&ga(t,o,{get:()=>e[o],enumerable:!(n=Zy(e,o))||n.enumerable});return t};var o0=t=>s0(ga({},"__esModule",{value:!0}),t);var Bt=Q((dR,Ru)=>{"use strict";var xu="\x1B[0m",ku="\x1B[1m",bs="\x1B[2m";function z(t,e,s){return`\x1B[38;2;${t};${e};${s}m`}function r0(){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
- `),o=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(o){let r=parseInt(o[1].slice(0,2),16),i=parseInt(o[2].slice(0,2),16),a=parseInt(o[3].slice(0,2),16);return .299*r+.587*i+.114*a<128}}catch{}return null}function Su(){let t=require("os");return require("path").join(t.homedir(),".nex-code",".theme_cache.json")}function i0(t){try{let s=require("fs").readFileSync(Su(),"utf8"),n=JSON.parse(s);if(n&&typeof n[t]=="boolean")return n[t]}catch{}return null}function a0(t,e){try{let s=require("fs"),n=require("path"),o=Su(),r=n.dirname(o),i={};try{i=JSON.parse(s.readFileSync(o,"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]),s.existsSync(r)||s.mkdirSync(r,{recursive:!0}),s.writeFileSync(o,JSON.stringify(i),"utf8")}catch{}}function l0(){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 s=process.env.TERM_SESSION_ID||"default",n=i0(s);if(n!==null)return n;let o=r0(),r=o!==null?o:!0;return a0(s,r),r}var vu=l0(),Eu={reset:xu,bold:ku,dim:bs,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:bs,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:bs,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:bs,banner_model:bs,banner_yolo:z(245,175,50),banner_gemini:z(138,180,248),footer_sep:bs,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)},Tu={reset:xu,bold:ku,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)},c0=vu?Eu:Tu;Ru.exports={T:c0,isDark:vu,DARK:Eu,LIGHT:Tu}});var _r=Q((fR,u0)=>{u0.exports={name:"nex-code",version:"0.5.7",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 --forceExit --maxWorkers=50%","test:orchestrator":"jest tests/orchestrator.test.js --forceExit",coverage:"jest --coverage --forceExit","test:watch":"jest --watch",typecheck:"tsc --noEmit",format:"prettier --write .","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=Q((pR,Au)=>{var{T:oe}=Bt(),xr=5,xs=(()=>{let t=[];for(let e=0;e<xr;e++)t.push(e);for(let e=xr-2;e>=1;e--)t.push(e);return t})(),Cu=["\u273D","\u2726","\u2727","\u2726"],ya=class{constructor(e="Thinking..."){this.text=e,this.frame=0,this.interval=null,this.startTime=null}_render(){if(this._stopped)return;let e=xs[this.frame%xs.length],s="";for(let o=0;o<xr;o++)s+=o===e?`${oe.cyan}\u25CF${oe.reset}`:" ";let n="";if(this.startTime){let o=Math.floor((Date.now()-this.startTime)/1e3);if(o>=60){let r=Math.floor(o/60),i=o%60;n=` ${oe.dim}${r}m ${String(i).padStart(2,"0")}s${oe.reset}`}else o>=1&&(n=` ${oe.dim}${o}s${oe.reset}`)}process.stderr.write(`\x1B[2K\r${s} ${oe.dim}${this.text}${oe.reset}${n}`),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}},wa=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 s=Math.floor(e/60),n=e%60;return s>0?`${s}m ${String(n).padStart(2,"0")}s`:`${n}s`}_render(){if(this._stopped)return;let e=xs[this.frame%xs.length],s=`${oe.cyan}\u25CF${oe.reset}`,n=this._formatElapsed(),o=n?` ${oe.dim}${n}${oe.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=`${oe.green}\u2713${oe.reset}`,c=oe.dim;break;case"error":l=`${oe.red}\u2717${oe.reset}`,c=oe.dim;break;case"retry":l=`${oe.yellow}\u21BB${oe.reset}`,c=oe.yellow;break;default:l=a===e?s:" ",c=""}let u=a===this.labels.length-1?o:"",d=r-4-(u?n.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}${oe.reset}${u}
2
+ `),o=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(o){let r=parseInt(o[1].slice(0,2),16),i=parseInt(o[2].slice(0,2),16),a=parseInt(o[3].slice(0,2),16);return .299*r+.587*i+.114*a<128}}catch{}return null}function Su(){let t=require("os");return require("path").join(t.homedir(),".nex-code",".theme_cache.json")}function i0(t){try{let s=require("fs").readFileSync(Su(),"utf8"),n=JSON.parse(s);if(n&&typeof n[t]=="boolean")return n[t]}catch{}return null}function a0(t,e){try{let s=require("fs"),n=require("path"),o=Su(),r=n.dirname(o),i={};try{i=JSON.parse(s.readFileSync(o,"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]),s.existsSync(r)||s.mkdirSync(r,{recursive:!0}),s.writeFileSync(o,JSON.stringify(i),"utf8")}catch{}}function l0(){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 s=process.env.TERM_SESSION_ID||"default",n=i0(s);if(n!==null)return n;let o=r0(),r=o!==null?o:!0;return a0(s,r),r}var vu=l0(),Eu={reset:xu,bold:ku,dim:bs,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:bs,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:bs,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:bs,banner_model:bs,banner_yolo:z(245,175,50),banner_gemini:z(138,180,248),footer_sep:bs,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)},Tu={reset:xu,bold:ku,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)},c0=vu?Eu:Tu;Ru.exports={T:c0,isDark:vu,DARK:Eu,LIGHT:Tu}});var _r=Q((fR,u0)=>{u0.exports={name:"nex-code",version:"0.5.9",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 --forceExit --maxWorkers=50%","test:orchestrator":"jest tests/orchestrator.test.js --forceExit",coverage:"jest --coverage --forceExit","test:watch":"jest --watch",typecheck:"tsc --noEmit",format:"prettier --write .","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=Q((pR,Au)=>{var{T:oe}=Bt(),xr=5,xs=(()=>{let t=[];for(let e=0;e<xr;e++)t.push(e);for(let e=xr-2;e>=1;e--)t.push(e);return t})(),Cu=["\u273D","\u2726","\u2727","\u2726"],ya=class{constructor(e="Thinking..."){this.text=e,this.frame=0,this.interval=null,this.startTime=null}_render(){if(this._stopped)return;let e=xs[this.frame%xs.length],s="";for(let o=0;o<xr;o++)s+=o===e?`${oe.cyan}\u25CF${oe.reset}`:" ";let n="";if(this.startTime){let o=Math.floor((Date.now()-this.startTime)/1e3);if(o>=60){let r=Math.floor(o/60),i=o%60;n=` ${oe.dim}${r}m ${String(i).padStart(2,"0")}s${oe.reset}`}else o>=1&&(n=` ${oe.dim}${o}s${oe.reset}`)}process.stderr.write(`\x1B[2K\r${s} ${oe.dim}${this.text}${oe.reset}${n}`),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}},wa=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 s=Math.floor(e/60),n=e%60;return s>0?`${s}m ${String(n).padStart(2,"0")}s`:`${n}s`}_render(){if(this._stopped)return;let e=xs[this.frame%xs.length],s=`${oe.cyan}\u25CF${oe.reset}`,n=this._formatElapsed(),o=n?` ${oe.dim}${n}${oe.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=`${oe.green}\u2713${oe.reset}`,c=oe.dim;break;case"error":l=`${oe.red}\u2717${oe.reset}`,c=oe.dim;break;case"retry":l=`${oe.yellow}\u21BB${oe.reset}`,c=oe.yellow;break;default:l=a===e?s:" ",c=""}let u=a===this.labels.length-1?o:"",d=r-4-(u?n.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}${oe.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 s=0;s<this.lineCount;s++)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,s){e>=0&&e<this.statuses.length&&(this.statuses[e]=s)}stop(e={}){if(this._stopped=!0,this.interval&&(clearInterval(this.interval),this.interval=null),!e.silent)this._renderFinal();else{let s="";for(let n=0;n<this.lineCount;n++)s+=`\x1B[2K
5
5
  `;this.lineCount>0&&(s+=`\x1B[${this.lineCount}A`),process.stderr.write(s)}process.stderr.write("\x1B[?25h")}_renderFinal(){let e=this._formatElapsed(),s=e?` ${oe.dim}${e}${oe.reset}`:"",n=process.stderr.columns||80,o="";for(let r=0;r<this.labels.length;r++){let i;switch(this.statuses[r]){case"done":i=`${oe.green}\u2713${oe.reset}`;break;case"error":i=`${oe.red}\u2717${oe.reset}`;break;case"retry":i=`${oe.yellow}\u21BB${oe.reset}`;break;default:i=`${oe.yellow}\u25CB${oe.reset}`}let a=r===this.labels.length-1?s:"",l=n-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];o+=`\x1B[2K ${i} ${oe.dim}${c}${oe.reset}${a}
@@ -1247,7 +1247,7 @@ class MyListView(ListAPIView):
1247
1247
  \`\`\`python
1248
1248
  # \u2705 CORRECT - Fail immediately if environment variable missing
1249
1249
  SECRET_KEY = os.environ['DJANGO_SECRET_KEY']
1250
- DEBUG = os.environ.get('DEBUG', 'False') == 'True'
1250
+ DEBUG = os.environ['DEBUG'] == 'True'
1251
1251
 
1252
1252
  # \u274C WRONG - Insecure defaults allow production deployment with dev settings
1253
1253
  SECRET_KEY = os.getenv('SECRET_KEY', 'insecure-dev-key')
package/dist/nex-code.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- var Yc=Object.defineProperty;var ub=Object.getOwnPropertyDescriptor;var db=Object.getOwnPropertyNames;var fb=Object.prototype.hasOwnProperty;var pb=(t,e)=>()=>(t&&(e=t(t=0)),e);var X=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),hb=(t,e)=>{for(var n in e)Yc(t,n,{get:e[n],enumerable:!0})},mb=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of db(e))!fb.call(t,o)&&o!==n&&Yc(t,o,{get:()=>e[o],enumerable:!(s=ub(e,o))||s.enumerable});return t};var gb=t=>mb(Yc({},"__esModule",{value:!0}),t);var go=X((CM,yb)=>{yb.exports={name:"nex-code",version:"0.5.7",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 --forceExit --maxWorkers=50%","test:orchestrator":"jest tests/orchestrator.test.js --forceExit",coverage:"jest --coverage --forceExit","test:watch":"jest --watch",typecheck:"tsc --noEmit",format:"prettier --write .","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 Et=X((AM,Nf)=>{"use strict";var Tf="\x1B[0m",Rf="\x1B[1m",yo="\x1B[2m";function Z(t,e,n){return`\x1B[38;2;${t};${e};${n}m`}function $b(){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
+ var Yc=Object.defineProperty;var ub=Object.getOwnPropertyDescriptor;var db=Object.getOwnPropertyNames;var fb=Object.prototype.hasOwnProperty;var pb=(t,e)=>()=>(t&&(e=t(t=0)),e);var X=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),hb=(t,e)=>{for(var n in e)Yc(t,n,{get:e[n],enumerable:!0})},mb=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of db(e))!fb.call(t,o)&&o!==n&&Yc(t,o,{get:()=>e[o],enumerable:!(s=ub(e,o))||s.enumerable});return t};var gb=t=>mb(Yc({},"__esModule",{value:!0}),t);var go=X((CM,yb)=>{yb.exports={name:"nex-code",version:"0.5.9",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 --forceExit --maxWorkers=50%","test:orchestrator":"jest tests/orchestrator.test.js --forceExit",coverage:"jest --coverage --forceExit","test:watch":"jest --watch",typecheck:"tsc --noEmit",format:"prettier --write .","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 Et=X((AM,Nf)=>{"use strict";var Tf="\x1B[0m",Rf="\x1B[1m",yo="\x1B[2m";function Z(t,e,n){return`\x1B[38;2;${t};${e};${n}m`}function $b(){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(`
3
3
  `),o=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(o){let r=parseInt(o[1].slice(0,2),16),i=parseInt(o[2].slice(0,2),16),a=parseInt(o[3].slice(0,2),16);return .299*r+.587*i+.114*a<128}}catch{}return null}function Cf(){let t=require("os");return require("path").join(t.homedir(),".nex-code",".theme_cache.json")}function wb(t){try{let n=require("fs").readFileSync(Cf(),"utf8"),s=JSON.parse(n);if(s&&typeof s[t]=="boolean")return s[t]}catch{}return null}function bb(t,e){try{let n=require("fs"),s=require("path"),o=Cf(),r=s.dirname(o),i={};try{i=JSON.parse(n.readFileSync(o,"utf8"))}catch(c){console.error("theme cache failed:",c.message)}i[t]=e;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(o,JSON.stringify(i),"utf8")}catch{}}function _b(){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",s=wb(n);if(s!==null)return s;let o=$b(),r=o!==null?o:!0;return bb(n,r),r}var Af=_b(),Of={reset:Tf,bold:Rf,dim:yo,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:yo,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:yo,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:yo,banner_model:yo,banner_yolo:Z(245,175,50),banner_gemini:Z(138,180,248),footer_sep:yo,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)},Mf={reset:Tf,bold:Rf,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)},xb=Af?Of:Mf;Nf.exports={T:xb,isDark:Af,DARK:Of,LIGHT:Mf}});var wo=X((OM,Lf)=>{var{T:ue}=Et(),Ii=5,$o=(()=>{let t=[];for(let e=0;e<Ii;e++)t.push(e);for(let e=Ii-2;e>=1;e--)t.push(e);return t})(),Pf=["\u273D","\u2726","\u2727","\u2726"],zc=class{constructor(e="Thinking..."){this.text=e,this.frame=0,this.interval=null,this.startTime=null}_render(){if(this._stopped)return;let e=$o[this.frame%$o.length],n="";for(let o=0;o<Ii;o++)n+=o===e?`${ue.cyan}\u25CF${ue.reset}`:" ";let s="";if(this.startTime){let o=Math.floor((Date.now()-this.startTime)/1e3);if(o>=60){let r=Math.floor(o/60),i=o%60;s=` ${ue.dim}${r}m ${String(i).padStart(2,"0")}s${ue.reset}`}else o>=1&&(s=` ${ue.dim}${o}s${ue.reset}`)}process.stderr.write(`\x1B[2K\r${n} ${ue.dim}${this.text}${ue.reset}${s}`),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}},Kc=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),s=e%60;return n>0?`${n}m ${String(s).padStart(2,"0")}s`:`${s}s`}_render(){if(this._stopped)return;let e=$o[this.frame%$o.length],n=`${ue.cyan}\u25CF${ue.reset}`,s=this._formatElapsed(),o=s?` ${ue.dim}${s}${ue.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=`${ue.green}\u2713${ue.reset}`,u=ue.dim;break;case"error":c=`${ue.red}\u2717${ue.reset}`,u=ue.dim;break;case"retry":c=`${ue.yellow}\u21BB${ue.reset}`,u=ue.yellow;break;default:c=a===e?n:" ",u=""}let d=a===this.labels.length-1?o:"",f=r-4-(d?s.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}${ue.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 e="\x1B[?25l";for(let n=0;n<this.lineCount;n++)e+=`
5
5
  `;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 s=0;s<this.lineCount;s++)n+=`\x1B[2K
@@ -1248,7 +1248,7 @@ class MyListView(ListAPIView):
1248
1248
  \`\`\`python
1249
1249
  # \u2705 CORRECT - Fail immediately if environment variable missing
1250
1250
  SECRET_KEY = os.environ['DJANGO_SECRET_KEY']
1251
- DEBUG = os.environ.get('DEBUG', 'False') == 'True'
1251
+ DEBUG = os.environ['DEBUG'] == 'True'
1252
1252
 
1253
1253
  # \u274C WRONG - Insecure defaults allow production deployment with dev settings
1254
1254
  SECRET_KEY = os.getenv('SECRET_KEY', 'insecure-dev-key')
@@ -1479,7 +1479,7 @@ ${n}`}];try{let i=((await C0(s,[],{temperature:0,maxTokens:800})).content||"").t
1479
1479
  `)?o+i:o+`
1480
1480
  `+i:i)}return s.length>0&&(o.endsWith(`
1481
1481
  `)||(o+=`
1482
- `),OA(e,o)),s})}async function IA(t){let e=await O0(t);if(e.skipped)return{applied:[],nexAdded:[],summary:null,skipped:!0};if(e.error)return{applied:[],nexAdded:[],summary:null,error:e.error};let n=M0(e.memories),s=N0(e.nex_additions);return{applied:n,nexAdded:s,summary:e.summary}}var DA=`You are a knowledge base agent for an AI coding assistant called nex-code.
1482
+ `),OA(e,o)),s})}async function IA(t){let e=await O0(t);if(e.skipped)return{applied:[],nexAdded:[],summary:null,skipped:!0};if(e.error)return{applied:[],nexAdded:[],summary:null,error:e.error};if(!Array.isArray(e.memories))return{applied:[],nexAdded:[],summary:null,error:"Invalid memories format"};let n=M0(e.memories),s=N0(e.nex_additions);return{applied:n,nexAdded:s,summary:e.summary}}var DA=`You are a knowledge base agent for an AI coding assistant called nex-code.
1483
1483
  Analyze this conversation and extract knowledge worth persisting in the project knowledge base (.nex/brain/).
1484
1484
 
1485
1485
  Return ONLY valid JSON in this exact format:
@@ -1895,7 +1895,7 @@ press Ctrl+C to stop
1895
1895
  `);let a=[];for(let u of o.triggers){let d=null;switch(u.on){case"file-change":d=bM(u,o,n);break;case"git-commit":d=_M(u,o,n);break;case"schedule":d=xM(u,o);break;default:process.stderr.write(`[daemon] unknown trigger type: ${u.on}
1896
1896
  `)}d&&a.push(d)}let c=()=>{process.stdout.write(`
1897
1897
  [daemon] shutting down...
1898
- `);for(let u of a)try{u&&typeof u.close=="function"?u.close():u&&clearInterval(u)}catch{}process.exit(0)};return process.on("SIGINT",c),process.on("SIGTERM",c),new Promise(()=>{})}Dw.exports={startDaemon:SM,parseCronToMs:Pw,expandTemplate:af,appendLog:Lw,notifyMatrix:Iw}});var Fw=X((DP,qw)=>{qw.exports=sf()});var Pc=require("path"),kM=require("os");require("dotenv").config({path:Pc.join(__dirname,"..",".env")});require("dotenv").config({path:Pc.join(kM.homedir(),".nex-code",".env")});require("dotenv").config();var $e=process.argv.slice(2);($e.includes("--help")||$e.includes("-h"))&&(console.log(`Usage: nex-code [options]
1898
+ `);for(let u of a)try{u&&typeof u.close=="function"?u.close():u&&clearInterval(u)}catch{}process.exit(0)};return process.on("SIGINT",c),process.on("SIGTERM",c),new Promise(()=>{})}Dw.exports={startDaemon:SM,parseCronToMs:Pw,expandTemplate:af,appendLog:Lw,notifyMatrix:Iw}});var Fw=X((DP,qw)=>{qw.exports=sf()});var Pc=require("path"),kM=require("os");require("dotenv").config({path:Pc.join(__dirname,"..",".env")});require("dotenv").config({path:Pc.join(kM.homedir(),".nex-code",".env"),override:!0});require("dotenv").config();var $e=process.argv.slice(2);($e.includes("--help")||$e.includes("-h"))&&(console.log(`Usage: nex-code [options]
1899
1899
 
1900
1900
  Options:
1901
1901
  --task <prompt> Run a single task and exit (headless mode)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nex-code",
3
- "version": "0.5.7",
3
+ "version": "0.5.9",
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"