opencommit 3.3.9 → 3.3.10

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.
Files changed (2) hide show
  1. package/out/cli.cjs +441 -369
  2. package/package.json +1 -1
package/out/cli.cjs CHANGED
@@ -1699,20 +1699,20 @@ var require_buffer_stream = __commonJS({
1699
1699
  module2.exports = (options) => {
1700
1700
  options = { ...options };
1701
1701
  const { array } = options;
1702
- let { encoding } = options;
1703
- const isBuffer2 = encoding === "buffer";
1702
+ let { encoding: encoding2 } = options;
1703
+ const isBuffer2 = encoding2 === "buffer";
1704
1704
  let objectMode = false;
1705
1705
  if (array) {
1706
- objectMode = !(encoding || isBuffer2);
1706
+ objectMode = !(encoding2 || isBuffer2);
1707
1707
  } else {
1708
- encoding = encoding || "utf8";
1708
+ encoding2 = encoding2 || "utf8";
1709
1709
  }
1710
1710
  if (isBuffer2) {
1711
- encoding = null;
1711
+ encoding2 = null;
1712
1712
  }
1713
1713
  const stream4 = new PassThroughStream({ objectMode });
1714
- if (encoding) {
1715
- stream4.setEncoding(encoding);
1714
+ if (encoding2) {
1715
+ stream4.setEncoding(encoding2);
1716
1716
  }
1717
1717
  let length = 0;
1718
1718
  const chunks = [];
@@ -2042,10 +2042,10 @@ var require_main = __commonJS({
2042
2042
  }
2043
2043
  function configDotenv(options) {
2044
2044
  const dotenvPath = path5.resolve(process.cwd(), ".env");
2045
- let encoding = "utf8";
2045
+ let encoding2 = "utf8";
2046
2046
  const debug5 = Boolean(options && options.debug);
2047
2047
  if (options && options.encoding) {
2048
- encoding = options.encoding;
2048
+ encoding2 = options.encoding;
2049
2049
  } else {
2050
2050
  if (debug5) {
2051
2051
  _debug("No encoding is specified. UTF-8 is used by default");
@@ -2066,7 +2066,7 @@ var require_main = __commonJS({
2066
2066
  const parsedAll = {};
2067
2067
  for (const path6 of optionPaths) {
2068
2068
  try {
2069
- const parsed = DotenvModule.parse(fs7.readFileSync(path6, { encoding }));
2069
+ const parsed = DotenvModule.parse(fs7.readFileSync(path6, { encoding: encoding2 }));
2070
2070
  DotenvModule.populate(parsedAll, parsed, options);
2071
2071
  } catch (e3) {
2072
2072
  if (debug5) {
@@ -25085,16 +25085,16 @@ var require_follow_redirects = __commonJS({
25085
25085
  destroy2.call(this, error);
25086
25086
  return this;
25087
25087
  };
25088
- RedirectableRequest.prototype.write = function(data, encoding, callback) {
25088
+ RedirectableRequest.prototype.write = function(data, encoding2, callback) {
25089
25089
  if (this._ending) {
25090
25090
  throw new WriteAfterEndError();
25091
25091
  }
25092
25092
  if (!isString2(data) && !isBuffer2(data)) {
25093
25093
  throw new TypeError("data should be a string, Buffer or Uint8Array");
25094
25094
  }
25095
- if (isFunction4(encoding)) {
25096
- callback = encoding;
25097
- encoding = null;
25095
+ if (isFunction4(encoding2)) {
25096
+ callback = encoding2;
25097
+ encoding2 = null;
25098
25098
  }
25099
25099
  if (data.length === 0) {
25100
25100
  if (callback) {
@@ -25104,20 +25104,20 @@ var require_follow_redirects = __commonJS({
25104
25104
  }
25105
25105
  if (this._requestBodyLength + data.length <= this._options.maxBodyLength) {
25106
25106
  this._requestBodyLength += data.length;
25107
- this._requestBodyBuffers.push({ data, encoding });
25108
- this._currentRequest.write(data, encoding, callback);
25107
+ this._requestBodyBuffers.push({ data, encoding: encoding2 });
25108
+ this._currentRequest.write(data, encoding2, callback);
25109
25109
  } else {
25110
25110
  this.emit("error", new MaxBodyLengthExceededError());
25111
25111
  this.abort();
25112
25112
  }
25113
25113
  };
25114
- RedirectableRequest.prototype.end = function(data, encoding, callback) {
25114
+ RedirectableRequest.prototype.end = function(data, encoding2, callback) {
25115
25115
  if (isFunction4(data)) {
25116
25116
  callback = data;
25117
- data = encoding = null;
25118
- } else if (isFunction4(encoding)) {
25119
- callback = encoding;
25120
- encoding = null;
25117
+ data = encoding2 = null;
25118
+ } else if (isFunction4(encoding2)) {
25119
+ callback = encoding2;
25120
+ encoding2 = null;
25121
25121
  }
25122
25122
  if (!data) {
25123
25123
  this._ended = this._ending = true;
@@ -25125,7 +25125,7 @@ var require_follow_redirects = __commonJS({
25125
25125
  } else {
25126
25126
  var self2 = this;
25127
25127
  var currentRequest = this._currentRequest;
25128
- this.write(data, encoding, function() {
25128
+ this.write(data, encoding2, function() {
25129
25129
  self2._ended = true;
25130
25130
  currentRequest.end(null, null, callback);
25131
25131
  });
@@ -34521,8 +34521,8 @@ var require_matchers = __commonJS({
34521
34521
  error: new sdkerror_js_1.SDKError("Unexpected API response status or content-type", response, responseBody)
34522
34522
  }, responseBody];
34523
34523
  }
34524
- const encoding = matcher.enc;
34525
- switch (encoding) {
34524
+ const encoding2 = matcher.enc;
34525
+ switch (encoding2) {
34526
34526
  case "json":
34527
34527
  raw = await response.json();
34528
34528
  break;
@@ -34545,8 +34545,8 @@ var require_matchers = __commonJS({
34545
34545
  raw = await response.text();
34546
34546
  break;
34547
34547
  default:
34548
- encoding;
34549
- throw new Error(`Unsupported response type: ${encoding}`);
34548
+ encoding2;
34549
+ throw new Error(`Unsupported response type: ${encoding2}`);
34550
34550
  }
34551
34551
  if (matcher.enc === "fail") {
34552
34552
  return [{
@@ -48565,7 +48565,7 @@ var require_Dicer = __commonJS({
48565
48565
  WritableStream2.prototype.emit.apply(this, arguments);
48566
48566
  }
48567
48567
  };
48568
- Dicer.prototype._write = function(data, encoding, cb) {
48568
+ Dicer.prototype._write = function(data, encoding2, cb) {
48569
48569
  if (!this._hparser && !this._bparser) {
48570
48570
  return cb();
48571
48571
  }
@@ -49553,7 +49553,7 @@ var require_multipart = __commonJS({
49553
49553
  let fieldname;
49554
49554
  let parsed;
49555
49555
  let charset;
49556
- let encoding;
49556
+ let encoding2;
49557
49557
  let filename;
49558
49558
  let nsize = 0;
49559
49559
  if (header["content-type"]) {
@@ -49593,9 +49593,9 @@ var require_multipart = __commonJS({
49593
49593
  return skipPart(part);
49594
49594
  }
49595
49595
  if (header["content-transfer-encoding"]) {
49596
- encoding = header["content-transfer-encoding"][0].toLowerCase();
49596
+ encoding2 = header["content-transfer-encoding"][0].toLowerCase();
49597
49597
  } else {
49598
- encoding = "7bit";
49598
+ encoding2 = "7bit";
49599
49599
  }
49600
49600
  let onData, onEnd;
49601
49601
  if (isPartAFile(fieldname, contype, filename)) {
@@ -49635,7 +49635,7 @@ var require_multipart = __commonJS({
49635
49635
  cb();
49636
49636
  }
49637
49637
  };
49638
- boy.emit("file", fieldname, file, filename, encoding, contype);
49638
+ boy.emit("file", fieldname, file, filename, encoding2, contype);
49639
49639
  onData = function(data) {
49640
49640
  if ((nsize += data.length) > fileSizeLimit) {
49641
49641
  const extralen = fileSizeLimit - nsize + data.length;
@@ -49684,7 +49684,7 @@ var require_multipart = __commonJS({
49684
49684
  if (buffer.length) {
49685
49685
  buffer = decodeText(buffer, "binary", charset);
49686
49686
  }
49687
- boy.emit("field", fieldname, buffer, false, truncated, encoding, contype);
49687
+ boy.emit("field", fieldname, buffer, false, truncated, encoding2, contype);
49688
49688
  --nends;
49689
49689
  checkFinished();
49690
49690
  };
@@ -50202,7 +50202,7 @@ var require_main2 = __commonJS({
50202
50202
  }
50203
50203
  throw new Error("Unsupported Content-Type.");
50204
50204
  };
50205
- Busboy.prototype._write = function(chunk, encoding, cb) {
50205
+ Busboy.prototype._write = function(chunk, encoding2, cb) {
50206
50206
  this._parser.write(chunk, cb);
50207
50207
  };
50208
50208
  module2.exports = Busboy;
@@ -52329,9 +52329,9 @@ Content-Type: ${value.type || "application/octet-stream"}\r
52329
52329
  busboy.on("field", (name, value) => {
52330
52330
  responseFormData.append(name, value);
52331
52331
  });
52332
- busboy.on("file", (name, value, filename, encoding, mimeType) => {
52332
+ busboy.on("file", (name, value, filename, encoding2, mimeType) => {
52333
52333
  const chunks = [];
52334
- if (encoding === "base64" || encoding.toLowerCase() === "base64") {
52334
+ if (encoding2 === "base64" || encoding2.toLowerCase() === "base64") {
52335
52335
  let base64chunk = "";
52336
52336
  value.on("data", (chunk) => {
52337
52337
  base64chunk += chunk.toString().replace(/[\r\n]/gm, "");
@@ -56781,9 +56781,9 @@ var require_api_pipeline = __commonJS({
56781
56781
  body.resume();
56782
56782
  }
56783
56783
  },
56784
- write: (chunk, encoding, callback) => {
56784
+ write: (chunk, encoding2, callback) => {
56785
56785
  const { req } = this;
56786
- if (req.push(chunk, encoding) || req._readableState.destroyed) {
56786
+ if (req.push(chunk, encoding2) || req._readableState.destroyed) {
56787
56787
  callback();
56788
56788
  } else {
56789
56789
  req[kResume] = callback;
@@ -60900,7 +60900,7 @@ var require_progressevent = __commonJS({
60900
60900
  var require_encoding2 = __commonJS({
60901
60901
  "node_modules/undici/lib/fileapi/encoding.js"(exports2, module2) {
60902
60902
  "use strict";
60903
- function getEncoding(label) {
60903
+ function getEncoding2(label) {
60904
60904
  if (!label) {
60905
60905
  return "failure";
60906
60906
  }
@@ -61177,7 +61177,7 @@ var require_encoding2 = __commonJS({
61177
61177
  }
61178
61178
  }
61179
61179
  module2.exports = {
61180
- getEncoding
61180
+ getEncoding: getEncoding2
61181
61181
  };
61182
61182
  }
61183
61183
  });
@@ -61194,7 +61194,7 @@ var require_util5 = __commonJS({
61194
61194
  kLastProgressEventFired
61195
61195
  } = require_symbols3();
61196
61196
  var { ProgressEvent } = require_progressevent();
61197
- var { getEncoding } = require_encoding2();
61197
+ var { getEncoding: getEncoding2 } = require_encoding2();
61198
61198
  var { DOMException: DOMException3 } = require_constants3();
61199
61199
  var { serializeAMimeType, parseMIMEType } = require_dataURL();
61200
61200
  var { types } = require("util");
@@ -61297,20 +61297,20 @@ var require_util5 = __commonJS({
61297
61297
  return dataURL;
61298
61298
  }
61299
61299
  case "Text": {
61300
- let encoding = "failure";
61300
+ let encoding2 = "failure";
61301
61301
  if (encodingName) {
61302
- encoding = getEncoding(encodingName);
61302
+ encoding2 = getEncoding2(encodingName);
61303
61303
  }
61304
- if (encoding === "failure" && mimeType) {
61304
+ if (encoding2 === "failure" && mimeType) {
61305
61305
  const type3 = parseMIMEType(mimeType);
61306
61306
  if (type3 !== "failure") {
61307
- encoding = getEncoding(type3.parameters.get("charset"));
61307
+ encoding2 = getEncoding2(type3.parameters.get("charset"));
61308
61308
  }
61309
61309
  }
61310
- if (encoding === "failure") {
61311
- encoding = "UTF-8";
61310
+ if (encoding2 === "failure") {
61311
+ encoding2 = "UTF-8";
61312
61312
  }
61313
- return decode(bytes, encoding);
61313
+ return decode(bytes, encoding2);
61314
61314
  }
61315
61315
  case "ArrayBuffer": {
61316
61316
  const sequence = combineByteSequences(bytes);
@@ -61327,16 +61327,16 @@ var require_util5 = __commonJS({
61327
61327
  }
61328
61328
  }
61329
61329
  }
61330
- function decode(ioQueue, encoding) {
61330
+ function decode(ioQueue, encoding2) {
61331
61331
  const bytes = combineByteSequences(ioQueue);
61332
61332
  const BOMEncoding = BOMSniffing(bytes);
61333
61333
  let slice = 0;
61334
61334
  if (BOMEncoding !== null) {
61335
- encoding = BOMEncoding;
61335
+ encoding2 = BOMEncoding;
61336
61336
  slice = BOMEncoding === "UTF-8" ? 3 : 2;
61337
61337
  }
61338
61338
  const sliced = bytes.slice(slice);
61339
- return new TextDecoder(encoding).decode(sliced);
61339
+ return new TextDecoder(encoding2).decode(sliced);
61340
61340
  }
61341
61341
  function BOMSniffing(ioQueue) {
61342
61342
  const [a4, b7, c4] = ioQueue;
@@ -61426,14 +61426,14 @@ var require_filereader = __commonJS({
61426
61426
  * @param {import('buffer').Blob} blob
61427
61427
  * @param {string?} encoding
61428
61428
  */
61429
- readAsText(blob, encoding = void 0) {
61429
+ readAsText(blob, encoding2 = void 0) {
61430
61430
  webidl.brandCheck(this, _FileReader);
61431
61431
  webidl.argumentLengthCheck(arguments, 1, { header: "FileReader.readAsText" });
61432
61432
  blob = webidl.converters.Blob(blob, { strict: false });
61433
- if (encoding !== void 0) {
61434
- encoding = webidl.converters.DOMString(encoding);
61433
+ if (encoding2 !== void 0) {
61434
+ encoding2 = webidl.converters.DOMString(encoding2);
61435
61435
  }
61436
- readOperation(this, blob, "Text", encoding);
61436
+ readOperation(this, blob, "Text", encoding2);
61437
61437
  }
61438
61438
  /**
61439
61439
  * @see https://w3c.github.io/FileAPI/#dfn-readAsDataURL
@@ -65273,7 +65273,7 @@ function G3(t2, e3) {
65273
65273
  // package.json
65274
65274
  var package_default = {
65275
65275
  name: "opencommit",
65276
- version: "3.3.9",
65276
+ version: "3.3.10",
65277
65277
  description: "Auto-generate impressive commits in 1 second. Killing lame commits with AI \u{1F92F}\u{1F52B}",
65278
65278
  keywords: [
65279
65279
  "git",
@@ -66680,19 +66680,19 @@ var getBufferedData = async (stream4, streamPromise) => {
66680
66680
  return error.bufferedData;
66681
66681
  }
66682
66682
  };
66683
- var getStreamPromise = (stream4, { encoding, buffer, maxBuffer }) => {
66683
+ var getStreamPromise = (stream4, { encoding: encoding2, buffer, maxBuffer }) => {
66684
66684
  if (!stream4 || !buffer) {
66685
66685
  return;
66686
66686
  }
66687
- if (encoding) {
66688
- return (0, import_get_stream.default)(stream4, { encoding, maxBuffer });
66687
+ if (encoding2) {
66688
+ return (0, import_get_stream.default)(stream4, { encoding: encoding2, maxBuffer });
66689
66689
  }
66690
66690
  return import_get_stream.default.buffer(stream4, { maxBuffer });
66691
66691
  };
66692
- var getSpawnedResult = async ({ stdout, stderr: stderr2, all: all3 }, { encoding, buffer, maxBuffer }, processDone) => {
66693
- const stdoutPromise = getStreamPromise(stdout, { encoding, buffer, maxBuffer });
66694
- const stderrPromise = getStreamPromise(stderr2, { encoding, buffer, maxBuffer });
66695
- const allPromise = getStreamPromise(all3, { encoding, buffer, maxBuffer: maxBuffer * 2 });
66692
+ var getSpawnedResult = async ({ stdout, stderr: stderr2, all: all3 }, { encoding: encoding2, buffer, maxBuffer }, processDone) => {
66693
+ const stdoutPromise = getStreamPromise(stdout, { encoding: encoding2, buffer, maxBuffer });
66694
+ const stderrPromise = getStreamPromise(stderr2, { encoding: encoding2, buffer, maxBuffer });
66695
+ const allPromise = getStreamPromise(all3, { encoding: encoding2, buffer, maxBuffer: maxBuffer * 2 });
66696
66696
  try {
66697
66697
  return await Promise.all([processDone, stdoutPromise, stderrPromise, allPromise]);
66698
66698
  } catch (error) {
@@ -72390,7 +72390,7 @@ var AxiosTransformStream = class extends import_stream2.default.Transform {
72390
72390
  }
72391
72391
  return super._read(size);
72392
72392
  }
72393
- _transform(chunk, encoding, callback) {
72393
+ _transform(chunk, encoding2, callback) {
72394
72394
  const internals = this[kInternals];
72395
72395
  const maxRate = internals.maxRate;
72396
72396
  const readableHighWaterMark = this.readableHighWaterMark;
@@ -72564,21 +72564,21 @@ var formDataToStream_default = formDataToStream;
72564
72564
  // node_modules/axios/lib/helpers/ZlibHeaderTransformStream.js
72565
72565
  var import_stream4 = __toESM(require("stream"), 1);
72566
72566
  var ZlibHeaderTransformStream = class extends import_stream4.default.Transform {
72567
- __transform(chunk, encoding, callback) {
72567
+ __transform(chunk, encoding2, callback) {
72568
72568
  this.push(chunk);
72569
72569
  callback();
72570
72570
  }
72571
- _transform(chunk, encoding, callback) {
72571
+ _transform(chunk, encoding2, callback) {
72572
72572
  if (chunk.length !== 0) {
72573
72573
  this._transform = this.__transform;
72574
72574
  if (chunk[0] !== 120) {
72575
72575
  const header = Buffer.alloc(2);
72576
72576
  header[0] = 120;
72577
72577
  header[1] = 156;
72578
- this.push(header, encoding);
72578
+ this.push(header, encoding2);
72579
72579
  }
72580
72580
  }
72581
- this.__transform(chunk, encoding, callback);
72581
+ this.__transform(chunk, encoding2, callback);
72582
72582
  }
72583
72583
  };
72584
72584
  var ZlibHeaderTransformStream_default = ZlibHeaderTransformStream;
@@ -74526,89 +74526,78 @@ function getServiceUnavailableMessage(provider, context) {
74526
74526
  }
74527
74527
  return `The ${provider} service is temporarily unavailable.`;
74528
74528
  }
74529
+ function formatInsufficientCredits(provider, billingUrl) {
74530
+ return {
74531
+ title: "Insufficient Credits",
74532
+ message: `Your ${provider} account has insufficient credits or quota.`,
74533
+ helpUrl: billingUrl,
74534
+ suggestion: "Add credits to your account to continue using the service."
74535
+ };
74536
+ }
74537
+ function formatRateLimit(provider, billingUrl, retryAfter) {
74538
+ return {
74539
+ title: "Rate Limit Exceeded",
74540
+ message: `You've made too many requests to ${provider}.`,
74541
+ helpUrl: billingUrl,
74542
+ suggestion: retryAfter ? `Please wait ${retryAfter} seconds before retrying.` : "Please wait a moment before retrying."
74543
+ };
74544
+ }
74545
+ function formatServiceUnavailable(provider, context) {
74546
+ return {
74547
+ title: "Service Unavailable",
74548
+ message: getServiceUnavailableMessage(provider, context),
74549
+ helpUrl: null,
74550
+ suggestion: "Please try again in a few moments."
74551
+ };
74552
+ }
74553
+ function formatAuthenticationError(provider, billingUrl) {
74554
+ return {
74555
+ title: "Authentication Failed",
74556
+ message: `Your ${provider} API key is invalid or expired.`,
74557
+ helpUrl: billingUrl,
74558
+ suggestion: "Run `oco setup` to configure a valid API key."
74559
+ };
74560
+ }
74561
+ function formatModelNotFound(provider, model) {
74562
+ return {
74563
+ title: "Model Not Found",
74564
+ message: `The model '${model}' is not available for ${provider}.`,
74565
+ helpUrl: null,
74566
+ suggestion: "Run `oco setup` to select a valid model."
74567
+ };
74568
+ }
74529
74569
  function formatUserFriendlyError(error, provider, context) {
74530
74570
  const billingUrl = PROVIDER_BILLING_URLS[provider] || null;
74531
74571
  if (error instanceof InsufficientCreditsError) {
74532
- return {
74533
- title: "Insufficient Credits",
74534
- message: `Your ${provider} account has insufficient credits or quota.`,
74535
- helpUrl: billingUrl,
74536
- suggestion: "Add credits to your account to continue using the service."
74537
- };
74572
+ return formatInsufficientCredits(provider, billingUrl);
74538
74573
  }
74539
74574
  if (error instanceof RateLimitError3) {
74540
- const retryMsg = error.retryAfter ? `Please wait ${error.retryAfter} seconds before retrying.` : "Please wait a moment before retrying.";
74541
- return {
74542
- title: "Rate Limit Exceeded",
74543
- message: `You've made too many requests to ${provider}.`,
74544
- helpUrl: billingUrl,
74545
- suggestion: retryMsg
74546
- };
74575
+ return formatRateLimit(provider, billingUrl, error.retryAfter);
74547
74576
  }
74548
74577
  if (error instanceof ServiceUnavailableError) {
74549
- return {
74550
- title: "Service Unavailable",
74551
- message: getServiceUnavailableMessage(provider, context),
74552
- helpUrl: null,
74553
- suggestion: "Please try again in a few moments."
74554
- };
74578
+ return formatServiceUnavailable(provider, context);
74555
74579
  }
74556
74580
  if (error instanceof AuthenticationError3) {
74557
- return {
74558
- title: "Authentication Failed",
74559
- message: `Your ${provider} API key is invalid or expired.`,
74560
- helpUrl: billingUrl,
74561
- suggestion: "Run `oco setup` to configure a valid API key."
74562
- };
74581
+ return formatAuthenticationError(provider, billingUrl);
74563
74582
  }
74564
74583
  if (error instanceof ModelNotFoundError) {
74565
- return {
74566
- title: "Model Not Found",
74567
- message: `The model '${error.modelName}' is not available for ${provider}.`,
74568
- helpUrl: null,
74569
- suggestion: "Run `oco setup` to select a valid model."
74570
- };
74584
+ return formatModelNotFound(provider, error.modelName);
74571
74585
  }
74572
74586
  if (isInsufficientCreditsError(error)) {
74573
- return {
74574
- title: "Insufficient Credits",
74575
- message: `Your ${provider} account has insufficient credits or quota.`,
74576
- helpUrl: billingUrl,
74577
- suggestion: "Add credits to your account to continue using the service."
74578
- };
74587
+ return formatInsufficientCredits(provider, billingUrl);
74579
74588
  }
74580
74589
  if (isRateLimitError(error)) {
74581
- return {
74582
- title: "Rate Limit Exceeded",
74583
- message: `You've made too many requests to ${provider}.`,
74584
- helpUrl: billingUrl,
74585
- suggestion: "Please wait a moment before retrying."
74586
- };
74590
+ return formatRateLimit(provider, billingUrl);
74587
74591
  }
74588
74592
  if (isServiceUnavailableError(error)) {
74589
- return {
74590
- title: "Service Unavailable",
74591
- message: getServiceUnavailableMessage(provider, context),
74592
- helpUrl: null,
74593
- suggestion: "Please try again in a few moments."
74594
- };
74593
+ return formatServiceUnavailable(provider, context);
74595
74594
  }
74596
74595
  if (isApiKeyError(error)) {
74597
- return {
74598
- title: "Authentication Failed",
74599
- message: `Your ${provider} API key is invalid or expired.`,
74600
- helpUrl: billingUrl,
74601
- suggestion: "Run `oco setup` to configure a valid API key."
74602
- };
74596
+ return formatAuthenticationError(provider, billingUrl);
74603
74597
  }
74604
74598
  if (isModelNotFoundError(error)) {
74605
74599
  const model = error.modelName || error.model || "unknown";
74606
- return {
74607
- title: "Model Not Found",
74608
- message: `The model '${model}' is not available for ${provider}.`,
74609
- helpUrl: null,
74610
- suggestion: "Run `oco setup` to select a valid model."
74611
- };
74600
+ return formatModelNotFound(provider, model);
74612
74601
  }
74613
74602
  const errorMessage = error instanceof Error ? error.message : String(error);
74614
74603
  return {
@@ -74792,15 +74781,80 @@ var cl100k_base_default = { pat_str: "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L
74792
74781
 
74793
74782
  // src/utils/tokenCount.ts
74794
74783
  var import_lite = __toESM(require_tiktoken(), 1);
74795
- function tokenCount(content) {
74796
- const encoding = new import_lite.Tiktoken(
74784
+ var TOKENIZER_CHUNK_LENGTH = 8e3;
74785
+ var encoding;
74786
+ var getEncoding = () => {
74787
+ encoding ??= new import_lite.Tiktoken(
74797
74788
  cl100k_base_default.bpe_ranks,
74798
74789
  cl100k_base_default.special_tokens,
74799
74790
  cl100k_base_default.pat_str
74800
74791
  );
74801
- const tokens = encoding.encode(content);
74802
- encoding.free();
74803
- return tokens.length;
74792
+ return encoding;
74793
+ };
74794
+ var getSafeSliceEnd = (content, start, length) => {
74795
+ let end = Math.min(start + length, content.length);
74796
+ if (end < content.length && end > start && /[\uD800-\uDBFF]/.test(content[end - 1]) && /[\uDC00-\uDFFF]/.test(content[end])) {
74797
+ end -= 1;
74798
+ }
74799
+ return end;
74800
+ };
74801
+ var getTextChunks = (content) => {
74802
+ const chunks = [];
74803
+ for (let start = 0; start < content.length; ) {
74804
+ const end = getSafeSliceEnd(content, start, TOKENIZER_CHUNK_LENGTH);
74805
+ chunks.push(content.slice(start, end));
74806
+ start = end;
74807
+ }
74808
+ return chunks;
74809
+ };
74810
+ var countTextChunk = (content) => getEncoding().encode(content).length;
74811
+ var yieldToEventLoop = () => new Promise((resolve) => setImmediate(resolve));
74812
+ function tokenCount(content) {
74813
+ return getTextChunks(content).reduce(
74814
+ (total, chunk) => total + countTextChunk(chunk),
74815
+ 0
74816
+ );
74817
+ }
74818
+ async function tokenCountAsync(content) {
74819
+ let total = 0;
74820
+ for (const chunk of getTextChunks(content)) {
74821
+ total += countTextChunk(chunk);
74822
+ await yieldToEventLoop();
74823
+ }
74824
+ return total;
74825
+ }
74826
+ var getBoundedTokenChunks = async (content, maxTokens) => {
74827
+ const tokens = countTextChunk(content);
74828
+ await yieldToEventLoop();
74829
+ if (tokens <= maxTokens) return [{ content, tokens }];
74830
+ const middle = getSafeSliceEnd(content, 0, Math.floor(content.length / 2));
74831
+ if (middle === 0 || middle === content.length) return [{ content, tokens }];
74832
+ return [
74833
+ ...await getBoundedTokenChunks(content.slice(0, middle), maxTokens),
74834
+ ...await getBoundedTokenChunks(content.slice(middle), maxTokens)
74835
+ ];
74836
+ };
74837
+ async function splitByTokenLimit(content, maxTokens) {
74838
+ if (maxTokens <= 0) throw new Error("maxTokens must be greater than zero");
74839
+ if (!content) return [];
74840
+ const countedChunks = [];
74841
+ for (const chunk of getTextChunks(content)) {
74842
+ countedChunks.push(...await getBoundedTokenChunks(chunk, maxTokens));
74843
+ }
74844
+ const mergedChunks = [];
74845
+ let currentContent = "";
74846
+ let currentTokens = 0;
74847
+ for (const chunk of countedChunks) {
74848
+ if (currentContent && currentTokens + chunk.tokens > maxTokens) {
74849
+ mergedChunks.push(currentContent);
74850
+ currentContent = "";
74851
+ currentTokens = 0;
74852
+ }
74853
+ currentContent += chunk.content;
74854
+ currentTokens += chunk.tokens;
74855
+ }
74856
+ if (currentContent) mergedChunks.push(currentContent);
74857
+ return mergedChunks;
74804
74858
  }
74805
74859
 
74806
74860
  // src/engine/anthropic.ts
@@ -85395,15 +85449,20 @@ var getMainCommitPrompt = async (fullGitMojiSpec, context) => {
85395
85449
  };
85396
85450
 
85397
85451
  // src/utils/mergeDiffs.ts
85398
- function mergeDiffs(arr, maxStringLength) {
85452
+ async function mergeDiffs(arr, maxStringLength) {
85453
+ if (!arr.length) return [];
85399
85454
  const mergedArr = [];
85400
85455
  let currentItem = arr[0];
85456
+ let currentItemTokens = await tokenCountAsync(currentItem);
85401
85457
  for (const item of arr.slice(1)) {
85402
- if (tokenCount(currentItem + item) <= maxStringLength) {
85458
+ const itemTokens = await tokenCountAsync(item);
85459
+ if (currentItemTokens + itemTokens <= maxStringLength) {
85403
85460
  currentItem += item;
85461
+ currentItemTokens += itemTokens;
85404
85462
  } else {
85405
85463
  mergedArr.push(currentItem);
85406
85464
  currentItem = item;
85465
+ currentItemTokens = itemTokens;
85407
85466
  }
85408
85467
  }
85409
85468
  mergedArr.push(currentItem);
@@ -85504,7 +85563,7 @@ var generateCommitMessageByDiff = async (diff, fullGitMojiSpec = false, context
85504
85563
  (msg) => tokenCount(msg.content) + 4
85505
85564
  ).reduce((a4, b7) => a4 + b7, 0);
85506
85565
  const MAX_REQUEST_TOKENS = MAX_TOKENS_INPUT - ADJUSTMENT_FACTOR - INIT_MESSAGES_PROMPT_LENGTH - MAX_TOKENS_OUTPUT;
85507
- if (tokenCount(diff) >= MAX_REQUEST_TOKENS) {
85566
+ if (await tokenCountAsync(diff) >= MAX_REQUEST_TOKENS) {
85508
85567
  const commitMessagePromises = await getCommitMsgsPromisesFromFileDiffs(
85509
85568
  diff,
85510
85569
  MAX_REQUEST_TOKENS,
@@ -85550,18 +85609,18 @@ var generateCommitMessageByDiff = async (diff, fullGitMojiSpec = false, context
85550
85609
  throw error;
85551
85610
  }
85552
85611
  };
85553
- function getMessagesPromisesByChangesInFile(fileDiff, separator, maxChangeLength, fullGitMojiSpec, context) {
85612
+ async function getMessagesPromisesByChangesInFile(fileDiff, separator, maxChangeLength, fullGitMojiSpec, context) {
85554
85613
  const hunkHeaderSeparator = "@@ ";
85555
85614
  const [fileHeader, ...fileDiffByLines] = fileDiff.split(hunkHeaderSeparator);
85556
- const mergedChanges = mergeDiffs(
85615
+ const mergedChanges = await mergeDiffs(
85557
85616
  fileDiffByLines.map((line) => hunkHeaderSeparator + line),
85558
85617
  maxChangeLength
85559
85618
  );
85560
85619
  const lineDiffsWithHeader = [];
85561
85620
  for (const change of mergedChanges) {
85562
85621
  const totalChange = fileHeader + change;
85563
- if (tokenCount(totalChange) > maxChangeLength) {
85564
- const splitChanges = splitDiff(totalChange, maxChangeLength);
85622
+ if (await tokenCountAsync(totalChange) > maxChangeLength) {
85623
+ const splitChanges = await splitDiff(totalChange, maxChangeLength);
85565
85624
  lineDiffsWithHeader.push(...splitChanges);
85566
85625
  } else {
85567
85626
  lineDiffsWithHeader.push(totalChange);
@@ -85580,39 +85639,20 @@ function getMessagesPromisesByChangesInFile(fileDiff, separator, maxChangeLength
85580
85639
  );
85581
85640
  return commitMsgsFromFileLineDiffs;
85582
85641
  }
85583
- function splitDiff(diff, maxChangeLength) {
85584
- const lines = diff.split("\n");
85585
- const splitDiffs = [];
85586
- let currentDiff = "";
85642
+ async function splitDiff(diff, maxChangeLength) {
85587
85643
  if (maxChangeLength <= 0) {
85588
85644
  throw new Error(GenerateCommitMessageErrorEnum.outputTokensTooHigh);
85589
85645
  }
85590
- for (let line of lines) {
85591
- while (tokenCount(line) > maxChangeLength) {
85592
- const subLine = line.substring(0, maxChangeLength);
85593
- line = line.substring(maxChangeLength);
85594
- splitDiffs.push(subLine);
85595
- }
85596
- if (tokenCount(currentDiff) + tokenCount("\n" + line) > maxChangeLength) {
85597
- splitDiffs.push(currentDiff);
85598
- currentDiff = line;
85599
- } else {
85600
- currentDiff += "\n" + line;
85601
- }
85602
- }
85603
- if (currentDiff) {
85604
- splitDiffs.push(currentDiff);
85605
- }
85606
- return splitDiffs;
85646
+ return splitByTokenLimit(diff, maxChangeLength);
85607
85647
  }
85608
85648
  var getCommitMsgsPromisesFromFileDiffs = async (diff, maxDiffLength, fullGitMojiSpec, context) => {
85609
85649
  const separator = "diff --git ";
85610
85650
  const diffByFiles = diff.split(separator).slice(1);
85611
- const mergedFilesDiffs = mergeDiffs(diffByFiles, maxDiffLength);
85651
+ const mergedFilesDiffs = await mergeDiffs(diffByFiles, maxDiffLength);
85612
85652
  const commitMessagePromises = [];
85613
85653
  for (const fileDiff of mergedFilesDiffs) {
85614
- if (tokenCount(fileDiff) >= maxDiffLength) {
85615
- const messagesPromises = getMessagesPromisesByChangesInFile(
85654
+ if (await tokenCountAsync(fileDiff) >= maxDiffLength) {
85655
+ const messagesPromises = await getMessagesPromisesByChangesInFile(
85616
85656
  fileDiff,
85617
85657
  separator,
85618
85658
  maxDiffLength,
@@ -85727,6 +85767,21 @@ var getGitDir = async () => {
85727
85767
  return gitDir;
85728
85768
  };
85729
85769
 
85770
+ // src/utils/gitPush.ts
85771
+ function buildGitPushArgs(options, upstreamBranch) {
85772
+ const args = ["push"];
85773
+ if (options.mode === "remote") {
85774
+ if (options.verbose) args.push("--verbose");
85775
+ args.push(options.remote);
85776
+ }
85777
+ if (upstreamBranch !== null) {
85778
+ args.push("--set-upstream");
85779
+ if (options.mode === "default") args.push(options.fallbackRemote);
85780
+ args.push(upstreamBranch);
85781
+ }
85782
+ return args;
85783
+ }
85784
+
85730
85785
  // src/utils/trytm.ts
85731
85786
  var trytm = async (promise) => {
85732
85787
  try {
@@ -85761,6 +85816,10 @@ var getCurrentBranch = async () => {
85761
85816
  const { stdout } = await execa("git", ["branch", "--show-current"]);
85762
85817
  return stdout.trim();
85763
85818
  };
85819
+ var runGitPush = async (options) => {
85820
+ const upstreamBranch = await hasUpstreamBranch() ? null : await getCurrentBranch();
85821
+ return await execa("git", buildGitPushArgs(options, upstreamBranch));
85822
+ };
85764
85823
  var displayPushUrl = (stderr2) => {
85765
85824
  const urlMatch = stderr2.match(/https?:\/\/\S+/);
85766
85825
  if (urlMatch) {
@@ -85838,11 +85897,10 @@ ${source_default.grey("\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2
85838
85897
  const remotes = await getGitRemotes();
85839
85898
  if (config6.OCO_GITPUSH === false) return;
85840
85899
  if (!remotes.length) {
85841
- const pushArgs = ["push"];
85842
- if (!await hasUpstreamBranch()) {
85843
- pushArgs.push("--set-upstream", "origin", await getCurrentBranch());
85844
- }
85845
- const { stdout: stdout2, stderr: stderr2 } = await execa("git", pushArgs);
85900
+ const { stdout: stdout2, stderr: stderr2 } = await runGitPush({
85901
+ mode: "default",
85902
+ fallbackRemote: "origin"
85903
+ });
85846
85904
  if (stdout2) ce(stdout2);
85847
85905
  displayPushUrl(stderr2);
85848
85906
  process.exit(0);
@@ -85855,11 +85913,11 @@ ${source_default.grey("\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2
85855
85913
  if (isPushConfirmedByUser) {
85856
85914
  const pushSpinner = le();
85857
85915
  pushSpinner.start(`Running 'git push ${remotes[0]}'`);
85858
- const pushArgs = ["push", "--verbose", remotes[0]];
85859
- if (!await hasUpstreamBranch()) {
85860
- pushArgs.push("--set-upstream", await getCurrentBranch());
85861
- }
85862
- const { stdout: stdout2, stderr: stderr2 } = await execa("git", pushArgs);
85916
+ const { stdout: stdout2, stderr: stderr2 } = await runGitPush({
85917
+ mode: "remote",
85918
+ remote: remotes[0],
85919
+ verbose: true
85920
+ });
85863
85921
  pushSpinner.stop(
85864
85922
  `${source_default.green("\u2714")} Successfully pushed all commits to ${remotes[0]}`
85865
85923
  );
@@ -85882,11 +85940,11 @@ ${source_default.grey("\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2
85882
85940
  if (selectedRemote !== skipOption) {
85883
85941
  const pushSpinner = le();
85884
85942
  pushSpinner.start(`Running 'git push ${selectedRemote}'`);
85885
- const pushArgs = ["push", selectedRemote];
85886
- if (!await hasUpstreamBranch()) {
85887
- pushArgs.push("--set-upstream", await getCurrentBranch());
85888
- }
85889
- const { stdout: stdout2, stderr: stderr2 } = await execa("git", pushArgs);
85943
+ const { stdout: stdout2, stderr: stderr2 } = await runGitPush({
85944
+ mode: "remote",
85945
+ remote: selectedRemote,
85946
+ verbose: false
85947
+ });
85890
85948
  if (stdout2) ce(stdout2);
85891
85949
  pushSpinner.stop(
85892
85950
  `${source_default.green(
@@ -86214,136 +86272,89 @@ function isCacheValid(cache) {
86214
86272
  if (!cache) return false;
86215
86273
  return Date.now() - cache.timestamp < CACHE_TTL_MS;
86216
86274
  }
86217
- async function fetchOpenAIModels(apiKey) {
86275
+ async function fetchModelList({
86276
+ url: url2,
86277
+ headers,
86278
+ fallback,
86279
+ mapModels
86280
+ }) {
86218
86281
  try {
86219
- const response = await fetch("https://api.openai.com/v1/models", {
86220
- headers: {
86221
- Authorization: `Bearer ${apiKey}`
86222
- }
86223
- });
86282
+ const response = headers ? await fetch(url2, { headers }) : await fetch(url2);
86224
86283
  if (!response.ok) {
86225
- return MODEL_LIST.openai;
86284
+ return fallback;
86226
86285
  }
86227
- const data = await response.json();
86228
- const models = data.data.map((m5) => m5.id).filter(
86229
- (id) => id.startsWith("gpt-") || id.startsWith("o1") || id.startsWith("o3") || id.startsWith("o4")
86230
- ).sort();
86231
- return models.length > 0 ? models : MODEL_LIST.openai;
86286
+ const models = mapModels(await response.json());
86287
+ return models && models.length > 0 ? models : fallback;
86232
86288
  } catch {
86233
- return MODEL_LIST.openai;
86289
+ return fallback;
86234
86290
  }
86235
86291
  }
86292
+ async function fetchOpenAIModels(apiKey) {
86293
+ return fetchModelList({
86294
+ url: "https://api.openai.com/v1/models",
86295
+ headers: { Authorization: `Bearer ${apiKey}` },
86296
+ fallback: MODEL_LIST.openai,
86297
+ mapModels: (data) => data.data.map((model) => model.id).filter(
86298
+ (id) => id.startsWith("gpt-") || id.startsWith("o1") || id.startsWith("o3") || id.startsWith("o4")
86299
+ ).sort()
86300
+ });
86301
+ }
86236
86302
  async function fetchOllamaModels(baseUrl = "http://localhost:11434") {
86237
- try {
86238
- const response = await fetch(`${baseUrl}/api/tags`);
86239
- if (!response.ok) {
86240
- return [];
86241
- }
86242
- const data = await response.json();
86243
- return data.models?.map((m5) => m5.name) || [];
86244
- } catch {
86245
- return [];
86246
- }
86303
+ return fetchModelList({
86304
+ url: `${baseUrl}/api/tags`,
86305
+ fallback: [],
86306
+ mapModels: (data) => data.models?.map((model) => model.name)
86307
+ });
86247
86308
  }
86248
86309
  async function fetchLlamaCppModels(baseUrl = "http://localhost:8080") {
86249
- try {
86250
- const response = await fetch(`${baseUrl}/v1/models`);
86251
- if (!response.ok) {
86252
- return [];
86253
- }
86254
- const data = await response.json();
86255
- return data.data?.map((m5) => m5.id) || [];
86256
- } catch {
86257
- return [];
86258
- }
86310
+ return fetchModelList({
86311
+ url: `${baseUrl}/v1/models`,
86312
+ fallback: [],
86313
+ mapModels: (data) => data.data?.map((model) => model.id)
86314
+ });
86259
86315
  }
86260
86316
  async function fetchAnthropicModels(apiKey) {
86261
- try {
86262
- const response = await fetch("https://api.anthropic.com/v1/models", {
86263
- headers: {
86264
- "x-api-key": apiKey,
86265
- "anthropic-version": "2023-06-01"
86266
- }
86267
- });
86268
- if (!response.ok) {
86269
- return MODEL_LIST.anthropic;
86270
- }
86271
- const data = await response.json();
86272
- const models = data.data?.map((m5) => m5.id).filter((id) => id.startsWith("claude-")).sort();
86273
- return models && models.length > 0 ? models : MODEL_LIST.anthropic;
86274
- } catch {
86275
- return MODEL_LIST.anthropic;
86276
- }
86317
+ return fetchModelList({
86318
+ url: "https://api.anthropic.com/v1/models",
86319
+ headers: {
86320
+ "x-api-key": apiKey,
86321
+ "anthropic-version": "2023-06-01"
86322
+ },
86323
+ fallback: MODEL_LIST.anthropic,
86324
+ mapModels: (data) => data.data?.map((model) => model.id).filter((id) => id.startsWith("claude-")).sort()
86325
+ });
86277
86326
  }
86278
86327
  async function fetchMistralModels(apiKey) {
86279
- try {
86280
- const response = await fetch("https://api.mistral.ai/v1/models", {
86281
- headers: {
86282
- Authorization: `Bearer ${apiKey}`
86283
- }
86284
- });
86285
- if (!response.ok) {
86286
- return MODEL_LIST.mistral;
86287
- }
86288
- const data = await response.json();
86289
- const models = data.data?.map((m5) => m5.id).sort();
86290
- return models && models.length > 0 ? models : MODEL_LIST.mistral;
86291
- } catch {
86292
- return MODEL_LIST.mistral;
86293
- }
86328
+ return fetchModelList({
86329
+ url: "https://api.mistral.ai/v1/models",
86330
+ headers: { Authorization: `Bearer ${apiKey}` },
86331
+ fallback: MODEL_LIST.mistral,
86332
+ mapModels: (data) => data.data?.map((model) => model.id).sort()
86333
+ });
86294
86334
  }
86295
86335
  async function fetchGroqModels(apiKey) {
86296
- try {
86297
- const response = await fetch("https://api.groq.com/openai/v1/models", {
86298
- headers: {
86299
- Authorization: `Bearer ${apiKey}`
86300
- }
86301
- });
86302
- if (!response.ok) {
86303
- return MODEL_LIST.groq;
86304
- }
86305
- const data = await response.json();
86306
- const models = data.data?.map((m5) => m5.id).sort();
86307
- return models && models.length > 0 ? models : MODEL_LIST.groq;
86308
- } catch {
86309
- return MODEL_LIST.groq;
86310
- }
86336
+ return fetchModelList({
86337
+ url: "https://api.groq.com/openai/v1/models",
86338
+ headers: { Authorization: `Bearer ${apiKey}` },
86339
+ fallback: MODEL_LIST.groq,
86340
+ mapModels: (data) => data.data?.map((model) => model.id).sort()
86341
+ });
86311
86342
  }
86312
86343
  async function fetchOpenRouterModels(apiKey) {
86313
- try {
86314
- const response = await fetch("https://openrouter.ai/api/v1/models", {
86315
- headers: {
86316
- Authorization: `Bearer ${apiKey}`
86317
- }
86318
- });
86319
- if (!response.ok) {
86320
- return MODEL_LIST.openrouter;
86321
- }
86322
- const data = await response.json();
86323
- const models = data.data?.filter(
86324
- (m5) => m5.context_length && m5.context_length > 0
86325
- ).map((m5) => m5.id).sort();
86326
- return models && models.length > 0 ? models : MODEL_LIST.openrouter;
86327
- } catch {
86328
- return MODEL_LIST.openrouter;
86329
- }
86344
+ return fetchModelList({
86345
+ url: "https://openrouter.ai/api/v1/models",
86346
+ headers: { Authorization: `Bearer ${apiKey}` },
86347
+ fallback: MODEL_LIST.openrouter,
86348
+ mapModels: (data) => data.data?.filter((model) => model.context_length && model.context_length > 0).map((model) => model.id).sort()
86349
+ });
86330
86350
  }
86331
86351
  async function fetchDeepSeekModels(apiKey) {
86332
- try {
86333
- const response = await fetch("https://api.deepseek.com/v1/models", {
86334
- headers: {
86335
- Authorization: `Bearer ${apiKey}`
86336
- }
86337
- });
86338
- if (!response.ok) {
86339
- return MODEL_LIST.deepseek;
86340
- }
86341
- const data = await response.json();
86342
- const models = data.data?.map((m5) => m5.id).sort();
86343
- return models && models.length > 0 ? models : MODEL_LIST.deepseek;
86344
- } catch {
86345
- return MODEL_LIST.deepseek;
86346
- }
86352
+ return fetchModelList({
86353
+ url: "https://api.deepseek.com/v1/models",
86354
+ headers: { Authorization: `Bearer ${apiKey}` },
86355
+ fallback: MODEL_LIST.deepseek,
86356
+ mapModels: (data) => data.data?.map((model) => model.id).sort()
86357
+ });
86347
86358
  }
86348
86359
  async function fetchModelsForProvider(provider, apiKey, baseUrl, forceRefresh = false) {
86349
86360
  const cache = readCache();
@@ -86441,52 +86452,111 @@ function getCachedModels(provider) {
86441
86452
  }
86442
86453
 
86443
86454
  // src/commands/setup.ts
86444
- var PROVIDER_DISPLAY_NAMES = {
86445
- ["openai" /* OPENAI */]: "OpenAI (GPT-4o, GPT-4)",
86446
- ["anthropic" /* ANTHROPIC */]: "Anthropic (Claude Sonnet, Opus)",
86447
- ["ollama" /* OLLAMA */]: "Ollama (Free, runs locally)",
86448
- ["llamacpp" /* LLAMACPP */]: "llama.cpp (Free, runs locally)",
86449
- ["gemini" /* GEMINI */]: "Google Gemini",
86450
- ["groq" /* GROQ */]: "Groq (Fast inference, free tier)",
86451
- ["mistral" /* MISTRAL */]: "Mistral AI",
86452
- ["deepseek" /* DEEPSEEK */]: "DeepSeek",
86453
- ["openrouter" /* OPENROUTER */]: "OpenRouter (Multiple providers)",
86454
- ["aimlapi" /* AIMLAPI */]: "AI/ML API",
86455
- ["azure" /* AZURE */]: "Azure OpenAI",
86456
- ["mlx" /* MLX */]: "MLX (Apple Silicon, local)"
86457
- };
86458
- var PRIMARY_PROVIDERS = [
86459
- "openai" /* OPENAI */,
86460
- "anthropic" /* ANTHROPIC */,
86461
- "ollama" /* OLLAMA */,
86462
- "llamacpp" /* LLAMACPP */
86463
- ];
86464
- var OTHER_PROVIDERS = [
86465
- "gemini" /* GEMINI */,
86466
- "groq" /* GROQ */,
86467
- "mistral" /* MISTRAL */,
86468
- "deepseek" /* DEEPSEEK */,
86469
- "openrouter" /* OPENROUTER */,
86470
- "aimlapi" /* AIMLAPI */,
86471
- "azure" /* AZURE */,
86472
- "mlx" /* MLX */
86473
- ];
86474
- var NO_API_KEY_PROVIDERS = [
86475
- "ollama" /* OLLAMA */,
86476
- "llamacpp" /* LLAMACPP */,
86477
- "mlx" /* MLX */,
86478
- "test" /* TEST */
86479
- ];
86480
- var MODEL_REQUIRED_PROVIDERS = [
86481
- "ollama" /* OLLAMA */,
86482
- "mlx" /* MLX */,
86483
- "llamacpp" /* LLAMACPP */
86455
+ var SETUP_PROVIDERS = [
86456
+ {
86457
+ provider: "openai" /* OPENAI */,
86458
+ displayName: "OpenAI (GPT)",
86459
+ selectionGroup: "primary",
86460
+ firstRunRequirement: "apiKey"
86461
+ },
86462
+ {
86463
+ provider: "anthropic" /* ANTHROPIC */,
86464
+ displayName: "Anthropic (Claude Sonnet, Opus)",
86465
+ selectionGroup: "primary",
86466
+ firstRunRequirement: "apiKey"
86467
+ },
86468
+ {
86469
+ provider: "ollama" /* OLLAMA */,
86470
+ displayName: "Ollama (Free, runs locally)",
86471
+ selectionGroup: "primary",
86472
+ firstRunRequirement: "model"
86473
+ },
86474
+ {
86475
+ provider: "llamacpp" /* LLAMACPP */,
86476
+ displayName: "llama.cpp (Free, runs locally)",
86477
+ selectionGroup: "primary",
86478
+ firstRunRequirement: "model"
86479
+ },
86480
+ {
86481
+ provider: "gemini" /* GEMINI */,
86482
+ displayName: "Google Gemini",
86483
+ selectionGroup: "other",
86484
+ firstRunRequirement: "apiKey"
86485
+ },
86486
+ {
86487
+ provider: "groq" /* GROQ */,
86488
+ displayName: "Groq (Fast inference, free tier)",
86489
+ selectionGroup: "other",
86490
+ firstRunRequirement: "apiKey"
86491
+ },
86492
+ {
86493
+ provider: "mistral" /* MISTRAL */,
86494
+ displayName: "Mistral AI",
86495
+ selectionGroup: "other",
86496
+ firstRunRequirement: "apiKey"
86497
+ },
86498
+ {
86499
+ provider: "deepseek" /* DEEPSEEK */,
86500
+ displayName: "DeepSeek",
86501
+ selectionGroup: "other",
86502
+ firstRunRequirement: "apiKey"
86503
+ },
86504
+ {
86505
+ provider: "openrouter" /* OPENROUTER */,
86506
+ displayName: "OpenRouter (Multiple providers)",
86507
+ selectionGroup: "other",
86508
+ firstRunRequirement: "apiKey"
86509
+ },
86510
+ {
86511
+ provider: "aimlapi" /* AIMLAPI */,
86512
+ displayName: "AI/ML API",
86513
+ selectionGroup: "other",
86514
+ firstRunRequirement: "apiKey"
86515
+ },
86516
+ {
86517
+ provider: "azure" /* AZURE */,
86518
+ displayName: "Azure OpenAI",
86519
+ selectionGroup: "other",
86520
+ firstRunRequirement: "apiKey"
86521
+ },
86522
+ {
86523
+ provider: "mlx" /* MLX */,
86524
+ displayName: "MLX (Apple Silicon, local)",
86525
+ selectionGroup: "other",
86526
+ firstRunRequirement: "model"
86527
+ },
86528
+ {
86529
+ provider: "flowise" /* FLOWISE */,
86530
+ displayName: "flowise" /* FLOWISE */,
86531
+ selectionGroup: "hidden",
86532
+ firstRunRequirement: "apiKey"
86533
+ },
86534
+ {
86535
+ provider: "test" /* TEST */,
86536
+ displayName: "test" /* TEST */,
86537
+ selectionGroup: "hidden",
86538
+ firstRunRequirement: "none"
86539
+ }
86484
86540
  ];
86485
- async function selectProvider() {
86486
- const primaryOptions = PRIMARY_PROVIDERS.map((provider) => ({
86487
- value: provider,
86488
- label: PROVIDER_DISPLAY_NAMES[provider] || provider
86541
+ function getProviderDefinition(provider) {
86542
+ return SETUP_PROVIDERS.find((definition) => definition.provider === provider);
86543
+ }
86544
+ function getProviderOptions(group) {
86545
+ return SETUP_PROVIDERS.filter(
86546
+ (definition) => definition.selectionGroup === group
86547
+ ).map((definition) => ({
86548
+ value: definition.provider,
86549
+ label: definition.displayName
86489
86550
  }));
86551
+ }
86552
+ function getProviderDisplayName(provider) {
86553
+ return getProviderDefinition(provider)?.displayName || provider;
86554
+ }
86555
+ function getFirstRunRequirement(provider) {
86556
+ return getProviderDefinition(provider)?.firstRunRequirement || "apiKey";
86557
+ }
86558
+ async function selectProvider() {
86559
+ const primaryOptions = getProviderOptions("primary");
86490
86560
  primaryOptions.push({
86491
86561
  value: "other",
86492
86562
  label: "Other providers..."
@@ -86497,13 +86567,9 @@ async function selectProvider() {
86497
86567
  });
86498
86568
  if (hD2(selection)) return selection;
86499
86569
  if (selection === "other") {
86500
- const otherOptions = OTHER_PROVIDERS.map((provider) => ({
86501
- value: provider,
86502
- label: PROVIDER_DISPLAY_NAMES[provider] || provider
86503
- }));
86504
86570
  return await ee({
86505
86571
  message: "Select provider:",
86506
- options: otherOptions
86572
+ options: getProviderOptions("other")
86507
86573
  });
86508
86574
  }
86509
86575
  return selection;
@@ -86539,7 +86605,7 @@ function formatCacheAge(timestamp) {
86539
86605
  return "just now";
86540
86606
  }
86541
86607
  async function selectModel(provider, apiKey) {
86542
- const providerDisplayName = PROVIDER_DISPLAY_NAMES[provider]?.split(" (")[0] || provider;
86608
+ const providerDisplayName = getProviderDisplayName(provider).split(" (")[0] || provider;
86543
86609
  const loadingSpinner = le();
86544
86610
  loadingSpinner.start(`Fetching models from ${providerDisplayName}...`);
86545
86611
  let models = [];
@@ -86563,7 +86629,7 @@ async function selectModel(provider, apiKey) {
86563
86629
  loadingSpinner.stop("Models loaded");
86564
86630
  }
86565
86631
  if (models.length === 0) {
86566
- if (NO_API_KEY_PROVIDERS.includes(provider)) {
86632
+ if (getFirstRunRequirement(provider) !== "apiKey") {
86567
86633
  return await J4({
86568
86634
  message: "Enter model name (e.g., llama3:8b, mistral):",
86569
86635
  placeholder: "llama3:8b",
@@ -86805,18 +86871,14 @@ function isFirstRun() {
86805
86871
  const hasGlobalConfig = getIsGlobalConfigFileExist();
86806
86872
  const config8 = getConfig();
86807
86873
  const provider = config8.OCO_AI_PROVIDER || "openai" /* OPENAI */;
86808
- if (provider === "test" /* TEST */) {
86809
- return false;
86810
- }
86811
- const hasRequiredConfig = MODEL_REQUIRED_PROVIDERS.includes(
86812
- provider
86813
- ) ? Boolean(config8.OCO_MODEL) : Boolean(config8.OCO_API_KEY);
86874
+ const requirement = getFirstRunRequirement(provider);
86875
+ const hasRequiredConfig = requirement === "model" ? Boolean(config8.OCO_MODEL) : requirement === "apiKey" ? Boolean(config8.OCO_API_KEY) : true;
86814
86876
  return !hasGlobalConfig && !hasRequiredConfig;
86815
86877
  }
86816
86878
  async function promptForMissingApiKey() {
86817
86879
  const config8 = getConfig();
86818
86880
  const provider = config8.OCO_AI_PROVIDER || "openai" /* OPENAI */;
86819
- if (NO_API_KEY_PROVIDERS.includes(provider)) {
86881
+ if (getFirstRunRequirement(provider) !== "apiKey") {
86820
86882
  return true;
86821
86883
  }
86822
86884
  if (config8.OCO_API_KEY) {
@@ -87163,30 +87225,40 @@ var runMigrations = async () => {
87163
87225
  }
87164
87226
  };
87165
87227
 
87166
- // src/cli.ts
87167
- var config7 = getConfig();
87168
- setupProxy(resolveProxy(config7.OCO_PROXY));
87169
- var OCO_FLAGS_WITH_VALUE = /* @__PURE__ */ new Set(["-c", "--context"]);
87170
- var OCO_BOOLEAN_FLAGS = /* @__PURE__ */ new Set(["-y", "--yes", "--fgm"]);
87171
- var OCO_EQUALS_PREFIXES = ["-c=", "--context=", "-y=", "--yes=", "--fgm="];
87172
- var stripOcoFlags = (argv) => {
87173
- const out = [];
87174
- for (let i3 = 0; i3 < argv.length; i3++) {
87175
- const a4 = argv[i3];
87176
- if (OCO_FLAGS_WITH_VALUE.has(a4)) {
87177
- i3++;
87178
- continue;
87179
- }
87180
- if (OCO_BOOLEAN_FLAGS.has(a4)) {
87181
- continue;
87182
- }
87183
- if (OCO_EQUALS_PREFIXES.some((prefix) => a4.startsWith(prefix))) {
87228
+ // src/utils/stripOcoFlags.ts
87229
+ var OCO_FLAG_SPECS = [
87230
+ {
87231
+ names: ["-c", "--context"],
87232
+ consumesNextToken: true
87233
+ },
87234
+ {
87235
+ names: ["-y", "--yes", "--fgm"],
87236
+ consumesNextToken: false
87237
+ }
87238
+ ];
87239
+ function stripOcoFlags(argv) {
87240
+ const forwardedArgs = [];
87241
+ for (let index = 0; index < argv.length; index++) {
87242
+ const argument = argv[index];
87243
+ const exactFlag = OCO_FLAG_SPECS.find(
87244
+ (spec) => spec.names.includes(argument)
87245
+ );
87246
+ if (exactFlag) {
87247
+ if (exactFlag.consumesNextToken) index++;
87184
87248
  continue;
87185
87249
  }
87186
- out.push(a4);
87250
+ const isEqualsForm = OCO_FLAG_SPECS.some(
87251
+ (spec) => spec.names.some((name) => argument.startsWith(`${name}=`))
87252
+ );
87253
+ if (isEqualsForm) continue;
87254
+ forwardedArgs.push(argument);
87187
87255
  }
87188
- return out;
87189
- };
87256
+ return forwardedArgs;
87257
+ }
87258
+
87259
+ // src/cli.ts
87260
+ var config7 = getConfig();
87261
+ setupProxy(resolveProxy(config7.OCO_PROXY));
87190
87262
  var rawArgv = process.argv.slice(2);
87191
87263
  var extraArgs = stripOcoFlags(rawArgv);
87192
87264
  Z2(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencommit",
3
- "version": "3.3.9",
3
+ "version": "3.3.10",
4
4
  "description": "Auto-generate impressive commits in 1 second. Killing lame commits with AI 🤯🔫",
5
5
  "keywords": [
6
6
  "git",