nex-code 0.4.33 → 0.4.36
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/dist/benchmark.js +1 -1
- package/dist/nex-code.js +1 -1
- package/dist/skills/autoresearch.js +77 -34
- package/package.json +1 -1
package/dist/benchmark.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";var se=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var ks=se((rk,Jc)=>{"use strict";var Gc="\x1B[0m",Yc="\x1B[1m",Wn="\x1B[2m";function Y(t,e,s){return`\x1B[38;2;${t};${e};${s}m`}function Zh(){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 Kc(){let t=require("os");return require("path").join(t.homedir(),".nex-code",".theme_cache.json")}function Qh(t){try{let s=require("fs").readFileSync(Kc(),"utf8"),n=JSON.parse(s);if(n&&typeof n[t]=="boolean")return n[t]}catch{}return null}function em(t,e){try{let s=require("fs"),n=require("path"),o=Kc(),r=n.dirname(o),i={};try{i=JSON.parse(s.readFileSync(o,"utf8"))}catch{}i[t]=e;let a=Object.keys(i);a.length>50&&a.slice(0,a.length-50).forEach(c=>delete i[c]),s.existsSync(r)||s.mkdirSync(r,{recursive:!0}),s.writeFileSync(o,JSON.stringify(i),"utf8")}catch{}}function tm(){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=Qh(s);if(n!==null)return n;let o=Zh(),r=o!==null?o:!0;return em(s,r),r}var zc=tm(),Xc={reset:Gc,bold:Yc,dim:Wn,primary:Y(80,190,255),secondary:Y(60,170,190),success:Y(80,210,120),warning:Y(245,175,50),error:Y(230,80,80),muted:Wn,subtle:Y(130,130,145),tool_read:Y(80,190,255),tool_write:Y(245,165,55),tool_exec:Y(185,100,235),tool_search:Y(70,185,190),tool_git:Y(90,210,100),tool_web:Y(100,215,250),tool_sysadmin:Y(225,150,75),tool_default:Y(100,205,115),syn_keyword:Y(185,100,235),syn_string:Y(90,210,120),syn_number:Y(245,175,50),syn_comment:Wn,syn_key:Y(80,190,255),diff_add:Y(80,210,120),diff_rem:Y(230,80,80),banner_logo:Y(80,200,255),banner_name:Y(80,200,255),banner_version:Wn,banner_model:Wn,banner_yolo:Y(245,175,50),footer_sep:Wn,footer_model:Y(80,175,235),footer_branch:Y(80,210,100),footer_project:Y(130,130,145),footer_divider:Y(80,80,95),footer_mode:Y(210,150,50),white:"\x1B[37m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",diff_add_bg:"\x1B[48;2;10;46;20m",diff_rem_bg:"\x1B[48;2;58;16;16m",brightCyan:"\x1B[96m",brightMagenta:"\x1B[95m",brightBlue:"\x1B[94m"},Vc={reset:Gc,bold:Yc,dim:Y(110,110,120),primary:Y(0,110,190),secondary:Y(0,125,148),success:Y(0,148,62),warning:Y(168,92,0),error:Y(188,32,32),muted:Y(110,110,120),subtle:Y(155,155,165),tool_read:Y(0,110,190),tool_write:Y(168,92,0),tool_exec:Y(128,42,188),tool_search:Y(0,122,148),tool_git:Y(0,138,62),tool_web:Y(0,112,178),tool_sysadmin:Y(168,82,0),tool_default:Y(0,138,62),syn_keyword:Y(128,42,188),syn_string:Y(0,138,62),syn_number:Y(168,92,0),syn_comment:Y(135,135,148),syn_key:Y(0,110,190),diff_add:Y(0,148,62),diff_rem:Y(188,32,32),banner_logo:Y(0,122,205),banner_name:Y(0,122,205),banner_version:Y(100,100,118),banner_model:Y(100,100,118),banner_yolo:Y(168,62,0),footer_sep:Y(168,168,178),footer_model:Y(0,102,175),footer_branch:Y(0,138,62),footer_project:Y(135,135,148),footer_divider:Y(168,168,178),footer_mode:Y(148,88,0),white:Y(40,40,52),red:Y(188,32,32),green:Y(0,148,62),yellow:Y(168,92,0),blue:Y(0,110,190),magenta:Y(128,42,188),cyan:Y(0,125,148),gray:Y(132,132,142),bgRed:"\x1B[41m",bgGreen:"\x1B[42m",diff_add_bg:"\x1B[48;2;215;245;220m",diff_rem_bg:"\x1B[48;2;255;215;215m",brightCyan:Y(0,158,182),brightMagenta:Y(158,52,208),brightBlue:Y(0,112,208)},nm=zc?Xc:Vc;Jc.exports={T:nm,isDark:zc,DARK:Xc,LIGHT:Vc}});var No=se((ik,sm)=>{sm.exports={name:"nex-code",version:"0.4.
|
|
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 Kc(){let t=require("os");return require("path").join(t.homedir(),".nex-code",".theme_cache.json")}function Qh(t){try{let s=require("fs").readFileSync(Kc(),"utf8"),n=JSON.parse(s);if(n&&typeof n[t]=="boolean")return n[t]}catch{}return null}function em(t,e){try{let s=require("fs"),n=require("path"),o=Kc(),r=n.dirname(o),i={};try{i=JSON.parse(s.readFileSync(o,"utf8"))}catch{}i[t]=e;let a=Object.keys(i);a.length>50&&a.slice(0,a.length-50).forEach(c=>delete i[c]),s.existsSync(r)||s.mkdirSync(r,{recursive:!0}),s.writeFileSync(o,JSON.stringify(i),"utf8")}catch{}}function tm(){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=Qh(s);if(n!==null)return n;let o=Zh(),r=o!==null?o:!0;return em(s,r),r}var zc=tm(),Xc={reset:Gc,bold:Yc,dim:Wn,primary:Y(80,190,255),secondary:Y(60,170,190),success:Y(80,210,120),warning:Y(245,175,50),error:Y(230,80,80),muted:Wn,subtle:Y(130,130,145),tool_read:Y(80,190,255),tool_write:Y(245,165,55),tool_exec:Y(185,100,235),tool_search:Y(70,185,190),tool_git:Y(90,210,100),tool_web:Y(100,215,250),tool_sysadmin:Y(225,150,75),tool_default:Y(100,205,115),syn_keyword:Y(185,100,235),syn_string:Y(90,210,120),syn_number:Y(245,175,50),syn_comment:Wn,syn_key:Y(80,190,255),diff_add:Y(80,210,120),diff_rem:Y(230,80,80),banner_logo:Y(80,200,255),banner_name:Y(80,200,255),banner_version:Wn,banner_model:Wn,banner_yolo:Y(245,175,50),footer_sep:Wn,footer_model:Y(80,175,235),footer_branch:Y(80,210,100),footer_project:Y(130,130,145),footer_divider:Y(80,80,95),footer_mode:Y(210,150,50),white:"\x1B[37m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",diff_add_bg:"\x1B[48;2;10;46;20m",diff_rem_bg:"\x1B[48;2;58;16;16m",brightCyan:"\x1B[96m",brightMagenta:"\x1B[95m",brightBlue:"\x1B[94m"},Vc={reset:Gc,bold:Yc,dim:Y(110,110,120),primary:Y(0,110,190),secondary:Y(0,125,148),success:Y(0,148,62),warning:Y(168,92,0),error:Y(188,32,32),muted:Y(110,110,120),subtle:Y(155,155,165),tool_read:Y(0,110,190),tool_write:Y(168,92,0),tool_exec:Y(128,42,188),tool_search:Y(0,122,148),tool_git:Y(0,138,62),tool_web:Y(0,112,178),tool_sysadmin:Y(168,82,0),tool_default:Y(0,138,62),syn_keyword:Y(128,42,188),syn_string:Y(0,138,62),syn_number:Y(168,92,0),syn_comment:Y(135,135,148),syn_key:Y(0,110,190),diff_add:Y(0,148,62),diff_rem:Y(188,32,32),banner_logo:Y(0,122,205),banner_name:Y(0,122,205),banner_version:Y(100,100,118),banner_model:Y(100,100,118),banner_yolo:Y(168,62,0),footer_sep:Y(168,168,178),footer_model:Y(0,102,175),footer_branch:Y(0,138,62),footer_project:Y(135,135,148),footer_divider:Y(168,168,178),footer_mode:Y(148,88,0),white:Y(40,40,52),red:Y(188,32,32),green:Y(0,148,62),yellow:Y(168,92,0),blue:Y(0,110,190),magenta:Y(128,42,188),cyan:Y(0,125,148),gray:Y(132,132,142),bgRed:"\x1B[41m",bgGreen:"\x1B[42m",diff_add_bg:"\x1B[48;2;215;245;220m",diff_rem_bg:"\x1B[48;2;255;215;215m",brightCyan:Y(0,158,182),brightMagenta:Y(158,52,208),brightBlue:Y(0,112,208)},nm=zc?Xc:Vc;Jc.exports={T:nm,isDark:zc,DARK:Xc,LIGHT:Vc}});var No=se((ik,sm)=>{sm.exports={name:"nex-code",version:"0.4.36",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:"esbuild bin/nex-code.js --bundle --platform=node --target=node18 --outfile=dist/nex-code.js --minify --external:axios --external:dotenv --external:playwright && esbuild cli/benchmark.js --bundle --platform=node --target=node18 --outfile=dist/benchmark.js --minify --external:axios --external:dotenv --external:playwright && rm -rf dist/skills && cp -r cli/skills dist/skills",dev:"esbuild bin/nex-code.js --bundle --platform=node --target=node18 --outfile=dist/nex-code.js --external:axios --external:dotenv --external:playwright --watch",test:"jest --forceExit","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-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-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",release:"npm version patch && git push --follow-tags && npm publish"},keywords:["ai","cli","coding","agent","ollama","ollama-cloud","openai","anthropic","claude","gemini","llm","gpt","agentic","terminal","coding-assistant","claude-code-alternative","gemini-cli-alternative","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.7.0",dotenv:"^16.4.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 Hn=se((ak,Qc)=>{var{T:Z}=ks(),Po=5,Un=(()=>{let t=[];for(let e=0;e<Po;e++)t.push(e);for(let e=Po-2;e>=1;e--)t.push(e);return t})(),Zc=["\u273D","\u2726","\u2727","\u2726"],gi=class{constructor(e="Thinking..."){this.text=e,this.frame=0,this.interval=null,this.startTime=null}_render(){if(this._stopped)return;let e=Un[this.frame%Un.length],s="";for(let o=0;o<Po;o++)s+=o===e?`${Z.cyan}\u25CF${Z.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=` ${Z.dim}${r}m ${String(i).padStart(2,"0")}s${Z.reset}`}else o>=1&&(n=` ${Z.dim}${o}s${Z.reset}`)}process.stderr.write(`\x1B[2K\r${s} ${Z.dim}${this.text}${Z.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}},yi=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=Un[this.frame%Un.length],s=`${Z.cyan}\u25CF${Z.reset}`,n=this._formatElapsed(),o=n?` ${Z.dim}${n}${Z.reset}`:"",r=process.stderr.columns||80,i="";for(let a=0;a<this.labels.length;a++){let c,l;switch(this.statuses[a]){case"done":c=`${Z.green}\u2713${Z.reset}`,l=Z.dim;break;case"error":c=`${Z.red}\u2717${Z.reset}`,l=Z.dim;break;case"retry":c=`${Z.yellow}\u21BB${Z.reset}`,l=Z.yellow;break;default:c=a===e?s:" ",l=""}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 ${c} ${l}${f}${Z.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?` ${Z.dim}${e}${Z.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=`${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?s:"",c=n-4-(a?e.length+1:0),l=this.labels[r].length>c?this.labels[r].substring(0,Math.max(10,c-3))+"...":this.labels[r];o+=`\x1B[2K ${i} ${Z.dim}${l}${Z.reset}${a}
|
package/dist/nex-code.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var te=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Ps=te((mT,T$)=>{T$.exports={name:"nex-code",version:"0.4.
|
|
2
|
+
var te=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Ps=te((mT,T$)=>{T$.exports={name:"nex-code",version:"0.4.36",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:"esbuild bin/nex-code.js --bundle --platform=node --target=node18 --outfile=dist/nex-code.js --minify --external:axios --external:dotenv --external:playwright && esbuild cli/benchmark.js --bundle --platform=node --target=node18 --outfile=dist/benchmark.js --minify --external:axios --external:dotenv --external:playwright && rm -rf dist/skills && cp -r cli/skills dist/skills",dev:"esbuild bin/nex-code.js --bundle --platform=node --target=node18 --outfile=dist/nex-code.js --external:axios --external:dotenv --external:playwright --watch",test:"jest --forceExit","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-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-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",release:"npm version patch && git push --follow-tags && npm publish"},keywords:["ai","cli","coding","agent","ollama","ollama-cloud","openai","anthropic","claude","gemini","llm","gpt","agentic","terminal","coding-assistant","claude-code-alternative","gemini-cli-alternative","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.7.0",dotenv:"^16.4.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 Vn=te((hT,Lu)=>{"use strict";var Cu="\x1B[0m",Au="\x1B[1m",Ls="\x1B[2m";function ee(t,e,n){return`\x1B[38;2;${t};${e};${n}m`}function R$(){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
|
`),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),c=parseInt(s[3].slice(0,2),16);return .299*r+.587*i+.114*c<128}}catch{}return null}function Ou(){let t=require("os");return require("path").join(t.homedir(),".nex-code",".theme_cache.json")}function C$(t){try{let n=require("fs").readFileSync(Ou(),"utf8"),o=JSON.parse(n);if(o&&typeof o[t]=="boolean")return o[t]}catch{}return null}function A$(t,e){try{let n=require("fs"),o=require("path"),s=Ou(),r=o.dirname(s),i={};try{i=JSON.parse(n.readFileSync(s,"utf8"))}catch{}i[t]=e;let c=Object.keys(i);c.length>50&&c.slice(0,c.length-50).forEach(l=>delete i[l]),n.existsSync(r)||n.mkdirSync(r,{recursive:!0}),n.writeFileSync(s,JSON.stringify(i),"utf8")}catch{}}function O$(){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(";"),c=parseInt(i[i.length-1],10);if(!isNaN(c))return c<8}let n=process.env.TERM_SESSION_ID||"default",o=C$(n);if(o!==null)return o;let s=R$(),r=s!==null?s:!0;return A$(n,r),r}var Nu=O$(),Mu={reset:Cu,bold:Au,dim:Ls,primary:ee(80,190,255),secondary:ee(60,170,190),success:ee(80,210,120),warning:ee(245,175,50),error:ee(230,80,80),muted:Ls,subtle:ee(130,130,145),tool_read:ee(80,190,255),tool_write:ee(245,165,55),tool_exec:ee(185,100,235),tool_search:ee(70,185,190),tool_git:ee(90,210,100),tool_web:ee(100,215,250),tool_sysadmin:ee(225,150,75),tool_default:ee(100,205,115),syn_keyword:ee(185,100,235),syn_string:ee(90,210,120),syn_number:ee(245,175,50),syn_comment:Ls,syn_key:ee(80,190,255),diff_add:ee(80,210,120),diff_rem:ee(230,80,80),banner_logo:ee(80,200,255),banner_name:ee(80,200,255),banner_version:Ls,banner_model:Ls,banner_yolo:ee(245,175,50),footer_sep:Ls,footer_model:ee(80,175,235),footer_branch:ee(80,210,100),footer_project:ee(130,130,145),footer_divider:ee(80,80,95),footer_mode:ee(210,150,50),white:"\x1B[37m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",diff_add_bg:"\x1B[48;2;10;46;20m",diff_rem_bg:"\x1B[48;2;58;16;16m",brightCyan:"\x1B[96m",brightMagenta:"\x1B[95m",brightBlue:"\x1B[94m"},Pu={reset:Cu,bold:Au,dim:ee(110,110,120),primary:ee(0,110,190),secondary:ee(0,125,148),success:ee(0,148,62),warning:ee(168,92,0),error:ee(188,32,32),muted:ee(110,110,120),subtle:ee(155,155,165),tool_read:ee(0,110,190),tool_write:ee(168,92,0),tool_exec:ee(128,42,188),tool_search:ee(0,122,148),tool_git:ee(0,138,62),tool_web:ee(0,112,178),tool_sysadmin:ee(168,82,0),tool_default:ee(0,138,62),syn_keyword:ee(128,42,188),syn_string:ee(0,138,62),syn_number:ee(168,92,0),syn_comment:ee(135,135,148),syn_key:ee(0,110,190),diff_add:ee(0,148,62),diff_rem:ee(188,32,32),banner_logo:ee(0,122,205),banner_name:ee(0,122,205),banner_version:ee(100,100,118),banner_model:ee(100,100,118),banner_yolo:ee(168,62,0),footer_sep:ee(168,168,178),footer_model:ee(0,102,175),footer_branch:ee(0,138,62),footer_project:ee(135,135,148),footer_divider:ee(168,168,178),footer_mode:ee(148,88,0),white:ee(40,40,52),red:ee(188,32,32),green:ee(0,148,62),yellow:ee(168,92,0),blue:ee(0,110,190),magenta:ee(128,42,188),cyan:ee(0,125,148),gray:ee(132,132,142),bgRed:"\x1B[41m",bgGreen:"\x1B[42m",diff_add_bg:"\x1B[48;2;215;245;220m",diff_rem_bg:"\x1B[48;2;255;215;215m",brightCyan:ee(0,158,182),brightMagenta:ee(158,52,208),brightBlue:ee(0,112,208)},N$=Nu?Mu:Pu;Lu.exports={T:N$,isDark:Nu,DARK:Mu,LIGHT:Pu}});var js=te((gT,ju)=>{var{T:re}=Vn(),Ur=5,Is=(()=>{let t=[];for(let e=0;e<Ur;e++)t.push(e);for(let e=Ur-2;e>=1;e--)t.push(e);return t})(),Iu=["\u273D","\u2726","\u2727","\u2726"],Pa=class{constructor(e="Thinking..."){this.text=e,this.frame=0,this.interval=null,this.startTime=null}_render(){if(this._stopped)return;let e=Is[this.frame%Is.length],n="";for(let s=0;s<Ur;s++)n+=s===e?`${re.cyan}\u25CF${re.reset}`:" ";let o="";if(this.startTime){let s=Math.floor((Date.now()-this.startTime)/1e3);if(s>=60){let r=Math.floor(s/60),i=s%60;o=` ${re.dim}${r}m ${String(i).padStart(2,"0")}s${re.reset}`}else s>=1&&(o=` ${re.dim}${s}s${re.reset}`)}process.stderr.write(`\x1B[2K\r${n} ${re.dim}${this.text}${re.reset}${o}`),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}},La=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=Is[this.frame%Is.length],n=`${re.cyan}\u25CF${re.reset}`,o=this._formatElapsed(),s=o?` ${re.dim}${o}${re.reset}`:"",r=process.stderr.columns||80,i="";for(let c=0;c<this.labels.length;c++){let l,u;switch(this.statuses[c]){case"done":l=`${re.green}\u2713${re.reset}`,u=re.dim;break;case"error":l=`${re.red}\u2717${re.reset}`,u=re.dim;break;case"retry":l=`${re.yellow}\u21BB${re.reset}`,u=re.yellow;break;default:l=c===e?n:" ",u=""}let d=c===this.labels.length-1?s:"",f=r-4-(d?o.length+1:0),p=this.labels[c].length>f?this.labels[c].substring(0,Math.max(10,f-3))+"...":this.labels[c];i+=`\x1B[2K ${l} ${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 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 o=0;o<this.lineCount;o++)n+=`\x1B[2K
|
|
@@ -234,40 +234,62 @@ Use ar_run_experiment with output_file to redirect, then ar_extract_metric to re
|
|
|
234
234
|
"",
|
|
235
235
|
"You are optimizing nex-code itself. The benchmark suite is your eval harness — DO NOT modify it.",
|
|
236
236
|
"",
|
|
237
|
-
"### Setup",
|
|
238
|
-
"1. Call ar_setup_branch
|
|
239
|
-
"2. Call ar_run_benchmark with quick=true
|
|
240
|
-
"3.
|
|
237
|
+
"### Setup (run ONCE)",
|
|
238
|
+
"1. Call ar_setup_branch (tag: 'self-improve')",
|
|
239
|
+
"2. Call ar_run_benchmark with quick=true — the result contains per-category scores",
|
|
240
|
+
"3. From the benchmark JSON result, identify the weakest category. STOP. Do NOT read any source files yet.",
|
|
241
241
|
"",
|
|
242
|
-
"### Loop",
|
|
243
|
-
"1. Pick ONE targeted improvement to address the weakest benchmark area",
|
|
244
|
-
"2. ar_checkpoint before making changes",
|
|
245
|
-
"3. Edit nex-code source files (agent.js, orchestrator.js, context-engine.js, etc.)",
|
|
246
|
-
"4. Run npm test to verify nothing breaks — if tests fail, fix or revert immediately",
|
|
247
|
-
"5. npm run build to update dist/",
|
|
248
|
-
"6. ar_run_benchmark with quick=true to measure the new score",
|
|
249
|
-
"7. ar_log_experiment with the benchmark score as metric",
|
|
250
|
-
"8. If score improved: keep. If score same or worse: ar_revert",
|
|
251
|
-
"9. Repeat — do NOT stop",
|
|
242
|
+
"### Loop (repeat until stopped)",
|
|
252
243
|
"",
|
|
253
|
-
"
|
|
254
|
-
"
|
|
255
|
-
"
|
|
256
|
-
"- cli/context-engine.js — compression, token estimation",
|
|
257
|
-
"- cli/sub-agent.js — retry logic, error classification",
|
|
258
|
-
"- cli/task-router.js — routing logic",
|
|
259
|
-
"- Any other cli/ source file that affects agent quality",
|
|
244
|
+
"**Step A — Hypothesize BEFORE reading code**",
|
|
245
|
+
"State your hypothesis in one sentence: 'I will change <specific thing> in <specific file> to improve <category>.'",
|
|
246
|
+
"Do this BEFORE opening any file. If you cannot state a specific hypothesis, pick the simplest possible change.",
|
|
260
247
|
"",
|
|
261
|
-
"
|
|
262
|
-
"
|
|
263
|
-
"
|
|
264
|
-
"
|
|
248
|
+
"**Step B — Read ONE targeted location**",
|
|
249
|
+
"Open ONLY the specific file and line range your hypothesis requires.",
|
|
250
|
+
"Do NOT read multiple files. Do NOT read agent.js broadly. Do NOT investigate root causes further.",
|
|
251
|
+
"If the edit target is not where you expected: make your best guess and proceed.",
|
|
265
252
|
"",
|
|
266
|
-
"
|
|
267
|
-
"
|
|
268
|
-
"
|
|
269
|
-
"
|
|
270
|
-
"
|
|
253
|
+
"**Step C — Checkpoint and edit**",
|
|
254
|
+
"1. ar_checkpoint",
|
|
255
|
+
"2. Make the ONE targeted edit",
|
|
256
|
+
"3. npm test — if tests fail, ar_revert immediately and go back to Step A with a different hypothesis",
|
|
257
|
+
"4. npm run build",
|
|
258
|
+
"",
|
|
259
|
+
"**Step D — Measure**",
|
|
260
|
+
"1. ar_run_benchmark quick=true",
|
|
261
|
+
"2. ar_log_experiment with the score as metric",
|
|
262
|
+
"3. If score improved: keep, go to Step A",
|
|
263
|
+
"4. If score same or worse: ar_revert, go to Step A with a different hypothesis",
|
|
264
|
+
"",
|
|
265
|
+
"### HARD RULES",
|
|
266
|
+
"- NEVER read more than 2 files per experiment cycle",
|
|
267
|
+
"- NEVER use bash to create branches or run benchmarks — use ar_ tools only",
|
|
268
|
+
"- If you are blocked from reading a file, SKIP IT and make your edit based on what you already know",
|
|
269
|
+
"- If 3 consecutive experiments fail to improve, change category focus",
|
|
270
|
+
"- Simplicity criterion: prefer removing code over adding it — complexity cost must be justified by metric gain",
|
|
271
|
+
"",
|
|
272
|
+
"### How the benchmark score works — READ THIS FIRST",
|
|
273
|
+
"The benchmark sends nex-code's TOOL_DEFINITIONS (schemas) to external models and checks:",
|
|
274
|
+
" - Did the model call a tool? (tool call rate)",
|
|
275
|
+
" - Did it call the RIGHT tool? (name accuracy)",
|
|
276
|
+
" - Did it provide valid arguments? (args validity)",
|
|
277
|
+
" - Did it match the JSON schema? (schema compliance)",
|
|
278
|
+
"The score reflects how CLEAR and DESCRIPTIVE nex-code's tool schemas are.",
|
|
279
|
+
"Changes to agent.js, context-engine.js, sub-agent.js have NO EFFECT on this score.",
|
|
280
|
+
"",
|
|
281
|
+
"### What actually moves the score",
|
|
282
|
+
"- cli/tools/index.js — tool `description` fields, parameter descriptions, examples",
|
|
283
|
+
" → Clearer descriptions = models pick the right tool more often",
|
|
284
|
+
" → Better parameter descriptions = models pass valid args more often",
|
|
285
|
+
" → Adding usage examples to descriptions = fewer wrong tool selections",
|
|
286
|
+
"- The `name` field of tools (must be clear and unambiguous)",
|
|
287
|
+
"- The `required` array in tool schemas (must match what models need to call it)",
|
|
288
|
+
"",
|
|
289
|
+
"### CANNOT modify",
|
|
290
|
+
"- cli/benchmark.js — eval harness, hands off",
|
|
291
|
+
"- tests/ — not the optimization target",
|
|
292
|
+
"- Tool names (renaming breaks existing sessions)",
|
|
271
293
|
].join("\n");
|
|
272
294
|
},
|
|
273
295
|
},
|
|
@@ -855,17 +877,33 @@ Use ar_run_experiment with output_file to redirect, then ar_extract_metric to re
|
|
|
855
877
|
experiments.push(entry);
|
|
856
878
|
saveExperiments();
|
|
857
879
|
|
|
858
|
-
const
|
|
880
|
+
const prev =
|
|
859
881
|
experiments.length >= 2
|
|
860
|
-
?
|
|
882
|
+
? experiments[experiments.length - 2].metric
|
|
883
|
+
: null;
|
|
884
|
+
const trend =
|
|
885
|
+
prev != null
|
|
886
|
+
? `Previous: ${prev}, Current: ${args.metric}`
|
|
861
887
|
: "First experiment — baseline established";
|
|
862
888
|
|
|
889
|
+
const keptCount = experiments.filter((e) => e.kept).length;
|
|
890
|
+
const revertedCount = experiments.filter((e) => !e.kept).length;
|
|
891
|
+
const statusIcon = args.kept ? "\x1b[32m✔ KEPT\x1b[0m" : "\x1b[31m✘ REVERTED\x1b[0m";
|
|
892
|
+
const delta =
|
|
893
|
+
prev != null && typeof args.metric === "number"
|
|
894
|
+
? ` (${args.metric > prev ? "+" : ""}${(args.metric - prev).toFixed(1)} pts)`
|
|
895
|
+
: "";
|
|
896
|
+
console.log(
|
|
897
|
+
`\n\x1b[1m── Experiment #${entry.id} ${statusIcon}\x1b[0m score: ${args.metric}${delta} │ total: ${experiments.length} kept: ${keptCount} reverted: ${revertedCount}`,
|
|
898
|
+
);
|
|
899
|
+
if (args.description) console.log(` ${args.description}`);
|
|
900
|
+
|
|
863
901
|
return JSON.stringify({
|
|
864
902
|
status: "logged",
|
|
865
903
|
experiment_number: entry.id,
|
|
866
904
|
total_experiments: experiments.length,
|
|
867
|
-
kept_count:
|
|
868
|
-
reverted_count:
|
|
905
|
+
kept_count: keptCount,
|
|
906
|
+
reverted_count: revertedCount,
|
|
869
907
|
crash_count: experiments.filter((e) => e.status === "crash").length,
|
|
870
908
|
trend,
|
|
871
909
|
});
|
|
@@ -938,6 +976,11 @@ Use ar_run_experiment with output_file to redirect, then ar_extract_metric to re
|
|
|
938
976
|
// Reset read guards — files changed after revert, agent needs fresh access
|
|
939
977
|
resetReadGuards();
|
|
940
978
|
|
|
979
|
+
const expNum = experiments.length + 1;
|
|
980
|
+
console.log(
|
|
981
|
+
`\x1b[33m ↩ Reverted\x1b[0m ${currentHash.slice(0, 7)} → ${newHash.slice(0, 7)}${args.reason ? ` (${args.reason})` : ""}`,
|
|
982
|
+
);
|
|
983
|
+
|
|
941
984
|
return JSON.stringify({
|
|
942
985
|
status: "reverted",
|
|
943
986
|
method: "reset",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nex-code",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.36",
|
|
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"
|