@negoziator/ai-commit 2.38.1 → 2.40.0
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/{anthropic-DuA5vE5h.mjs → anthropic-Cu3TAG1r.mjs} +1 -1
- package/dist/{azure-openai-71qhy4s4.mjs → azure-openai-DCpE1BEh.mjs} +1 -1
- package/dist/cli-DDDniRwr.mjs +140 -0
- package/dist/cli.mjs +1 -1
- package/dist/{custom-UcwdrwuK.mjs → custom-DVt00ve3.mjs} +1 -1
- package/dist/{ollama-CFW7F7C3.mjs → ollama-VLtr8YK2.mjs} +1 -1
- package/dist/{openai-DCW7kQNn.mjs → openai-Bu9L9mrj.mjs} +1 -1
- package/package.json +1 -1
- package/dist/cli-wMuQ2foU.mjs +0 -140
package/dist/cli.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import"./cli-
|
|
2
|
+
import"./cli-DDDniRwr.mjs";import"tty";import"node:url";import"node:child_process";import"node:string_decoder";import"node:util";import"node:process";import"node:tty";import"node:path";import"child_process";import"path";import"fs";import"node:timers/promises";import"node:os";import"node:events";import"node:v8";import"node:fs";import"node:stream";import"node:buffer";import"node:stream/promises";import"node:readline";import"fs/promises";import"os";import"url";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var M=Object.defineProperty;var d=(l,t)=>M(l,"name",{value:t,configurable:!0});import T from"http";import N from"https";import{L as O,g as P}from"./prompt-BGI0PV0L.mjs";import{K as m}from"./cli-
|
|
1
|
+
var M=Object.defineProperty;var d=(l,t)=>M(l,"name",{value:t,configurable:!0});import T from"http";import N from"https";import{L as O,g as P}from"./prompt-BGI0PV0L.mjs";import{K as m}from"./cli-DDDniRwr.mjs";import"tty";import"node:url";import"node:child_process";import"node:string_decoder";import"node:util";import"node:process";import"node:tty";import"node:path";import"child_process";import"path";import"fs";import"node:timers/promises";import"node:os";import"node:events";import"node:v8";import"node:fs";import"node:stream";import"node:buffer";import"node:stream/promises";import"node:readline";import"fs/promises";import"os";import"url";const g=class g extends O{get name(){return"custom"}validateConfig(){const{endpoint:t}=this.config;if(!t)throw new m("Please set your custom endpoint via `aicommit config set CUSTOM_ENDPOINT=<your endpoint>`")}async generateCommitMessage(t){try{const o=[{role:"system",content:P(this.config.locale,this.config.maxLength,this.config.type,t.projectConfig)},{role:"user",content:t.diff}],s=[];for(let i=0;i<t.completions;i++){const e=await this.createChatCompletion(o);let n;e.choices&&e.choices[0]?.message?.content?n=e.choices[0].message.content:e.message?.content?n=e.message.content:e.content?n=e.content:typeof e=="string"&&(n=e),n&&s.push(this.sanitizeMessage(n))}return{messages:this.deduplicateMessages(s)}}catch(r){const o=r;throw o.code==="ECONNREFUSED"?new m(`Cannot connect to custom endpoint at ${this.config.endpoint}. Make sure your endpoint is running and accessible.`):o.code==="ENOTFOUND"?new m(`Error connecting to ${o.hostname} (${o.syscall}). Check your CUSTOM_ENDPOINT configuration.`):o}}async createChatCompletion(t){const r={model:this.config.model,messages:t,temperature:this.config.temperature,max_tokens:this.config.maxCompletionTokens},o={...this.config.headers||{}};this.config.apiKey&&(o.Authorization=`Bearer ${this.config.apiKey}`);const{response:s,data:a}=await this.httpPost(this.config.endpoint,"",o,r);if(!s.statusCode||s.statusCode<200||s.statusCode>299){let i=`Custom API Error: ${s.statusCode} - ${s.statusMessage}`;throw a&&(i+=`
|
|
2
2
|
|
|
3
3
|
${a}`),new m(i)}return JSON.parse(a)}async httpPost(t,r,o,s){return new Promise((a,i)=>{const e=new URL(t),n=e.protocol==="https:",y=n?N:T,C=e.pathname+(r||""),f=JSON.stringify(s),c=y.request({hostname:e.hostname,port:e.port||(n?443:80),path:C,method:"POST",headers:{...o,"Content-Type":"application/json","Content-Length":Buffer.byteLength(f)},timeout:this.config.timeout},p=>{const u=[];p.on("data",w=>u.push(w)),p.on("end",()=>{a({request:c,response:p,data:Buffer.concat(u).toString()})})});c.on("error",i),c.on("timeout",()=>{c.destroy(),i(new m(`Time out error: request took over ${this.config.timeout}ms. Try increasing the \`timeout\` config.`))}),c.write(f),c.end()})}sanitizeMessage(t){return t.trim().replace(/[\n\r]/g,"").replace(/(\w)\.$/,"$1")}deduplicateMessages(t){return Array.from(new Set(t))}};d(g,"CustomProvider");let h=g;export{h as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
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-BGI0PV0L.mjs";import{K as m}from"./cli-
|
|
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-BGI0PV0L.mjs";import{K as m}from"./cli-DDDniRwr.mjs";import"tty";import"node:url";import"node:child_process";import"node:string_decoder";import"node:util";import"node:process";import"node:tty";import"node:path";import"child_process";import"path";import"fs";import"node:timers/promises";import"node:os";import"node:events";import"node:v8";import"node:fs";import"node:stream";import"node:buffer";import"node:stream/promises";import"node:readline";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
2
|
|
|
3
3
|
${s.error}`)}catch{n+=`
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var d=Object.defineProperty;var g=(u,t)=>d(u,"name",{value:t,configurable:!0});import y from"https";import{d as w}from"./index-B3_BP8RZ.mjs";import{L as C,g as A}from"./prompt-BGI0PV0L.mjs";import{K as i}from"./cli-
|
|
1
|
+
var d=Object.defineProperty;var g=(u,t)=>d(u,"name",{value:t,configurable:!0});import y from"https";import{d as w}from"./index-B3_BP8RZ.mjs";import{L as C,g as A}from"./prompt-BGI0PV0L.mjs";import{K as i}from"./cli-DDDniRwr.mjs";import"net";import"tls";import"assert";import"tty";import"util";import"os";import"http";import"url";import"node:url";import"node:child_process";import"node:string_decoder";import"node:util";import"node:process";import"node:tty";import"node:path";import"child_process";import"path";import"fs";import"node:timers/promises";import"node:os";import"node:events";import"node:v8";import"node:fs";import"node:stream";import"node:buffer";import"node:stream/promises";import"node:readline";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
2
|
|
|
3
3
|
${o}`),e.statusCode===500&&(s+=`
|
|
4
4
|
|