nex-code 0.3.10 → 0.3.11
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/package.json +1 -1
package/dist/nex-code.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var O=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Wt=O((am,ma)=>{ma.exports={name:"nex-code",version:"0.3.
|
|
2
|
+
var O=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Wt=O((am,ma)=>{ma.exports={name:"nex-code",version:"0.3.11",description:"Nex Code \u2014 Agentic Coding CLI with Multi-Provider Support",bin:{"nex-code":"./dist/nex-code.js"},files:["dist/","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",test:"jest --coverage","test:watch":"jest --watch",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",release:"npm version patch && git push --follow-tags && npm publish"},keywords:["cli","coding","agent","ai","llm","multi-provider","openai","anthropic","gemini","google","ollama"],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"}}});var to=O((cm,eo)=>{var N={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",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",brightCyan:"\x1B[96m",brightMagenta:"\x1B[95m",brightBlue:"\x1B[94m"},Xn=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],Qn=["\u273D","\u2726","\u2727","\u2726"],Ms=class{constructor(e="Thinking..."){this.text=e,this.frame=0,this.interval=null,this.startTime=null}_render(){if(this._stopped)return;let e=Xn[this.frame%Xn.length],s="";if(this.startTime){let n=Math.floor((Date.now()-this.startTime)/1e3);if(n>=60){let o=Math.floor(n/60),r=n%60;s=` ${N.dim}${o}m ${String(r).padStart(2,"0")}s${N.reset}`}else n>=1&&(s=` ${N.dim}${n}s${N.reset}`)}process.stderr.write(`\x1B[2K\r${N.cyan}${e}${N.reset} ${N.dim}${this.text}${N.reset}${s}`),this.frame++}start(){this._stopped=!1,this.startTime=Date.now(),process.stderr.write("\x1B[?25l"),this._render(),this.interval=setInterval(()=>this._render(),80)}update(e){this.text=e}stop(){this._stopped=!0,this.interval&&(clearInterval(this.interval),this.interval=null),process.stderr.write("\x1B[2K\r\x1B[?25h"),this.startTime=null}},Zn=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],Rs=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=Zn[this.frame%Zn.length],s=this._formatElapsed(),n=s?` ${N.dim}${s}${N.reset}`:"",o="";for(let r=0;r<this.labels.length;r++){let i,c;switch(this.statuses[r]){case"done":i=`${N.green}\u2713${N.reset}`,c=N.dim;break;case"error":i=`${N.red}\u2717${N.reset}`,c=N.dim;break;default:i=`${N.cyan}${e}${N.reset}`,c=""}let l=r===this.labels.length-1?n:"";o+=`\x1B[2K ${i} ${c}${this.labels[r]}${N.reset}${l}
|
|
3
3
|
`}this.lineCount>0&&(o+=`\x1B[${this.lineCount}A`),process.stderr.write(o),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(),80)}update(e,s){e>=0&&e<this.statuses.length&&(this.statuses[e]=s)}stop(){this._stopped=!0,this.interval&&(clearInterval(this.interval),this.interval=null),this._renderFinal(),process.stderr.write("\x1B[?25h")}_renderFinal(){let e=this._formatElapsed(),s=e?` ${N.dim}${e}${N.reset}`:"",n="";for(let o=0;o<this.labels.length;o++){let r;switch(this.statuses[o]){case"done":r=`${N.green}\u2713${N.reset}`;break;case"error":r=`${N.red}\u2717${N.reset}`;break;default:r=`${N.yellow}\u25CB${N.reset}`}let i=o===this.labels.length-1?s:"";n+=`\x1B[2K ${r} ${N.dim}${this.labels[o]}${N.reset}${i}
|
|
5
5
|
`}process.stderr.write(n)}},Bt={done:"\u2714",in_progress:"\u25FC",pending:"\u25FB",failed:"\u2717"},Ht={done:N.green,in_progress:N.cyan,pending:N.dim,failed:N.red},Me=null,Ns=class{constructor(e,s){this.name=e,this.tasks=s.map(n=>({id:n.id,description:n.description,status:n.status||"pending"})),this.frame=0,this.interval=null,this.startTime=null,this.tokens=0,this.lineCount=1+this.tasks.length,this._paused=!1}_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`}_formatTokens(){return this.tokens<=0?"":this.tokens>=1e3?`${(this.tokens/1e3).toFixed(1)}k`:String(this.tokens)}_render(){if(this._stopped)return;let e=Qn[this.frame%Qn.length],s=this._formatElapsed(),n=this._formatTokens(),o=[s,n?`\u2193 ${n} tokens`:""].filter(Boolean).join(" \xB7 "),r=o?` ${N.dim}(${o})${N.reset}`:"",i=`\x1B[2K${N.cyan}${e}${N.reset} ${this.name}\u2026${r}
|
|
@@ -35,7 +35,7 @@ Be factual and brief. Use bullet points. Max 300 words.`;async function Ka(t){if
|
|
|
35
35
|
${n}`,_compacted:!0,_originalCount:t.length},tokensRemoved:o-r}}catch{return null}}function yo(t){return t.map(e=>{let s=e.role==="tool"?"tool_result":e.role,n=(e.content||"").substring(0,500);if(e.tool_calls){let o=e.tool_calls.map(r=>r.function?.name).join(", ");return`[${s}] ${n}
|
|
36
36
|
tools: ${o}`}return`[${s}] ${n}`}).join(`
|
|
37
37
|
|
|
38
|
-
`)}bo.exports={compactMessages:Ka,formatMessagesForSummary:yo,COMPACTION_ENABLED:ho,COMPACTION_MIN_MESSAGES:go,COMPACTION_SUMMARY_BUDGET:$o}});var ke=O((hm,Ao)=>{
|
|
38
|
+
`)}bo.exports={compactMessages:Ka,formatMessagesForSummary:yo,COMPACTION_ENABLED:ho,COMPACTION_MIN_MESSAGES:go,COMPACTION_SUMMARY_BUDGET:$o}});var ke=O((hm,Ao)=>{function _o(){return ce().getActiveModel()}var za={anthropic:3.5,openai:4,gemini:4,ollama:4,local:4},wt=new Map,xo=1e3,zt=new WeakMap,et=new Map,ko=500,xt=null;function Ga(){if(xt!==null)return xt;try{let e=_o()?.provider||"ollama";return xt=za[e]||4,xt}catch{return 4}}function Ja(){xt=null}function De(t){if(!t)return 0;typeof t!="string"&&(t=JSON.stringify(t));let e=t.length<=80?t:`${t.length}:${t.substring(0,60)}:${t.substring(t.length-20)}`,s=wt.get(e);if(s!==void 0)return s;let n=Math.ceil(t.length/Ga());if(wt.size>=xo){let o=xo>>1,r=wt.keys();for(let i=0;i<o;i++)wt.delete(r.next().value)}return wt.set(e,n),n}function Va(t){if(zt.has(t))return zt.get(t);let e=vo(t);if(et.has(e)){let n=et.get(e);return zt.set(t,n),n}let s=JSON.stringify(t);if(et.size>=ko){let n=ko>>1,o=et.keys();for(let r=0;r<n;r++)et.delete(o.next().value)}return et.set(e,s),zt.set(t,s),s}function vo(t){let e=t.role||"",s=typeof t.content=="string"?t.content.substring(0,100):"",n=t.tool_calls?t.tool_calls.length:0;return`${e}:${s.length}:${n}`}function tt(t){let s=4;if(t.content&&(s+=De(t.content)),t.tool_calls)for(let n of t.tool_calls){s+=4,s+=De(n.function?.name||"");let o=n.function?.arguments;typeof o=="string"?s+=De(o):o&&(s+=De(JSON.stringify(o)))}return s}function he(t){let e=0;for(let s of t)e+=tt(s);return e}function Ya(t,e){if(t&&t.length===e.length){let r=!1;for(let i=0;i<e.length;i++)if(t[i]!==e[i]){r=!0;break}if(!r)return 0}let s=t?t.length:0,n=e.length,o=0;for(let r=s;r<n;r++)o+=tt(e[r]);return o}function Gt(t){return!t||t.length===0?0:De(JSON.stringify(t))}function Jt(){return _o()?.contextWindow||32768}function Xa(t,e){let s=he(t),n=Gt(e),o=s+n,r=Jt(),i=r>0?o/r*100:0,c=0,l=0,u=0;for(let d of t){let f=tt(d);d.role==="system"?c+=f:d.role==="tool"?u+=f:l+=f}return{used:o,limit:r,percentage:Math.round(i*10)/10,breakdown:{system:c,conversation:l,toolResults:u,toolDefinitions:n},messageCount:t.length}}var So=.75,To=.1,Co=10,Qa=200,Za=500;function Eo(t,e){if(!t||t.length<=e)return t;let n=/^(ERROR|EXIT|BLOCKED|CANCELLED)/i.test(t)?e*3:e;if(t.length<=n)return t;let o=t.split(`
|
|
39
39
|
`);if(o.length<=10){let g=Math.floor(n*.6),x=Math.floor(n*.4),b=t.substring(0,g),y=t.substring(t.length-x);return b+`
|
|
40
40
|
...(${t.length} chars total)...
|
|
41
41
|
`+y}let r=Math.floor(o.length*.4),i=Math.floor(o.length*.4),c=[],l=0,u=Math.floor(n*.4);for(let g=0;g<r&&l<u;g++)c.push(o[g]),l+=o[g].length+1;let d=[],f=0,m=Math.floor(n*.4);for(let g=o.length-1;g>=o.length-i&&f<m;g--)d.unshift(o[g]),f+=o[g].length+1;let p=o.length-c.length-d.length;return c.join(`
|