nex-code 0.4.28 → 0.4.29
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/nex-code.js +2 -2
- package/dist/skills/autoresearch.js +2 -0
- package/package.json +1 -1
package/dist/nex-code.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var Q=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var As=Q((pT,E$)=>{E$.exports={name:"nex-code",version:"0.4.
|
|
2
|
+
var Q=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var As=Q((pT,E$)=>{E$.exports={name:"nex-code",version:"0.4.29",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 && 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 Yn=Q((mT,Nu)=>{"use strict";var Eu="\x1B[0m",Tu="\x1B[1m",Os="\x1B[2m";function Z(t,e,n){return`\x1B[38;2;${t};${e};${n}m`}function T$(){if(!process.stdout.isTTY)return null;try{let{execFileSync:t}=require("child_process"),e=["import sys,os,tty,termios,select","f=open('/dev/tty','r+b',buffering=0)","fd=f.fileno()","s=termios.tcgetattr(fd)","try:"," tty.setraw(fd)"," f.write(bytes([0x1b,0x5d,0x31,0x31,0x3b,0x3f,0x1b,0x5c]))"," r=select.select([fd],[],[],0.1)[0]"," d=b''"," if r:"," while True:"," r2=select.select([fd],[],[],0.05)[0]"," if not r2:break"," c=os.read(fd,1)"," d+=c"," if d[-1:]==bytes([0x07]) or d[-2:]==bytes([0x1b,0x5c]):break"," sys.stdout.buffer.write(d)","finally:"," termios.tcsetattr(fd,termios.TCSADRAIN,s)"," f.close()"].join(`
|
|
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 Ru(){let t=require("os");return require("path").join(t.homedir(),".nex-code",".theme_cache.json")}function R$(t){try{let n=require("fs").readFileSync(Ru(),"utf8"),o=JSON.parse(n);if(o&&typeof o[t]=="boolean")return o[t]}catch{}return null}function C$(t,e){try{let n=require("fs"),o=require("path"),s=Ru(),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 A$(){let t=(process.env.NEX_THEME||"").toLowerCase();if(t==="light")return!1;if(t==="dark")return!0;let e=process.env.COLORFGBG;if(e){let i=e.split(";"),c=parseInt(i[i.length-1],10);if(!isNaN(c))return c<8}let n=process.env.TERM_SESSION_ID||"default",o=R$(n);if(o!==null)return o;let s=T$(),r=s!==null?s:!0;return C$(n,r),r}var Cu=A$(),Au={reset:Eu,bold:Tu,dim:Os,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:Os,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:Os,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:Os,banner_model:Os,banner_yolo:Z(245,175,50),footer_sep:Os,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:"\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"},Ou={reset:Eu,bold:Tu,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),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[41m",bgGreen:"\x1B[42m",diff_add_bg:"\x1B[48;2;215;245;220m",diff_rem_bg:"\x1B[48;2;255;215;215m",brightCyan:Z(0,158,182),brightMagenta:Z(158,52,208),brightBlue:Z(0,112,208)},O$=Cu?Au:Ou;Nu.exports={T:O$,isDark:Cu,DARK:Au,LIGHT:Ou}});var Ms=Q((hT,Pu)=>{var{T:ne}=Yn(),Lr=5,Ns=(()=>{let t=[];for(let e=0;e<Lr;e++)t.push(e);for(let e=Lr-2;e>=1;e--)t.push(e);return t})(),Mu=["\u273D","\u2726","\u2727","\u2726"],Ca=class{constructor(e="Thinking..."){this.text=e,this.frame=0,this.interval=null,this.startTime=null}_render(){if(this._stopped)return;let e=Ns[this.frame%Ns.length],n="";for(let s=0;s<Lr;s++)n+=s===e?`${ne.cyan}\u25CF${ne.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=` ${ne.dim}${r}m ${String(i).padStart(2,"0")}s${ne.reset}`}else s>=1&&(o=` ${ne.dim}${s}s${ne.reset}`)}process.stderr.write(`\x1B[2K\r${n} ${ne.dim}${this.text}${ne.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}},Aa=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=Ns[this.frame%Ns.length],n=`${ne.cyan}\u25CF${ne.reset}`,o=this._formatElapsed(),s=o?` ${ne.dim}${o}${ne.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=`${ne.green}\u2713${ne.reset}`,u=ne.dim;break;case"error":l=`${ne.red}\u2717${ne.reset}`,u=ne.dim;break;case"retry":l=`${ne.yellow}\u21BB${ne.reset}`,u=ne.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}${ne.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
|
|
@@ -1178,7 +1178,7 @@ Continue implementing the fixes based on these findings.`};G.push(ce)}if(cr>=3){
|
|
|
1178
1178
|
Files modified so far: ${[...A].map(He=>He.split("/").slice(-1)[0]).join(", ")}`:"";W(`${$.red} \u2717 Super-nuclear limit reached (3\xD7) \u2014 aborting to prevent runaway context loop${$.reset}`),console.log(`${$.yellow} \u{1F4A1} Task may exceed model context. Try /clear and break it into smaller steps.${ce?$.dim+ce:""}${$.reset}`),u&&(u.stop(),u=null),l(null),Qe(x,E,A,T,L,{suppressHint:!0}),Ze(H);break}R=G,cr++,ws=12+Math.min(_e*3,15),bl=!0,Ji=A.size,Vi=!1,Ut=0,j=0;for(let[ce,He]of xs){let lt=He?.count??He??0;Rh(xs,ce,lt>=2?lt:1)}for(let[ce]of Dn)gs(xs,ce)<2&&Dn.delete(ce);ys.clear(),vs.clear(),Bt&&en>0&&(Qt=!0,W(`${$.cyan} \u26A1 Post-wipe creation guard: cap pre-fired (${en} edits already made)${$.reset}`));for(let[ce]of pr)Rh(pr,ce,pu-1);if(so(`Super-nuclear compression \u2014 dropped all history, keeping original task only (${Y-U} tokens freed)`,$.yellow),cr>=1){let ce=[...xs.entries()].filter(([,Tt])=>Tt>=ho).map(([Tt])=>Tt.split("/").slice(-1)[0]),He=ce.length>0?`
|
|
1179
1179
|
|
|
1180
1180
|
Files already at read cap \u2014 use grep_search instead: ${ce.join(", ")}`:"",Kt={role:"user",content:Mt&&!ot?"[SYSTEM] Context was compressed. SSH is currently unavailable \u2014 do not read more local files. Summarize what you found and ask the user for the server output you need.":`[SYSTEM] Context was compressed. Use the findings above to implement your fix. If you need to re-read a file, use line_start/line_end for the specific section.${He}`};H.push(Kt),R.push(Kt)}pe=0,Ve--;continue}}b="Context too large to compress \u2014 use /clear to start fresh"}else _.message.includes("500")||_.message.includes("502")||_.message.includes("503")||_.message.includes("504")?b="API server error \u2014 the provider is experiencing issues. Please try again in a moment":(_.message.includes("fetch failed")||_.message.includes("fetch"))&&(b="Network request failed \u2014 please check your internet connection");if(console.log(`${$.red} \u2717 ${b}${$.reset}`),_.message.includes("429")){if(ye++,ye>cl){console.log(`${$.red} Rate limit: max retries (${cl}) exceeded. Try again later or use /budget to check your limits.${$.reset}`),u&&(u.stop(),u=null),l(null),Qe(x,E,A,T,L),Ze(H);break}let F=Math.min(1e4*Math.pow(2,ye-1),12e4),ae=new oo(`Rate limit \u2014 waiting ${Math.round(F/1e3)}s (retry ${ye}/${cl})`);ae.start(),await new Promise(G=>setTimeout(G,F)),ae.stop();continue}let re=process.env.NEX_PHASE_ROUTING!=="0"&&(()=>{try{return je().getActiveProviderName()==="ollama"}catch{return!1}})();if(_.message.includes("socket disconnected")||_.message.includes("TLS")||_.message.includes("ECONNRESET")||_.message.includes("ECONNABORTED")||_.message.includes("ETIMEDOUT")||re&&(_.message.includes("500")||_.message.includes("502")||_.message.includes("503")||_.message.includes("504")||_.message.includes("401")||_.message.includes("Unauthorized"))||_.code==="ECONNRESET"||_.code==="ECONNABORTED"){if(be++,be>ll){console.log(`${$.red} Network error: max retries (${ll}) exceeded. Check your connection and try again.
|
|
1181
|
-
Use /undo to revert changes made during this session.${$.reset}`),u&&(u.stop(),u=null),l(null),Qe(x,E,A,T,L),Ze(H);break}let F=Math.min(2e3*Math.pow(2,be-1),3e4),ae=new oo(`API temporarily unavailable \u2014 retrying in ${Math.round(F/1e3)}s (${be}/${ll}). Your changes are safe.`);ae.start(),await new Promise(G=>setTimeout(G,F)),ae.stop(),Ve--;continue}u&&(u.stop(),u=null),l(null),Qe(x,E,A,T,L),Ze(H);break}if(clearInterval($u),ye=0,be=0,Es&&(u&&!u._paused&&u.pause(),qe&&qe.stop()),hn&&(clearTimeout(hn),hn=null),jt&&ct&&(ct.push(jt),jt=""),Et&&ct.flush(),be=0,fe=0,on&&on.usage){let _=on.usage.prompt_tokens||0,b=on.usage.completion_tokens||0;bh(ro(),pn(),_,b),d+=_+b,u&&u.setStats({tokens:d})}else if(on&&!on.usage){let _=R.map(I=>typeof I.content=="string"?I.content:Array.isArray(I.content)?I.content.map(F=>typeof F=="string"?F:F.text||"").join(""):"").join(" "),b=xh(_),re=xh(on.content||Et||"");bh(ro(),pn(),b,re),d+=b+re,u&&u.setStats({tokens:d})}let{content:yu,tool_calls:gn}=on,Cr=hl(yu||""),wu=Cr.truncated?Cr.text:yu;Cr.truncated&&W(`${$.yellow} \u26A0 LLM output loop detected (${Cr.repeatCount}\xD7 repeated paragraph) \u2014 response truncated${$.reset}`);let Ar=_k(wu||""),rn=Ar.truncated?Ar.text:wu;Ar.truncated&&W(`${$.yellow} \u26A0 LLM output loop detected (${Ar.repeatCount}\xD7 repeated window) \u2014 response truncated${$.reset}`);let Ta={role:"assistant",content:rn||""};if(gn&&gn.length>0&&(Ta.tool_calls=gn),H.push(Ta),R.push(Ta),!ot&&rn&&gn&&gn.length>0){let _=fl(rn);if(_){ot=!0,kt=_.slice(0,120),fn=0,Qt=!1,vn=0,W(`${$.yellow} \u26A1 Root cause in model analysis: ${kt} \u2014 fix phase (read budget: 3)${$.reset}`);let b={role:"user",content:`[SYSTEM] Root cause identified: ${kt}. Read only the file that needs fixing, then edit it. Do not read other files.`};H.push(b),R.push(b)}}if(!gn||gn.length===0){let _=(rn||"").trim().length>0||Et.trim().length>0,b=!1;if(Mt&&_&&(Hi>=2?W(`${$.yellow} \u26A0 SSH permanently blocked after ${Hi} storm warnings \u2014 no further SSH calls allowed${$.reset}`):(Mt=!1,Ut=go-4,b=!0)),b&&_){let I=(rn||"").trim();if(I.endsWith("?")||/\b(Wo |Bitte |Kannst du|Soll ich)\b/.test(I.slice(-200))){let ae={role:"user",content:"[SYSTEM] Continue. Do not ask questions \u2014 implement the fix yourself using SSH. The server is at 94.130.37.43."};R.push(ae),H.push(ae);continue}}if(!_&&x>0&&Ve<gl-1){let I={role:"user",content:"[SYSTEM] You ran tools but produced no visible output. The user CANNOT see tool results \u2014 only your text. Please summarize your findings now."};R.push(I),H.push(I);continue}let re=/keine.*Tool|can.?t use.*tool|Tool.?Budget|nicht.*zugreifen|cannot.*access|no.*tool.*access|keine.*Werkzeug|da ich keine.*kann/i;if(_&&Ve<3&&re.test((rn||"").slice(0,600)))if(bl&&ws<=0||Mt){W(`${$.yellow} \u26A0 Tool avoidance (constrained context) \u2014 telling model to ask user${$.reset}`);let F={role:"user",content:"[SYSTEM] Correct \u2014 remote access is currently limited. Summarize what you have found so far and tell the user exactly what specific information (logs, process list, error output) you need from the server to continue."};R.push(F),H.push(F);continue}else{W(`${$.yellow} \u26A0 Tool avoidance detected \u2014 nudging model to use tools${$.reset}`);let F={role:"user",content:"[SYSTEM] You have full tool access. Use your tools to investigate and implement the fix directly \u2014 do not say you cannot use tools. If SSH is needed, use a single targeted command that captures the most relevant information rather than multiple sequential calls."};R.push(F),H.push(F);continue}if(n.skillLoop&&_&&x>3&&
|
|
1181
|
+
Use /undo to revert changes made during this session.${$.reset}`),u&&(u.stop(),u=null),l(null),Qe(x,E,A,T,L),Ze(H);break}let F=Math.min(2e3*Math.pow(2,be-1),3e4),ae=new oo(`API temporarily unavailable \u2014 retrying in ${Math.round(F/1e3)}s (${be}/${ll}). Your changes are safe.`);ae.start(),await new Promise(G=>setTimeout(G,F)),ae.stop(),Ve--;continue}u&&(u.stop(),u=null),l(null),Qe(x,E,A,T,L),Ze(H);break}if(clearInterval($u),ye=0,be=0,Es&&(u&&!u._paused&&u.pause(),qe&&qe.stop()),hn&&(clearTimeout(hn),hn=null),jt&&ct&&(ct.push(jt),jt=""),Et&&ct.flush(),be=0,fe=0,on&&on.usage){let _=on.usage.prompt_tokens||0,b=on.usage.completion_tokens||0;bh(ro(),pn(),_,b),d+=_+b,u&&u.setStats({tokens:d})}else if(on&&!on.usage){let _=R.map(I=>typeof I.content=="string"?I.content:Array.isArray(I.content)?I.content.map(F=>typeof F=="string"?F:F.text||"").join(""):"").join(" "),b=xh(_),re=xh(on.content||Et||"");bh(ro(),pn(),b,re),d+=b+re,u&&u.setStats({tokens:d})}let{content:yu,tool_calls:gn}=on,Cr=hl(yu||""),wu=Cr.truncated?Cr.text:yu;Cr.truncated&&W(`${$.yellow} \u26A0 LLM output loop detected (${Cr.repeatCount}\xD7 repeated paragraph) \u2014 response truncated${$.reset}`);let Ar=_k(wu||""),rn=Ar.truncated?Ar.text:wu;Ar.truncated&&W(`${$.yellow} \u26A0 LLM output loop detected (${Ar.repeatCount}\xD7 repeated window) \u2014 response truncated${$.reset}`);let Ta={role:"assistant",content:rn||""};if(gn&&gn.length>0&&(Ta.tool_calls=gn),H.push(Ta),R.push(Ta),!ot&&rn&&gn&&gn.length>0){let _=fl(rn);if(_){ot=!0,kt=_.slice(0,120),fn=0,Qt=!1,vn=0,W(`${$.yellow} \u26A1 Root cause in model analysis: ${kt} \u2014 fix phase (read budget: 3)${$.reset}`);let b={role:"user",content:`[SYSTEM] Root cause identified: ${kt}. Read only the file that needs fixing, then edit it. Do not read other files.`};H.push(b),R.push(b)}}if(!gn||gn.length===0){let _=(rn||"").trim().length>0||Et.trim().length>0,b=!1;if(Mt&&_&&(Hi>=2?W(`${$.yellow} \u26A0 SSH permanently blocked after ${Hi} storm warnings \u2014 no further SSH calls allowed${$.reset}`):(Mt=!1,Ut=go-4,b=!0)),b&&_){let I=(rn||"").trim();if(I.endsWith("?")||/\b(Wo |Bitte |Kannst du|Soll ich)\b/.test(I.slice(-200))){let ae={role:"user",content:"[SYSTEM] Continue. Do not ask questions \u2014 implement the fix yourself using SSH. The server is at 94.130.37.43."};R.push(ae),H.push(ae);continue}}if(!_&&x>0&&Ve<gl-1){let I={role:"user",content:"[SYSTEM] You ran tools but produced no visible output. The user CANNOT see tool results \u2014 only your text. Please summarize your findings now."};R.push(I),H.push(I);continue}let re=/keine.*Tool|can.?t use.*tool|Tool.?Budget|nicht.*zugreifen|cannot.*access|no.*tool.*access|keine.*Werkzeug|da ich keine.*kann/i;if(_&&Ve<3&&re.test((rn||"").slice(0,600)))if(bl&&ws<=0||Mt){W(`${$.yellow} \u26A0 Tool avoidance (constrained context) \u2014 telling model to ask user${$.reset}`);let F={role:"user",content:"[SYSTEM] Correct \u2014 remote access is currently limited. Summarize what you have found so far and tell the user exactly what specific information (logs, process list, error output) you need from the server to continue."};R.push(F),H.push(F);continue}else{W(`${$.yellow} \u26A0 Tool avoidance detected \u2014 nudging model to use tools${$.reset}`);let F={role:"user",content:"[SYSTEM] You have full tool access. Use your tools to investigate and implement the fix directly \u2014 do not say you cannot use tools. If SSH is needed, use a single targeted command that captures the most relevant information rather than multiple sequential calls."};R.push(F),H.push(F);continue}if(n.skillLoop&&_&&x>3&&Tr<5){let I=(rn||Et||"").toLowerCase();if(/\b(i.ll stop|stop the|stopped|done with|complet|summar|conclud|no more|finish|end of|that.s all|final|wrapped up|no further|mindful of)/.test(I.slice(-600))){Tr=(Tr||0)+1,W(`${$.yellow} \u26A0 Skill loop: model tried to stop \u2014 continuation nudge #${Tr}${$.reset}`);let ae={role:"user",content:"[SYSTEM] Do NOT stop. You are in an autonomous experiment loop. The user is away and expects you to keep running experiments indefinitely until they interrupt with Ctrl+C. Start the next experiment NOW: hypothesize a new change, checkpoint, edit, run, measure, keep or revert. Think harder \u2014 try a completely different optimization approach."};R.push(ae),H.push(ae);continue}}if(Te&&Xe==="plan"&&qn>=2){W(`${$.cyan} \u21B3 Plan phase: ${qn} consecutive blocks \u2014 auto-advancing to implement${$.reset}`),qn=0;let I=rr("implement","[auto-advance: task only requires direct action]");if(I){H.push(I),R.push(I),Ve=0,sn=hs("implement");continue}}if(Te&&_){let I=(rn||Et||"").trim();if(Xe==="plan"){let F=rr("implement",I);if(F){H.push(F),R.push(F),Ve=0,sn=hs("implement");continue}}else if(Xe==="implement"&&A.size>0){let F=H.find(we=>we.role==="user"),ae=typeof F?.content=="string"?F.content:"",G=rr("verify",I,A,ae);if(G){H.push(G),R.push(G),Ve=0,sn=Math.min(hs("verify")+Math.max(0,(A.size-2)*2),20);continue}}else if(Xe==="verify"){let ae=/\bFAIL\b|test.*fail|error|broken|missing|incorrect/i.test(I.slice(0,500));if(ae&&dr<1){dr++;let G={role:"user",content:`[PHASE: RE-IMPLEMENTATION] Verification found issues:
|
|
1182
1182
|
${I.slice(0,400)}
|
|
1183
1183
|
|
|
1184
1184
|
Fix the identified issues. This is the final attempt.`};Xe="implement",kn=ml("implement",ao),H.push(G),R.push(G),Ve=0,sn=hs("implement"),W(`${$.yellow} \u21B3 Verify \u2192 implement loop-back #${dr} (issues found)${$.reset}`);continue}W(`${$.green} \u2713 Verification phase complete${ae?" (loop-back exhausted)":" (PASS)"}${$.reset}`)}}if(fr()&&_&&x===0)if(Yi++,Yi>2)W(`${$.yellow} \u26A0 Plan accepted despite no file reads (rejection loop cap reached)${$.reset}`);else{let I={role:"user",content:`[SYSTEM] You wrote a plan without reading any files. This plan may be based on incorrect assumptions (wrong database type, wrong file structure, etc.).
|
|
@@ -151,6 +151,8 @@ You are a researcher running rapid experiments, NOT a code reviewer.
|
|
|
151
151
|
- **Max 3 reads before editing**: if you have read 3 files/ranges without making an edit, STOP reading and make a change based on what you know
|
|
152
152
|
- **Each experiment should take under 2 minutes**: read one file, edit it, measure, log, move on
|
|
153
153
|
- **Prefer bash for metrics**: use bash commands (wc -c, time, du) for measurements — they are fast and don't consume context
|
|
154
|
+
- **Use write_file for small files**: if a file is under 50 lines, use write_file to rewrite it entirely instead of struggling with edit_file old_text matching. This is faster and avoids repeated edit failures on minified/single-line code
|
|
155
|
+
- **If edit_file fails once, switch to write_file immediately** — do not retry edit_file more than once on the same file
|
|
154
156
|
|
|
155
157
|
## Simplicity Criterion
|
|
156
158
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nex-code",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.29",
|
|
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"
|