@negoziator/ai-commit 2.33.8 → 2.34.1

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.
@@ -1,12 +0,0 @@
1
- var ue=Object.defineProperty;var r=(g,o)=>ue(g,"name",{value:o,configurable:!0});import{g as ce}from"./cli-CLrzwExP.mjs";import ae from"net";import le from"tls";import fe from"url";import de from"assert";import G from"tty";import pe from"util";import he from"os";import Ce from"events";var P={},M={exports:{}},D={exports:{}},j,z;function me(){if(z)return j;z=1;var g=1e3,o=g*60,l=o*60,t=l*24,f=t*7,w=t*365.25;j=r(function(c,n){n=n||{};var e=typeof c;if(e==="string"&&c.length>0)return b(c);if(e==="number"&&isFinite(c))return n.long?i(c):v(c);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(c))},"ms");function b(c){if(c=String(c),!(c.length>100)){var n=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(c);if(n){var e=parseFloat(n[1]),a=(n[2]||"ms").toLowerCase();switch(a){case"years":case"year":case"yrs":case"yr":case"y":return e*w;case"weeks":case"week":case"w":return e*f;case"days":case"day":case"d":return e*t;case"hours":case"hour":case"hrs":case"hr":case"h":return e*l;case"minutes":case"minute":case"mins":case"min":case"m":return e*o;case"seconds":case"second":case"secs":case"sec":case"s":return e*g;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:return}}}}r(b,"parse");function v(c){var n=Math.abs(c);return n>=t?Math.round(c/t)+"d":n>=l?Math.round(c/l)+"h":n>=o?Math.round(c/o)+"m":n>=g?Math.round(c/g)+"s":c+"ms"}r(v,"fmtShort");function i(c){var n=Math.abs(c);return n>=t?p(c,n,t,"day"):n>=l?p(c,n,l,"hour"):n>=o?p(c,n,o,"minute"):n>=g?p(c,n,g,"second"):c+" ms"}r(i,"fmtLong");function p(c,n,e,a){var s=n>=e*1.5;return Math.round(c/e)+" "+a+(s?"s":"")}return r(p,"plural"),j}r(me,"requireMs");var B,V;function Y(){if(V)return B;V=1;function g(o){t.debug=t,t.default=t,t.coerce=p,t.disable=v,t.enable=w,t.enabled=i,t.humanize=me(),t.destroy=c,Object.keys(o).forEach(n=>{t[n]=o[n]}),t.names=[],t.skips=[],t.formatters={};function l(n){let e=0;for(let a=0;a<n.length;a++)e=(e<<5)-e+n.charCodeAt(a),e|=0;return t.colors[Math.abs(e)%t.colors.length]}r(l,"selectColor"),t.selectColor=l;function t(n){let e,a=null,s,h;function u(...m){if(!u.enabled)return;const C=u,d=Number(new Date),x=d-(e||d);C.diff=x,C.prev=e,C.curr=d,e=d,m[0]=t.coerce(m[0]),typeof m[0]!="string"&&m.unshift("%O");let F=0;m[0]=m[0].replace(/%([a-zA-Z%])/g,(E,T)=>{if(E==="%%")return"%";F++;const O=t.formatters[T];if(typeof O=="function"){const _=m[F];E=O.call(C,_),m.splice(F,1),F--}return E}),t.formatArgs.call(C,m),(C.log||t.log).apply(C,m)}return r(u,"debug"),u.namespace=n,u.useColors=t.useColors(),u.color=t.selectColor(n),u.extend=f,u.destroy=t.destroy,Object.defineProperty(u,"enabled",{enumerable:!0,configurable:!1,get:r(()=>a!==null?a:(s!==t.namespaces&&(s=t.namespaces,h=t.enabled(n)),h),"get"),set:r(m=>{a=m},"set")}),typeof t.init=="function"&&t.init(u),u}r(t,"createDebug");function f(n,e){const a=t(this.namespace+(typeof e>"u"?":":e)+n);return a.log=this.log,a}r(f,"extend");function w(n){t.save(n),t.namespaces=n,t.names=[],t.skips=[];const e=(typeof n=="string"?n:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const a of e)a[0]==="-"?t.skips.push(a.slice(1)):t.names.push(a)}r(w,"enable");function b(n,e){let a=0,s=0,h=-1,u=0;for(;a<n.length;)if(s<e.length&&(e[s]===n[a]||e[s]==="*"))e[s]==="*"?(h=s,u=a,s++):(a++,s++);else if(h!==-1)s=h+1,u++,a=u;else return!1;for(;s<e.length&&e[s]==="*";)s++;return s===e.length}r(b,"matchesTemplate");function v(){const n=[...t.names,...t.skips.map(e=>"-"+e)].join(",");return t.enable(""),n}r(v,"disable");function i(n){for(const e of t.skips)if(b(n,e))return!1;for(const e of t.names)if(b(n,e))return!0;return!1}r(i,"enabled");function p(n){return n instanceof Error?n.stack||n.message:n}r(p,"coerce");function c(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r(c,"destroy"),t.enable(t.load()),t}return r(g,"setup"),B=g,B}r(Y,"requireCommon");var J;function ge(){return J||(J=1,(function(g,o){o.formatArgs=t,o.save=f,o.load=w,o.useColors=l,o.storage=b(),o.destroy=(()=>{let i=!1;return()=>{i||(i=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),o.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function l(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let i;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(i=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(i[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}r(l,"useColors");function t(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+g.exports.humanize(this.diff),!this.useColors)return;const p="color: "+this.color;i.splice(1,0,p,"color: inherit");let c=0,n=0;i[0].replace(/%[a-zA-Z%]/g,e=>{e!=="%%"&&(c++,e==="%c"&&(n=c))}),i.splice(n,0,p)}r(t,"formatArgs"),o.log=console.debug||console.log||(()=>{});function f(i){try{i?o.storage.setItem("debug",i):o.storage.removeItem("debug")}catch{}}r(f,"save");function w(){let i;try{i=o.storage.getItem("debug")||o.storage.getItem("DEBUG")}catch{}return!i&&typeof process<"u"&&"env"in process&&(i=process.env.DEBUG),i}r(w,"load");function b(){try{return localStorage}catch{}}r(b,"localstorage"),g.exports=Y()(o);const{formatters:v}=g.exports;v.j=function(i){try{return JSON.stringify(i)}catch(p){return"[UnexpectedJSONParseError]: "+p.message}}})(D,D.exports)),D.exports}r(ge,"requireBrowser");var L={exports:{}},N,W;function ye(){return W||(W=1,N=r((g,o=process.argv)=>{const l=g.startsWith("-")?"":g.length===1?"-":"--",t=o.indexOf(l+g),f=o.indexOf("--");return t!==-1&&(f===-1||t<f)},"hasFlag")),N}r(ye,"requireHasFlag");var $,K;function be(){if(K)return $;K=1;const g=he,o=G,l=ye(),{env:t}=process;let f;l("no-color")||l("no-colors")||l("color=false")||l("color=never")?f=0:(l("color")||l("colors")||l("color=true")||l("color=always"))&&(f=1),"FORCE_COLOR"in t&&(t.FORCE_COLOR==="true"?f=1:t.FORCE_COLOR==="false"?f=0:f=t.FORCE_COLOR.length===0?1:Math.min(parseInt(t.FORCE_COLOR,10),3));function w(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}r(w,"translateLevel");function b(i,p){if(f===0)return 0;if(l("color=16m")||l("color=full")||l("color=truecolor"))return 3;if(l("color=256"))return 2;if(i&&!p&&f===void 0)return 0;const c=f||0;if(t.TERM==="dumb")return c;if(process.platform==="win32"){const n=g.release().split(".");return Number(n[0])>=10&&Number(n[2])>=10586?Number(n[2])>=14931?3:2:1}if("CI"in t)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(n=>n in t)||t.CI_NAME==="codeship"?1:c;if("TEAMCITY_VERSION"in t)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(t.TEAMCITY_VERSION)?1:0;if(t.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in t){const n=parseInt((t.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(t.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(t.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(t.TERM)||"COLORTERM"in t?1:c}r(b,"supportsColor");function v(i){const p=b(i,i&&i.isTTY);return w(p)}return r(v,"getSupportLevel"),$={supportsColor:v,stdout:w(b(!0,o.isatty(1))),stderr:w(b(!0,o.isatty(2)))},$}r(be,"requireSupportsColor");var Z;function ve(){return Z||(Z=1,(function(g,o){const l=G,t=pe;o.init=c,o.log=v,o.formatArgs=w,o.save=i,o.load=p,o.useColors=f,o.destroy=t.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),o.colors=[6,2,3,4,5,1];try{const e=be();e&&(e.stderr||e).level>=2&&(o.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}o.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,a)=>{const s=a.substring(6).toLowerCase().replace(/_([a-z])/g,(u,m)=>m.toUpperCase());let h=process.env[a];return/^(yes|on|true|enabled)$/i.test(h)?h=!0:/^(no|off|false|disabled)$/i.test(h)?h=!1:h==="null"?h=null:h=Number(h),e[s]=h,e},{});function f(){return"colors"in o.inspectOpts?!!o.inspectOpts.colors:l.isatty(process.stderr.fd)}r(f,"useColors");function w(e){const{namespace:a,useColors:s}=this;if(s){const h=this.color,u="\x1B[3"+(h<8?h:"8;5;"+h),m=` ${u};1m${a} \x1B[0m`;e[0]=m+e[0].split(`
2
- `).join(`
3
- `+m),e.push(u+"m+"+g.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=b()+a+" "+e[0]}r(w,"formatArgs");function b(){return o.inspectOpts.hideDate?"":new Date().toISOString()+" "}r(b,"getDate");function v(...e){return process.stderr.write(t.formatWithOptions(o.inspectOpts,...e)+`
4
- `)}r(v,"log");function i(e){e?process.env.DEBUG=e:delete process.env.DEBUG}r(i,"save");function p(){return process.env.DEBUG}r(p,"load");function c(e){e.inspectOpts={};const a=Object.keys(o.inspectOpts);for(let s=0;s<a.length;s++)e.inspectOpts[a[s]]=o.inspectOpts[a[s]]}r(c,"init"),g.exports=Y()(o);const{formatters:n}=g.exports;n.o=function(e){return this.inspectOpts.colors=this.useColors,t.inspect(e,this.inspectOpts).split(`
5
- `).map(a=>a.trim()).join(" ")},n.O=function(e){return this.inspectOpts.colors=this.useColors,t.inspect(e,this.inspectOpts)}})(L,L.exports)),L.exports}r(ve,"requireNode");var Q;function H(){return Q||(Q=1,typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?M.exports=ge():M.exports=ve()),M.exports}r(H,"requireSrc$1");var q={},X;function Fe(){if(X)return q;X=1,Object.defineProperty(q,"__esModule",{value:!0});function g(o){return function(l,t){return new Promise((f,w)=>{o.call(this,l,t,(b,v)=>{b?w(b):f(v)})})}}return r(g,"promisify$1"),q.default=g,q}r(Fe,"requirePromisify");var S,ee;function we(){if(ee)return S;ee=1;var g=S&&S.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};const o=Ce,l=g(H()),t=g(Fe()),f=l.default("agent-base");function w(i){return!!i&&typeof i.addRequest=="function"}r(w,"isAgent");function b(){const{stack:i}=new Error;return typeof i!="string"?!1:i.split(`
6
- `).some(p=>p.indexOf("(https.js:")!==-1||p.indexOf("node:https:")!==-1)}r(b,"isSecureEndpoint");function v(i,p){return new v.Agent(i,p)}return r(v,"createAgent"),(function(i){const c=class c extends o.EventEmitter{constructor(e,a){super();let s=a;typeof e=="function"?this.callback=e:e&&(s=e),this.timeout=null,s&&typeof s.timeout=="number"&&(this.timeout=s.timeout),this.maxFreeSockets=1,this.maxSockets=1,this.maxTotalSockets=1/0,this.sockets={},this.freeSockets={},this.requests={},this.options={}}get defaultPort(){return typeof this.explicitDefaultPort=="number"?this.explicitDefaultPort:b()?443:80}set defaultPort(e){this.explicitDefaultPort=e}get protocol(){return typeof this.explicitProtocol=="string"?this.explicitProtocol:b()?"https:":"http:"}set protocol(e){this.explicitProtocol=e}callback(e,a,s){throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`')}addRequest(e,a){const s=Object.assign({},a);typeof s.secureEndpoint!="boolean"&&(s.secureEndpoint=b()),s.host==null&&(s.host="localhost"),s.port==null&&(s.port=s.secureEndpoint?443:80),s.protocol==null&&(s.protocol=s.secureEndpoint?"https:":"http:"),s.host&&s.path&&delete s.path,delete s.agent,delete s.hostname,delete s._defaultAgent,delete s.defaultPort,delete s.createConnection,e._last=!0,e.shouldKeepAlive=!1;let h=!1,u=null;const m=s.timeout||this.timeout,C=r(y=>{e._hadError||(e.emit("error",y),e._hadError=!0)},"onerror"),d=r(()=>{u=null,h=!0;const y=new Error(`A "socket" was not created for HTTP request before ${m}ms`);y.code="ETIMEOUT",C(y)},"ontimeout"),x=r(y=>{h||(u!==null&&(clearTimeout(u),u=null),C(y))},"callbackError"),F=r(y=>{if(h)return;if(u!=null&&(clearTimeout(u),u=null),w(y)){f("Callback returned another Agent instance %o",y.constructor.name),y.addRequest(e,s);return}if(y){y.once("free",()=>{this.freeSocket(y,s)}),e.onSocket(y);return}const E=new Error(`no Duplex stream was returned to agent-base for \`${e.method} ${e.path}\``);C(E)},"onsocket");if(typeof this.callback!="function"){C(new Error("`callback` is not defined"));return}this.promisifiedCallback||(this.callback.length>=3?(f("Converting legacy callback function to promise"),this.promisifiedCallback=t.default(this.callback)):this.promisifiedCallback=this.callback),typeof m=="number"&&m>0&&(u=setTimeout(d,m)),"port"in s&&typeof s.port!="number"&&(s.port=Number(s.port));try{f("Resolving socket for %o request: %o",s.protocol,`${e.method} ${e.path}`),Promise.resolve(this.promisifiedCallback(e,s)).then(F,x)}catch(y){Promise.reject(y).catch(x)}}freeSocket(e,a){f("Freeing socket %o %o",e.constructor.name,a),e.destroy()}destroy(){f("Destroying agent %o",this.constructor.name)}};r(c,"Agent");let p=c;i.Agent=p,i.prototype=i.Agent.prototype})(v||(v={})),S=v,S}r(we,"requireSrc");var A={},te;function _e(){if(te)return A;te=1;var g=A&&A.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(A,"__esModule",{value:!0});const l=g(H()).default("https-proxy-agent:parse-proxy-response");function t(f){return new Promise((w,b)=>{let v=0;const i=[];function p(){const h=f.read();h?s(h):f.once("readable",p)}r(p,"read");function c(){f.removeListener("end",e),f.removeListener("error",a),f.removeListener("close",n),f.removeListener("readable",p)}r(c,"cleanup");function n(h){l("onclose had error %o",h)}r(n,"onclose");function e(){l("onend")}r(e,"onend");function a(h){c(),l("onerror %o",h),b(h)}r(a,"onerror");function s(h){i.push(h),v+=h.length;const u=Buffer.concat(i,v);if(u.indexOf(`\r
7
- \r
8
- `)===-1){l("have not received end of HTTP headers yet..."),p();return}const C=u.toString("ascii",0,u.indexOf(`\r
9
- `)),d=+C.split(" ")[1];l("got proxy server response: %o",C),w({statusCode:d,buffered:u})}r(s,"ondata"),f.on("error",a),f.on("close",n),f.on("end",e),p()})}return r(t,"parseProxyResponse$1"),A.default=t,A}r(_e,"requireParseProxyResponse");var re;function Oe(){if(re)return P;re=1;var g=P&&P.__awaiter||function(u,m,C,d){function x(F){return F instanceof C?F:new C(function(y){y(F)})}return r(x,"adopt"),new(C||(C=Promise))(function(F,y){function E(_){try{O(d.next(_))}catch(I){y(I)}}r(E,"fulfilled");function T(_){try{O(d.throw(_))}catch(I){y(I)}}r(T,"rejected");function O(_){_.done?F(_.value):x(_.value).then(E,T)}r(O,"step"),O((d=d.apply(u,m||[])).next())})},o=P&&P.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(P,"__esModule",{value:!0});const l=o(ae),t=o(le),f=o(fe),w=o(de),b=o(H()),v=we(),i=o(_e()),p=b.default("https-proxy-agent:agent"),h=class h extends v.Agent{constructor(m){let C;if(typeof m=="string"?C=f.default.parse(m):C=m,!C)throw new Error("an HTTP(S) proxy server `host` and `port` must be specified!");p("creating new HttpsProxyAgent instance: %o",C),super(C);const d=Object.assign({},C);this.secureProxy=C.secureProxy||a(d.protocol),d.host=d.hostname||d.host,typeof d.port=="string"&&(d.port=parseInt(d.port,10)),!d.port&&d.host&&(d.port=this.secureProxy?443:80),this.secureProxy&&!("ALPNProtocols"in d)&&(d.ALPNProtocols=["http 1.1"]),d.host&&d.path&&(delete d.path,delete d.pathname),this.proxy=d}callback(m,C){return g(this,void 0,void 0,function*(){const{proxy:d,secureProxy:x}=this;let F;x?(p("Creating `tls.Socket`: %o",d),F=t.default.connect(d)):(p("Creating `net.Socket`: %o",d),F=l.default.connect(d));const y=Object.assign({},d.headers);let T=`CONNECT ${`${C.host}:${C.port}`} HTTP/1.1\r
10
- `;d.auth&&(y["Proxy-Authorization"]=`Basic ${Buffer.from(d.auth).toString("base64")}`);let{host:O,port:_,secureEndpoint:I}=C;e(_,I)||(O+=`:${_}`),y.Host=O,y.Connection="close";for(const R of Object.keys(y))T+=`${R}: ${y[R]}\r
11
- `;const oe=i.default(F);F.write(`${T}\r
12
- `);const{statusCode:se,buffered:ie}=yield oe;if(se===200){if(m.once("socket",n),C.secureEndpoint){p("Upgrading socket connection to TLS");const R=C.servername||C.host;return t.default.connect(Object.assign(Object.assign({},s(C,"host","hostname","path","port")),{socket:F,servername:R}))}return F}F.destroy();const U=new l.default.Socket({writable:!1});return U.readable=!0,m.once("socket",R=>{p("replaying proxy buffer for failed request"),w.default(R.listenerCount("data")>0),R.push(ie),R.push(null)}),U})}};r(h,"HttpsProxyAgent");let c=h;P.default=c;function n(u){u.resume()}r(n,"resume");function e(u,m){return!!(!m&&u===80||m&&u===443)}r(e,"isDefaultPort");function a(u){return typeof u=="string"?/^https:?$/i.test(u):!1}r(a,"isHTTPS");function s(u,...m){const C={};let d;for(d in u)m.includes(d)||(C[d]=u[d]);return C}return r(s,"omit"),P}r(Oe,"requireAgent");var k,ne;function xe(){if(ne)return k;ne=1;var g=k&&k.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};const o=g(Oe());function l(t){return new o.default(t)}return r(l,"createHttpsProxyAgent"),(function(t){t.HttpsProxyAgent=o.default,t.prototype=o.default.prototype})(l||(l={})),k=l,k}r(xe,"requireDist");var Ee=xe(),Re=ce(Ee);export{Re as c};
@@ -1,5 +0,0 @@
1
- var C=Object.defineProperty;var f=(d,t)=>C(d,"name",{value:t,configurable:!0});import M from"http";import O from"https";import{L as $,g as L}from"./prompt-BMR92Sng.mjs";import{K as m}from"./cli-CLrzwExP.mjs";import"tty";import"node:buffer";import"node:path";import"node:child_process";import"node:process";import"child_process";import"path";import"fs";import"node:url";import"node:os";import"assert";import"events";import"node:fs";import"buffer";import"stream";import"util";import"node:util";import"node:readline";import"node:stream";import"fs/promises";import"os";import"url";const g=class g extends ${get name(){return"ollama"}validateConfig(){const{endpoint:t}=this.config;if(!t)throw new m("Ollama endpoint is not configured. Using default: http://localhost:11434")}async generateCommitMessage(t){try{const e=[{role:"system",content:L(this.config.locale,this.config.maxLength,this.config.type,t.projectConfig)},{role:"user",content:t.diff}],o=[];for(let s=0;s<t.completions;s++){const a=(await this.createChatCompletion(e)).message.content;a&&o.push(this.sanitizeMessage(a))}return{messages:this.deduplicateMessages(o)}}catch(r){const e=r;throw e.code==="ECONNREFUSED"?new m(`Cannot connect to Ollama at ${this.config.endpoint}. Make sure Ollama is running. Install from: https://ollama.com`):e.code==="ENOTFOUND"?new m(`Error connecting to ${e.hostname} (${e.syscall}). Check your OLLAMA_ENDPOINT configuration.`):e}}async createChatCompletion(t){const r={model:this.config.model,messages:t,stream:!1,options:{temperature:this.config.temperature,num_predict:this.config.maxCompletionTokens}},{response:e,data:o}=await this.httpPost(this.config.endpoint,"/api/chat",{},r);if(!e.statusCode||e.statusCode<200||e.statusCode>299){let n=`Ollama API Error: ${e.statusCode} - ${e.statusMessage}`;if(o)try{const s=JSON.parse(o);s.error&&(n+=`
2
-
3
- ${s.error}`)}catch{n+=`
4
-
5
- ${o}`}throw new m(n)}return JSON.parse(o)}async httpPost(t,r,e,o){return new Promise((n,s)=>{const c=new URL(t),a=c.protocol==="https:",y=a?O:M,l=JSON.stringify(o),i=y.request({hostname:c.hostname,port:c.port||(a?443:80),path:r,method:"POST",headers:{...e,"Content-Type":"application/json","Content-Length":Buffer.byteLength(l)},timeout:this.config.timeout},p=>{const u=[];p.on("data",w=>u.push(w)),p.on("end",()=>{n({request:i,response:p,data:Buffer.concat(u).toString()})})});i.on("error",s),i.on("timeout",()=>{i.destroy(),s(new m(`Time out error: request took over ${this.config.timeout}ms. Try increasing the \`timeout\` config or check if Ollama is running.`))}),i.write(l),i.end()})}sanitizeMessage(t){return t.trim().replace(/[\n\r]/g,"").replace(/(\w)\.$/,"$1")}deduplicateMessages(t){return Array.from(new Set(t))}};f(g,"OllamaProvider");let h=g;export{h as default};
@@ -1,5 +0,0 @@
1
- var y=Object.defineProperty;var g=(u,t)=>y(u,"name",{value:t,configurable:!0});import d from"https";import{c as w}from"./index-C2fjMMuy.mjs";import{L as C,g as A}from"./prompt-BMR92Sng.mjs";import{K as i}from"./cli-CLrzwExP.mjs";import"net";import"tls";import"url";import"assert";import"tty";import"util";import"os";import"events";import"node:buffer";import"node:path";import"node:child_process";import"node:process";import"child_process";import"path";import"fs";import"node:url";import"node:os";import"node:fs";import"buffer";import"stream";import"node:util";import"node:readline";import"node:stream";import"fs/promises";const m=class m extends C{get name(){return"openai"}validateConfig(){const{apiKey:t}=this.config;if(!t)throw new i("Please set your OpenAI API key via `aicommit config set OPENAI_KEY=<your token>`");if(!t.startsWith("sk-"))throw new i('Invalid OpenAI API key: Must start with "sk-"')}async generateCommitMessage(t){try{const e=await this.createChatCompletion({model:this.config.model,messages:[{role:"system",content:A(this.config.locale,this.config.maxLength,this.config.type,t.projectConfig)},{role:"user",content:t.diff}],temperature:this.config.temperature,top_p:1,frequency_penalty:0,presence_penalty:0,max_completion_tokens:this.config.maxCompletionTokens,stream:!1,n:t.completions});return{messages:this.deduplicateMessages(e.choices.filter(s=>s.message?.content).map(s=>this.sanitizeMessage(s.message.content)))}}catch(e){const o=e;throw o.code==="ENOTFOUND"?new i(`Error connecting to ${o.hostname} (${o.syscall}). Are you connected to the internet?`):o}}async createChatCompletion(t){const{response:e,data:o}=await this.httpsPost("api.openai.com","/v1/chat/completions",{Authorization:`Bearer ${this.config.apiKey}`},t);if(!e.statusCode||e.statusCode<200||e.statusCode>299){let s=`OpenAI API Error: ${e.statusCode} - ${e.statusMessage}`;throw o&&(s+=`
2
-
3
- ${o}`),e.statusCode===500&&(s+=`
4
-
5
- Check the API status: https://status.openai.com`),new i(s)}return JSON.parse(o)}async httpsPost(t,e,o,s){return new Promise((f,p)=>{const c=JSON.stringify(s),r=d.request({hostname:t,path:e,method:"POST",headers:{...o,"Content-Type":"application/json","Content-Length":Buffer.byteLength(c)},timeout:this.config.timeout,agent:this.config.proxy?w(this.config.proxy):void 0},n=>{const h=[];n.on("data",l=>h.push(l)),n.on("end",()=>{f({request:r,response:n,data:Buffer.concat(h).toString()})})});r.on("error",p),r.on("timeout",()=>{r.destroy(),p(new i(`Time out error: request took over ${this.config.timeout}ms. Try increasing the \`timeout\` config, or checking the OpenAI API status https://status.openai.com`))}),r.write(c),r.end()})}sanitizeMessage(t){return t.trim().replace(/[\n\r]/g,"").replace(/(\w)\.$/,"$1")}deduplicateMessages(t){return Array.from(new Set(t))}};g(m,"OpenAIProvider");let a=m;export{a as default};