diff --git a/README.md b/README.md
index f993bb3..c920685 100644
--- a/README.md
+++ b/README.md
@@ -7,8 +7,7 @@
Auto-generate meaningful commits in 1 second
Killing lame commits with AI 🤯🔫
- 🪩 Winner of GitHub 2023 HACKATHON
-
+
---
@@ -57,6 +56,17 @@ git add
oco
```
+You can also run it with local model through ollama:
+- install and start ollama
+- run `ollama run mistral` (do this only once, to pull model)
+- run (in your project directory):
+
+```sh
+git add
+AI_PROVIDER='ollama' opencommit
+```
+
+
## Configuration
### Local per repo configuration
diff --git a/out/cli.cjs b/out/cli.cjs
index 0eea285..bc7c85c 100755
--- a/out/cli.cjs
+++ b/out/cli.cjs
@@ -14495,76 +14495,6 @@ var require_dist = __commonJS({
}
});
-// node_modules/proxy-from-env/index.js
-var require_proxy_from_env = __commonJS({
- "node_modules/proxy-from-env/index.js"(exports) {
- "use strict";
- var parseUrl = require("url").parse;
- var DEFAULT_PORTS = {
- ftp: 21,
- gopher: 70,
- http: 80,
- https: 443,
- ws: 80,
- wss: 443
- };
- var stringEndsWith = String.prototype.endsWith || function(s) {
- return s.length <= this.length && this.indexOf(s, this.length - s.length) !== -1;
- };
- function getProxyForUrl2(url3) {
- var parsedUrl = typeof url3 === "string" ? parseUrl(url3) : url3 || {};
- var proto2 = parsedUrl.protocol;
- var hostname = parsedUrl.host;
- var port = parsedUrl.port;
- if (typeof hostname !== "string" || !hostname || typeof proto2 !== "string") {
- return "";
- }
- proto2 = proto2.split(":", 1)[0];
- hostname = hostname.replace(/:\d*$/, "");
- port = parseInt(port) || DEFAULT_PORTS[proto2] || 0;
- if (!shouldProxy(hostname, port)) {
- return "";
- }
- var proxy = getEnv2("npm_config_" + proto2 + "_proxy") || getEnv2(proto2 + "_proxy") || getEnv2("npm_config_proxy") || getEnv2("all_proxy");
- if (proxy && proxy.indexOf("://") === -1) {
- proxy = proto2 + "://" + proxy;
- }
- return proxy;
- }
- function shouldProxy(hostname, port) {
- var NO_PROXY = (getEnv2("npm_config_no_proxy") || getEnv2("no_proxy")).toLowerCase();
- if (!NO_PROXY) {
- return true;
- }
- if (NO_PROXY === "*") {
- return false;
- }
- return NO_PROXY.split(/[,\s]/).every(function(proxy) {
- if (!proxy) {
- return true;
- }
- var parsedProxy = proxy.match(/^(.+):(\d+)$/);
- var parsedProxyHostname = parsedProxy ? parsedProxy[1] : proxy;
- var parsedProxyPort = parsedProxy ? parseInt(parsedProxy[2]) : 0;
- if (parsedProxyPort && parsedProxyPort !== port) {
- return true;
- }
- if (!/^[.*]/.test(parsedProxyHostname)) {
- return hostname !== parsedProxyHostname;
- }
- if (parsedProxyHostname.charAt(0) === "*") {
- parsedProxyHostname = parsedProxyHostname.slice(1);
- }
- return !stringEndsWith.call(hostname, parsedProxyHostname);
- });
- }
- function getEnv2(key) {
- return process.env[key.toLowerCase()] || process.env[key.toUpperCase()] || "";
- }
- exports.getProxyForUrl = getProxyForUrl2;
- }
-});
-
// node_modules/dotenv/package.json
var require_package2 = __commonJS({
"node_modules/dotenv/package.json"(exports, module2) {
@@ -14893,6 +14823,188 @@ var require_ini = __commonJS({
}
});
+// node_modules/@commitlint/types/lib/ensure.js
+var require_ensure = __commonJS({
+ "node_modules/@commitlint/types/lib/ensure.js"(exports) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ }
+});
+
+// node_modules/@commitlint/types/lib/format.js
+var require_format = __commonJS({
+ "node_modules/@commitlint/types/lib/format.js"(exports) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ }
+});
+
+// node_modules/@commitlint/types/lib/is-ignored.js
+var require_is_ignored = __commonJS({
+ "node_modules/@commitlint/types/lib/is-ignored.js"(exports) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ }
+});
+
+// node_modules/@commitlint/types/lib/lint.js
+var require_lint = __commonJS({
+ "node_modules/@commitlint/types/lib/lint.js"(exports) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ }
+});
+
+// node_modules/@commitlint/types/lib/load.js
+var require_load = __commonJS({
+ "node_modules/@commitlint/types/lib/load.js"(exports) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ }
+});
+
+// node_modules/@commitlint/types/lib/parse.js
+var require_parse2 = __commonJS({
+ "node_modules/@commitlint/types/lib/parse.js"(exports) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ }
+});
+
+// node_modules/@commitlint/types/lib/prompt.js
+var require_prompt = __commonJS({
+ "node_modules/@commitlint/types/lib/prompt.js"(exports) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ }
+});
+
+// node_modules/@commitlint/types/lib/rules.js
+var require_rules = __commonJS({
+ "node_modules/@commitlint/types/lib/rules.js"(exports) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.RuleConfigQuality = exports.RuleConfigSeverity = void 0;
+ var RuleConfigSeverity2;
+ (function(RuleConfigSeverity3) {
+ RuleConfigSeverity3[RuleConfigSeverity3["Disabled"] = 0] = "Disabled";
+ RuleConfigSeverity3[RuleConfigSeverity3["Warning"] = 1] = "Warning";
+ RuleConfigSeverity3[RuleConfigSeverity3["Error"] = 2] = "Error";
+ })(RuleConfigSeverity2 = exports.RuleConfigSeverity || (exports.RuleConfigSeverity = {}));
+ var RuleConfigQuality;
+ (function(RuleConfigQuality2) {
+ RuleConfigQuality2[RuleConfigQuality2["User"] = 0] = "User";
+ RuleConfigQuality2[RuleConfigQuality2["Qualified"] = 1] = "Qualified";
+ })(RuleConfigQuality = exports.RuleConfigQuality || (exports.RuleConfigQuality = {}));
+ }
+});
+
+// node_modules/@commitlint/types/lib/index.js
+var require_lib = __commonJS({
+ "node_modules/@commitlint/types/lib/index.js"(exports) {
+ "use strict";
+ var __createBinding = exports && exports.__createBinding || (Object.create ? function(o2, m4, k6, k22) {
+ if (k22 === void 0)
+ k22 = k6;
+ var desc = Object.getOwnPropertyDescriptor(m4, k6);
+ if (!desc || ("get" in desc ? !m4.__esModule : desc.writable || desc.configurable)) {
+ desc = { enumerable: true, get: function() {
+ return m4[k6];
+ } };
+ }
+ Object.defineProperty(o2, k22, desc);
+ } : function(o2, m4, k6, k22) {
+ if (k22 === void 0)
+ k22 = k6;
+ o2[k22] = m4[k6];
+ });
+ var __exportStar = exports && exports.__exportStar || function(m4, exports2) {
+ for (var p4 in m4)
+ if (p4 !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p4))
+ __createBinding(exports2, m4, p4);
+ };
+ Object.defineProperty(exports, "__esModule", { value: true });
+ __exportStar(require_ensure(), exports);
+ __exportStar(require_format(), exports);
+ __exportStar(require_is_ignored(), exports);
+ __exportStar(require_lint(), exports);
+ __exportStar(require_load(), exports);
+ __exportStar(require_parse2(), exports);
+ __exportStar(require_prompt(), exports);
+ __exportStar(require_rules(), exports);
+ }
+});
+
+// node_modules/proxy-from-env/index.js
+var require_proxy_from_env = __commonJS({
+ "node_modules/proxy-from-env/index.js"(exports) {
+ "use strict";
+ var parseUrl = require("url").parse;
+ var DEFAULT_PORTS = {
+ ftp: 21,
+ gopher: 70,
+ http: 80,
+ https: 443,
+ ws: 80,
+ wss: 443
+ };
+ var stringEndsWith = String.prototype.endsWith || function(s) {
+ return s.length <= this.length && this.indexOf(s, this.length - s.length) !== -1;
+ };
+ function getProxyForUrl2(url3) {
+ var parsedUrl = typeof url3 === "string" ? parseUrl(url3) : url3 || {};
+ var proto2 = parsedUrl.protocol;
+ var hostname = parsedUrl.host;
+ var port = parsedUrl.port;
+ if (typeof hostname !== "string" || !hostname || typeof proto2 !== "string") {
+ return "";
+ }
+ proto2 = proto2.split(":", 1)[0];
+ hostname = hostname.replace(/:\d*$/, "");
+ port = parseInt(port) || DEFAULT_PORTS[proto2] || 0;
+ if (!shouldProxy(hostname, port)) {
+ return "";
+ }
+ var proxy = getEnv2("npm_config_" + proto2 + "_proxy") || getEnv2(proto2 + "_proxy") || getEnv2("npm_config_proxy") || getEnv2("all_proxy");
+ if (proxy && proxy.indexOf("://") === -1) {
+ proxy = proto2 + "://" + proxy;
+ }
+ return proxy;
+ }
+ function shouldProxy(hostname, port) {
+ var NO_PROXY = (getEnv2("npm_config_no_proxy") || getEnv2("no_proxy")).toLowerCase();
+ if (!NO_PROXY) {
+ return true;
+ }
+ if (NO_PROXY === "*") {
+ return false;
+ }
+ return NO_PROXY.split(/[,\s]/).every(function(proxy) {
+ if (!proxy) {
+ return true;
+ }
+ var parsedProxy = proxy.match(/^(.+):(\d+)$/);
+ var parsedProxyHostname = parsedProxy ? parsedProxy[1] : proxy;
+ var parsedProxyPort = parsedProxy ? parseInt(parsedProxy[2]) : 0;
+ if (parsedProxyPort && parsedProxyPort !== port) {
+ return true;
+ }
+ if (!/^[.*]/.test(parsedProxyHostname)) {
+ return hostname !== parsedProxyHostname;
+ }
+ if (parsedProxyHostname.charAt(0) === "*") {
+ parsedProxyHostname = parsedProxyHostname.slice(1);
+ }
+ return !stringEndsWith.call(hostname, parsedProxyHostname);
+ });
+ }
+ function getEnv2(key) {
+ return process.env[key.toLowerCase()] || process.env[key.toUpperCase()] || "";
+ }
+ exports.getProxyForUrl = getProxyForUrl2;
+ }
+});
+
// node_modules/@dqbd/tiktoken/lite/tiktoken_bg.cjs
var require_tiktoken_bg = __commonJS({
"node_modules/@dqbd/tiktoken/lite/tiktoken_bg.cjs"(exports, module2) {
@@ -15253,118 +15365,6 @@ var require_tiktoken = __commonJS({
}
});
-// node_modules/@commitlint/types/lib/ensure.js
-var require_ensure = __commonJS({
- "node_modules/@commitlint/types/lib/ensure.js"(exports) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- }
-});
-
-// node_modules/@commitlint/types/lib/format.js
-var require_format = __commonJS({
- "node_modules/@commitlint/types/lib/format.js"(exports) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- }
-});
-
-// node_modules/@commitlint/types/lib/is-ignored.js
-var require_is_ignored = __commonJS({
- "node_modules/@commitlint/types/lib/is-ignored.js"(exports) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- }
-});
-
-// node_modules/@commitlint/types/lib/lint.js
-var require_lint = __commonJS({
- "node_modules/@commitlint/types/lib/lint.js"(exports) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- }
-});
-
-// node_modules/@commitlint/types/lib/load.js
-var require_load = __commonJS({
- "node_modules/@commitlint/types/lib/load.js"(exports) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- }
-});
-
-// node_modules/@commitlint/types/lib/parse.js
-var require_parse2 = __commonJS({
- "node_modules/@commitlint/types/lib/parse.js"(exports) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- }
-});
-
-// node_modules/@commitlint/types/lib/prompt.js
-var require_prompt = __commonJS({
- "node_modules/@commitlint/types/lib/prompt.js"(exports) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- }
-});
-
-// node_modules/@commitlint/types/lib/rules.js
-var require_rules = __commonJS({
- "node_modules/@commitlint/types/lib/rules.js"(exports) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.RuleConfigQuality = exports.RuleConfigSeverity = void 0;
- var RuleConfigSeverity2;
- (function(RuleConfigSeverity3) {
- RuleConfigSeverity3[RuleConfigSeverity3["Disabled"] = 0] = "Disabled";
- RuleConfigSeverity3[RuleConfigSeverity3["Warning"] = 1] = "Warning";
- RuleConfigSeverity3[RuleConfigSeverity3["Error"] = 2] = "Error";
- })(RuleConfigSeverity2 = exports.RuleConfigSeverity || (exports.RuleConfigSeverity = {}));
- var RuleConfigQuality;
- (function(RuleConfigQuality2) {
- RuleConfigQuality2[RuleConfigQuality2["User"] = 0] = "User";
- RuleConfigQuality2[RuleConfigQuality2["Qualified"] = 1] = "Qualified";
- })(RuleConfigQuality = exports.RuleConfigQuality || (exports.RuleConfigQuality = {}));
- }
-});
-
-// node_modules/@commitlint/types/lib/index.js
-var require_lib = __commonJS({
- "node_modules/@commitlint/types/lib/index.js"(exports) {
- "use strict";
- var __createBinding = exports && exports.__createBinding || (Object.create ? function(o2, m4, k6, k22) {
- if (k22 === void 0)
- k22 = k6;
- var desc = Object.getOwnPropertyDescriptor(m4, k6);
- if (!desc || ("get" in desc ? !m4.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() {
- return m4[k6];
- } };
- }
- Object.defineProperty(o2, k22, desc);
- } : function(o2, m4, k6, k22) {
- if (k22 === void 0)
- k22 = k6;
- o2[k22] = m4[k6];
- });
- var __exportStar = exports && exports.__exportStar || function(m4, exports2) {
- for (var p4 in m4)
- if (p4 !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p4))
- __createBinding(exports2, m4, p4);
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- __exportStar(require_ensure(), exports);
- __exportStar(require_format(), exports);
- __exportStar(require_is_ignored(), exports);
- __exportStar(require_lint(), exports);
- __exportStar(require_load(), exports);
- __exportStar(require_parse2(), exports);
- __exportStar(require_prompt(), exports);
- __exportStar(require_rules(), exports);
- }
-});
-
// node_modules/ignore/index.js
var require_ignore = __commonJS({
"node_modules/ignore/index.js"(exports, module2) {
@@ -16384,7 +16384,7 @@ function G3(t, e2) {
// package.json
var package_default = {
name: "opencommit",
- version: "3.0.3",
+ version: "3.0.4",
description: "Auto-generate impressive commits in 1 second. Killing lame commits with AI \u{1F92F}\u{1F52B}",
keywords: [
"git",
@@ -16396,7 +16396,8 @@ var package_default = {
"aicommit",
"aicommits",
"gptcommit",
- "commit"
+ "commit",
+ "ollama"
],
main: "cli.js",
bin: {
@@ -16424,6 +16425,7 @@ var package_default = {
scripts: {
watch: "npm run -S build -- --sourcemap --watch",
start: "node ./out/cli.cjs",
+ "ollama:start": "AI_PROVIDER='ollama' node./out/cli.cjs",
dev: "ts-node ./src/cli.ts",
build: "rimraf out && node esbuild.config.js",
"build:push": "npm run build && git add . && git commit -m 'build' && git push",
@@ -16453,6 +16455,7 @@ var package_default = {
"@dqbd/tiktoken": "^1.0.2",
"@octokit/webhooks-schemas": "^6.11.0",
"@octokit/webhooks-types": "^6.11.0",
+ ai: "^2.2.14",
axios: "^1.3.4",
chalk: "^5.2.0",
cleye: "^1.3.2",
@@ -18433,6 +18436,632 @@ function ue() {
// src/generateCommitMessageFromGitDiff.ts
var import_openai4 = __toESM(require_dist(), 1);
+// src/commands/config.ts
+var dotenv = __toESM(require_main(), 1);
+var import_fs = require("fs");
+var import_ini = __toESM(require_ini(), 1);
+var import_os = require("os");
+var import_path = require("path");
+
+// src/i18n/cs.json
+var cs_default = {
+ localLanguage: "\u010Desky",
+ commitFix: "fix(server.ts): zlep\u0161en\xED velikosti prom\u011Bnn\xE9 port na velk\xE1 p\xEDsmena PORT",
+ commitFeat: "feat(server.ts): p\u0159id\xE1n\xED podpory pro prom\u011Bnnou prost\u0159ed\xED process.env.PORT",
+ commitDescription: "Prom\u011Bnn\xE1 port se nyn\xED jmenuje PORT, co\u017E odpov\xEDd\xE1 konvenci pojmenov\xE1n\xED, proto\u017Ee PORT je konstanta. Podpora prom\u011Bnn\xE9 prost\u0159ed\xED process.env.PORT umo\u017E\u0148uje snadn\u011Bj\u0161\xED spr\xE1vu nastaven\xED p\u0159i spu\u0161t\u011Bn\xED."
+};
+
+// src/i18n/de.json
+var de_default = {
+ localLanguage: "Deutsch",
+ commitFix: "fix(server.ts): \xC4ndere die Gro\xDF- und Kleinschreibung der Port-Variable von Kleinbuchstaben auf Gro\xDFbuchstaben PORT.",
+ commitFeat: "Funktion(server.ts): Unterst\xFCtzung f\xFCr die Umgebungsvariable process.env.PORT hinzuf\xFCgen",
+ commitDescription: "Die Port-Variable hei\xDFt jetzt PORT, was die Konsistenz mit den Namenskonventionen verbessert, da PORT eine Konstante ist. Die Unterst\xFCtzung f\xFCr eine Umgebungsvariable erm\xF6glicht es der Anwendung, flexibler zu sein, da sie jetzt auf jedem verf\xFCgbaren Port laufen kann, der \xFCber die Umgebungsvariable process.env.PORT angegeben wird."
+};
+
+// src/i18n/en.json
+var en_default = {
+ localLanguage: "english",
+ commitFix: "fix(server.ts): change port variable case from lowercase port to uppercase PORT to improve semantics",
+ commitFeat: "feat(server.ts): add support for process.env.PORT environment variable to be able to run app on a configurable port",
+ commitDescription: "The port variable is now named PORT, which improves consistency with the naming conventions as PORT is a constant. Support for an environment variable allows the application to be more flexible as it can now run on any available port specified via the process.env.PORT environment variable."
+};
+
+// src/i18n/es_ES.json
+var es_ES_default = {
+ localLanguage: "spanish",
+ commitFix: "fix(server.ts): cambiar la variable port de min\xFAsculas a may\xFAsculas PORT",
+ commitFeat: "feat(server.ts): a\xF1adir soporte para la variable de entorno process.env.PORT",
+ commitDescription: "La variable port ahora se llama PORT, lo que mejora la coherencia con las convenciones de nomenclatura, ya que PORT es una constante. El soporte para una variable de entorno permite que la aplicaci\xF3n sea m\xE1s flexible, ya que ahora puede ejecutarse en cualquier puerto disponible especificado a trav\xE9s de la variable de entorno process.env.PORT."
+};
+
+// src/i18n/fr.json
+var fr_default = {
+ localLanguage: "fran\xE7aise",
+ commitFix: "corriger(server.ts) : changer la casse de la variable de port de minuscules \xE0 majuscules (PORT)",
+ commitFeat: "fonctionnalit\xE9(server.ts) : ajouter la prise en charge de la variable d'environnement process.env.PORT",
+ commitDescription: "La variable de port est maintenant nomm\xE9e PORT, ce qui am\xE9liore la coh\xE9rence avec les conventions de nommage car PORT est une constante. La prise en charge d'une variable d'environnement permet \xE0 l'application d'\xEAtre plus flexible car elle peut maintenant s'ex\xE9cuter sur n'importe quel port disponible sp\xE9cifi\xE9 via la variable d'environnement process.env.PORT."
+};
+
+// src/i18n/id_ID.json
+var id_ID_default = {
+ localLanguage: "bahasa",
+ commitFix: "fix(server.ts): mengubah huruf port variable dari huruf kecil ke huruf besar PORT",
+ commitFeat: "feat(server.ts): menambahkan support di process.env.PORT environment variabel",
+ commitDescription: "Port variabel bernama PORT, yang membantu konsistensi dengan memberi nama yaitu PORT yang konstan. Bantuan environment variabel membantu aplikasi lebih fleksibel, dan dapat di jalankan di port manapun yang tertulis pada process.env.PORT"
+};
+
+// src/i18n/it.json
+var it_default = {
+ localLanguage: "italiano",
+ commitFix: "fix(server.ts): cambia la grafia della variabile della porta dal minuscolo port al maiuscolo PORT",
+ commitFeat: "feat(server.ts): aggiunge il supporto per la variabile di ambiente process.env.PORT",
+ commitDescription: "La variabile port \xE8 ora chiamata PORT, migliorando la coerenza con le convenzioni di denominazione in quanto PORT \xE8 una costante. Il supporto per una variabile di ambiente consente all'applicazione di essere pi\xF9 flessibile poich\xE9 ora pu\xF2 essere eseguita su qualsiasi porta disponibile specificata tramite la variabile di ambiente process.env.PORT."
+};
+
+// src/i18n/ja.json
+var ja_default = {
+ localLanguage: "\u65E5\u672C\u8A9E",
+ commitFix: "\u4FEE\u6B63(server.ts): \u30DD\u30FC\u30C8\u5909\u6570\u3092\u5C0F\u6587\u5B57\u306Eport\u304B\u3089\u5927\u6587\u5B57\u306EPORT\u306B\u5909\u66F4",
+ commitFeat: "\u65B0\u6A5F\u80FD(server.ts): \u74B0\u5883\u5909\u6570process.env.PORT\u306E\u30B5\u30DD\u30FC\u30C8\u3092\u8FFD\u52A0",
+ commitDescription: "\u30DD\u30FC\u30C8\u5909\u6570\u306F\u73FE\u5728PORT\u3068\u3044\u3046\u540D\u524D\u306B\u306A\u308A\u3001\u5B9A\u6570\u3067\u3042\u308BPORT\u3092\u4F7F\u3046\u3053\u3068\u3067\u547D\u540D\u898F\u5247\u306B\u4E00\u8CAB\u6027\u304C\u751F\u307E\u308C\u307E\u3057\u305F\u3002\u74B0\u5883\u5909\u6570\u3092\u30B5\u30DD\u30FC\u30C8\u3059\u308B\u3053\u3068\u3067\u3001\u74B0\u5883\u5909\u6570process.env.PORT\u3067\u6307\u5B9A\u3055\u308C\u305F\u4EFB\u610F\u306E\u5229\u7528\u53EF\u80FD\u306A\u30DD\u30FC\u30C8\u3067\u5B9F\u884C\u3067\u304D\u308B\u3088\u3046\u306B\u306A\u308A\u3001\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u306F\u3088\u308A\u67D4\u8EDF\u306B\u306A\u308A\u307E\u3057\u305F\u3002"
+};
+
+// src/i18n/ko.json
+var ko_default = {
+ localLanguage: "\uD55C\uAD6D\uC5B4",
+ commitFix: "fix(server.ts): \uD3EC\uD2B8 \uBCC0\uC218\uB97C \uC18C\uBB38\uC790 port\uC5D0\uC11C \uB300\uBB38\uC790 PORT\uB85C \uBCC0\uACBD",
+ commitFeat: "\uD53C\uD2B8(server.ts): process.env.PORT \uD658\uACBD \uBCC0\uC218 \uC9C0\uC6D0 \uCD94\uAC00",
+ commitDescription: "\uD3EC\uD2B8 \uBCC0\uC218\uB294 \uC774\uC81C PORT\uB85C \uC774\uB984\uC774 \uC9C0\uC815\uB418\uC5B4 \uC0C1\uC218\uC778 PORT\uC640 \uC77C\uAD00\uC131 \uC788\uB294 \uC774\uB984 \uADDC\uCE59\uC744 \uB530\uB985\uB2C8\uB2E4. \uD658\uACBD \uBCC0\uC218 \uC9C0\uC6D0\uC744 \uD1B5\uD574 \uC560\uD50C\uB9AC\uCF00\uC774\uC158\uC740 \uC774\uC81C process.env.PORT \uD658\uACBD \uBCC0\uC218\uB85C \uC9C0\uC815\uB41C \uC0AC\uC6A9 \uAC00\uB2A5\uD55C \uBAA8\uB4E0 \uD3EC\uD2B8\uC5D0\uC11C \uC2E4\uD589\uD560 \uC218 \uC788\uC73C\uBBC0\uB85C \uB354 \uC720\uC5F0\uD574\uC84C\uC2B5\uB2C8\uB2E4."
+};
+
+// src/i18n/nl.json
+var nl_default = {
+ localLanguage: "Nederlands",
+ commitFix: "fix(server.ts): verander poortvariabele van kleine letters poort naar hoofdletters PORT",
+ commitFeat: "feat(server.ts): voeg ondersteuning toe voor process.env.PORT omgevingsvariabele",
+ commitDescription: "De poortvariabele heet nu PORT, wat de consistentie met de naamgevingsconventies verbetert omdat PORT een constante is. Ondersteuning voor een omgevingsvariabele maakt de applicatie flexibeler, omdat deze nu kan draaien op elke beschikbare poort die is gespecificeerd via de process.env.PORT omgevingsvariabele."
+};
+
+// src/i18n/pl.json
+var pl_default = {
+ localLanguage: "polski",
+ commitFix: "fix(server.ts): poprawa wielko\u015Bci zmiennej port na pisane z du\u017Cymi literami PORT",
+ commitFeat: "feat(server.ts): dodanie obs\u0142ugi zmiennej \u015Brodowiskowej process.env.PORT",
+ commitDescription: "Zmienna port jest teraz nazwana PORT, co jest zgodne z konwencj\u0105 nazewnicz\u0105 poniewa\u017C PORT jest sta\u0142\u0105. Obs\u0142uga zmiennej \u015Brodowiskowej process.env.PORT pozwala \u0142atwiej zarz\u0105dza\u0107 ustawieniami przy starcie."
+};
+
+// src/i18n/pt_br.json
+var pt_br_default = {
+ localLanguage: "portugu\xEAs",
+ commitFix: "fix(server.ts): altera o caso da vari\xE1vel de porta de port min\xFAscula para PORT mai\xFAscula",
+ commitFeat: "feat(server.ts): adiciona suporte para a vari\xE1vel de ambiente process.env.PORT",
+ commitDescription: "A vari\xE1vel de porta agora \xE9 denominada PORT, o que melhora a consist\xEAncia com as conven\xE7\xF5es de nomenclatura, pois PORT \xE9 uma constante. O suporte para uma vari\xE1vel de ambiente permite que o aplicativo seja mais flex\xEDvel, pois agora pode ser executado em qualquer porta dispon\xEDvel especificada por meio da vari\xE1vel de ambiente process.env.PORT."
+};
+
+// src/i18n/ru.json
+var ru_default = {
+ localLanguage: "\u0440\u0443\u0441\u0441\u043A\u0438\u0439",
+ commitFix: "fix(server.ts): \u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u043F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u043E\u0439 \u043F\u043E\u0440\u0442\u0430 \u0441 \u043D\u0438\u0436\u043D\u0435\u0433\u043E \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 port \u043D\u0430 \u0432\u0435\u0440\u0445\u043D\u0438\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 PORT",
+ commitFeat: "feat(server.ts): \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u0430 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u043A\u0430 \u043F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u043E\u0439 \u043E\u043A\u0440\u0443\u0436\u0435\u043D\u0438\u044F process.env.PORT",
+ commitDescription: "\u041F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u0430\u044F port \u0442\u0435\u043F\u0435\u0440\u044C \u043D\u0430\u0437\u044B\u0432\u0430\u0435\u0442\u0441\u044F PORT, \u0447\u0442\u043E \u0443\u043B\u0443\u0447\u0448\u0430\u0435\u0442 \u0441\u043E\u0433\u043B\u0430\u0441\u043E\u0432\u0430\u043D\u043D\u043E\u0441\u0442\u044C \u0441 \u0441\u043E\u0433\u043B\u0430\u0448\u0435\u043D\u0438\u044F\u043C\u0438 \u043E\u0431 \u0438\u043C\u0435\u043D\u043E\u0432\u0430\u043D\u0438\u0438 \u043A\u043E\u043D\u0441\u0442\u0430\u043D\u0442. \u041F\u043E\u0434\u0434\u0435\u0440\u0436\u043A\u0430 \u043F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u043E\u0439 \u043E\u043A\u0440\u0443\u0436\u0435\u043D\u0438\u044F \u043F\u043E\u0437\u0432\u043E\u043B\u044F\u0435\u0442 \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u044E \u0431\u044B\u0442\u044C \u0431\u043E\u043B\u0435\u0435 \u0433\u0438\u0431\u043A\u0438\u043C, \u0437\u0430\u043F\u0443\u0441\u043A\u0430\u044F\u0441\u044C \u043D\u0430 \u043B\u044E\u0431\u043E\u043C \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E\u043C \u043F\u043E\u0440\u0442\u0443, \u0443\u043A\u0430\u0437\u0430\u043D\u043D\u043E\u043C \u0441 \u043F\u043E\u043C\u043E\u0449\u044C\u044E \u043F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u043E\u0439 \u043E\u043A\u0440\u0443\u0436\u0435\u043D\u0438\u044F process.env.PORT."
+};
+
+// src/i18n/sv.json
+var sv_default = {
+ localLanguage: "svenska",
+ commitFix: "fixa(server.ts): \xE4ndra variabelnamnet f\xF6r port fr\xE5n sm\xE5 bokst\xE4ver till stora bokst\xE4ver PORT",
+ commitFeat: "nyhet(server.ts): l\xE4gg till st\xF6d f\xF6r process.env.PORT milj\xF6variabel",
+ commitDescription: "Variabeln som inneh\xE5ller portnumret heter nu PORT vilket f\xF6rb\xE4ttrar konsekvensen med namngivningskonventionerna eftersom PORT \xE4r en konstant. St\xF6d f\xF6r en milj\xF6variabel g\xF6r att applikationen kan vara mer flexibel d\xE5 den nu kan k\xF6ras p\xE5 vilken port som helst som specificeras via milj\xF6variabeln process.env.PORT."
+};
+
+// src/i18n/th.json
+var th_default = {
+ localLanguage: "\u0E44\u0E17\u0E22",
+ commitFix: "fix(server.ts): \u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E15\u0E31\u0E27\u0E1E\u0E34\u0E21\u0E1E\u0E4C\u0E02\u0E2D\u0E07\u0E15\u0E31\u0E27\u0E41\u0E1B\u0E23 \u0E08\u0E32\u0E01\u0E15\u0E31\u0E27\u0E1E\u0E34\u0E21\u0E1E\u0E4C\u0E40\u0E25\u0E47\u0E01 port \u0E40\u0E1B\u0E47\u0E19\u0E15\u0E31\u0E27\u0E1E\u0E34\u0E21\u0E1E\u0E4C\u0E43\u0E2B\u0E0D\u0E48 PORT",
+ commitFeat: "feat(server.ts): \u0E40\u0E1E\u0E34\u0E48\u0E21\u0E01\u0E32\u0E23\u0E23\u0E2D\u0E07\u0E23\u0E31\u0E1A\u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E15\u0E31\u0E27\u0E41\u0E1B\u0E23\u0E2A\u0E20\u0E32\u0E1E\u0E41\u0E27\u0E14\u0E25\u0E49\u0E2D\u0E21 process.env.PORT",
+ commitDescription: "\u0E15\u0E2D\u0E19\u0E19\u0E35\u0E49\u0E15\u0E31\u0E27\u0E41\u0E1B\u0E23\u0E1E\u0E2D\u0E23\u0E4C\u0E15\u0E21\u0E35\u0E0A\u0E37\u0E48\u0E2D\u0E27\u0E48\u0E32 PORT, \u0E0B\u0E36\u0E48\u0E07\u0E1B\u0E23\u0E31\u0E1A\u0E1B\u0E23\u0E38\u0E07\u0E04\u0E27\u0E32\u0E21\u0E2A\u0E2D\u0E14\u0E04\u0E25\u0E49\u0E2D\u0E07\u0E01\u0E31\u0E1A\u0E2B\u0E25\u0E31\u0E01\u0E01\u0E32\u0E23\u0E15\u0E31\u0E49\u0E07\u0E0A\u0E37\u0E48\u0E2D\u0E40\u0E19\u0E37\u0E48\u0E2D\u0E07\u0E08\u0E32\u0E01 PORT \u0E40\u0E1B\u0E47\u0E19\u0E04\u0E48\u0E32\u0E04\u0E07\u0E17\u0E35\u0E48. \u0E01\u0E32\u0E23\u0E2A\u0E19\u0E31\u0E1A\u0E2A\u0E19\u0E38\u0E19\u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E15\u0E31\u0E27\u0E41\u0E1B\u0E23\u0E2A\u0E20\u0E32\u0E1E\u0E41\u0E27\u0E14\u0E25\u0E49\u0E2D\u0E21 \u0E0A\u0E48\u0E27\u0E22\u0E43\u0E2B\u0E49\u0E41\u0E2D\u0E1B\u0E1E\u0E25\u0E34\u0E40\u0E04\u0E0A\u0E31\u0E19\u0E21\u0E35\u0E04\u0E27\u0E32\u0E21\u0E22\u0E37\u0E14\u0E2B\u0E22\u0E38\u0E48\u0E19\u0E21\u0E32\u0E01\u0E02\u0E36\u0E49\u0E19\u0E40\u0E19\u0E37\u0E48\u0E2D\u0E07\u0E08\u0E32\u0E01 \u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E17\u0E33\u0E07\u0E32\u0E19\u0E1A\u0E19\u0E1E\u0E2D\u0E23\u0E4C\u0E15\u0E43\u0E14 \u0E46 \u0E15\u0E32\u0E21\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14 \u0E0B\u0E36\u0E48\u0E07\u0E23\u0E30\u0E1A\u0E38\u0E1C\u0E48\u0E32\u0E19\u0E15\u0E31\u0E27\u0E41\u0E1B\u0E23\u0E2A\u0E20\u0E32\u0E1E\u0E41\u0E27\u0E14\u0E25\u0E49\u0E2D\u0E21 process.env.PORT"
+};
+
+// src/i18n/tr.json
+var tr_default = {
+ localLanguage: "Turkish",
+ commitFix: "fix(server.ts): port de\u011Fi\u015Fkeni k\xFC\xE7\xFCk harfli porttan b\xFCy\xFCk harfli PORT'a de\u011Fi\u015Ftirildi",
+ commitFeat: "feat(server.ts): process.env.PORT ortam de\u011Fi\u015Fkeni i\xE7in destek eklendi.",
+ commitDescription: "Ba\u011Flant\u0131 noktas\u0131 de\u011Fi\u015Fkeni art\u0131k PORT olarak adland\u0131r\u0131ld\u0131 ve PORT bir sabit de\u011Fi\u015Fken oldu\u011Fu i\xE7in bu adland\u0131rma tutarl\u0131l\u0131\u011F\u0131 art\u0131r\u0131r. Ortam de\u011Fi\u015Fkeni deste\u011Fi, art\u0131k process.env.PORT ortam de\u011Fi\u015Fkeni arac\u0131l\u0131\u011F\u0131yla belirtilen herhangi bir kullan\u0131labilir ba\u011Flant\u0131 noktas\u0131nda \xE7al\u0131\u015Fabilece\u011Finden uygulaman\u0131n daha esnek olmas\u0131n\u0131 sa\u011Flar."
+};
+
+// src/i18n/vi_VN.json
+var vi_VN_default = {
+ localLanguage: "vietnamese",
+ commitFix: "fix(server.ts): thay \u0111\u1ED5i ch\u1EEF vi\u1EBFt th\u01B0\u1EDDng c\u1EE7a bi\u1EBFn port th\xE0nh ch\u1EEF vi\u1EBFt hoa PORT",
+ commitFeat: "feat(server.ts): th\xEAm h\u1ED7 tr\u1EE3 cho bi\u1EBFn m\xF4i tr\u01B0\u1EDDng process.env.PORT",
+ commitDescription: "Bi\u1EBFn port \u0111\xE3 \u0111\u01B0\u1EE3c \u0111\u1ED5i t\xEAn th\xE0nh PORT, gi\xFAp c\u1EA3i thi\u1EC7n t\xEDnh nh\u1EA5t qu\xE1n trong vi\u1EC7c \u0111\u1EB7t t\xEAn theo quy \u01B0\u1EDBc v\xEC PORT l\xE0 m\u1ED9t h\u1EB1ng s\u1ED1. H\u1ED7 tr\u1EE3 cho bi\u1EBFn m\xF4i tr\u01B0\u1EDDng cho ph\xE9p \u1EE9ng d\u1EE5ng linh ho\u1EA1t h\u01A1n khi c\xF3 th\u1EC3 ch\u1EA1y tr\xEAn b\u1EA5t k\u1EF3 c\u1ED5ng n\xE0o \u0111\u01B0\u1EE3c ch\u1EC9 \u0111\u1ECBnh th\xF4ng qua bi\u1EBFn m\xF4i tr\u01B0\u1EDDng process.env.PORT."
+};
+
+// src/i18n/zh_CN.json
+var zh_CN_default = {
+ localLanguage: "\u7B80\u4F53\u4E2D\u6587",
+ commitFix: "\u4FEE\u590D(server.ts)\uFF1A\u5C06\u7AEF\u53E3\u53D8\u91CF\u4ECE\u5C0F\u5199port\u6539\u4E3A\u5927\u5199PORT",
+ commitFeat: "\u529F\u80FD(server.ts)\uFF1A\u6DFB\u52A0\u5BF9process.env.PORT\u73AF\u5883\u53D8\u91CF\u7684\u652F\u6301",
+ commitDescription: "\u73B0\u5728\u7AEF\u53E3\u53D8\u91CF\u88AB\u547D\u540D\u4E3APORT\uFF0C\u8FD9\u63D0\u9AD8\u4E86\u547D\u540D\u7EA6\u5B9A\u7684\u4E00\u81F4\u6027\uFF0C\u56E0\u4E3APORT\u662F\u4E00\u4E2A\u5E38\u91CF\u3002\u73AF\u5883\u53D8\u91CF\u7684\u652F\u6301\u4F7F\u5E94\u7528\u7A0B\u5E8F\u66F4\u52A0\u7075\u6D3B\uFF0C\u56E0\u4E3A\u5B83\u73B0\u5728\u53EF\u4EE5\u901A\u8FC7process.env.PORT\u73AF\u5883\u53D8\u91CF\u5728\u4EFB\u4F55\u53EF\u7528\u7AEF\u53E3\u4E0A\u8FD0\u884C\u3002"
+};
+
+// src/i18n/zh_TW.json
+var zh_TW_default = {
+ localLanguage: "\u7E41\u9AD4\u4E2D\u6587",
+ commitFix: "\u4FEE\u6B63(server.ts)\uFF1A\u5C07\u7AEF\u53E3\u8B8A\u6578\u5F9E\u5C0F\u5BEB\u7AEF\u53E3\u6539\u70BA\u5927\u5BEBPORT",
+ commitFeat: "\u529F\u80FD(server.ts)\uFF1A\u65B0\u589E\u5C0Dprocess.env.PORT\u74B0\u5883\u8B8A\u6578\u7684\u652F\u63F4",
+ commitDescription: "\u73FE\u5728port\u8B8A\u6578\u5DF2\u66F4\u540D\u70BAPORT\uFF0C\u4EE5\u7B26\u5408\u547D\u540D\u6163\u4F8B\uFF0C\u56E0\u70BAPORT\u662F\u4E00\u500B\u5E38\u91CF\u3002\u652F\u63F4\u74B0\u5883\u8B8A\u6578\u53EF\u4EE5\u4F7F\u61C9\u7528\u7A0B\u5E8F\u66F4\u9748\u6D3B\uFF0C\u56E0\u70BA\u5B83\u73FE\u5728\u53EF\u4EE5\u901A\u904Eprocess.env.PORT\u74B0\u5883\u8B8A\u6578\u904B\u884C\u5728\u4EFB\u4F55\u53EF\u7528\u7AEF\u53E3\u4E0A\u3002"
+};
+
+// src/i18n/index.ts
+var i18n = {
+ en: en_default,
+ zh_CN: zh_CN_default,
+ zh_TW: zh_TW_default,
+ ja: ja_default,
+ cs: cs_default,
+ de: de_default,
+ fr: fr_default,
+ it: it_default,
+ ko: ko_default,
+ pt_br: pt_br_default,
+ vi_VN: vi_VN_default,
+ es_ES: es_ES_default,
+ sv: sv_default,
+ id_ID: id_ID_default,
+ nl: nl_default,
+ ru: ru_default,
+ pl: pl_default,
+ tr: tr_default,
+ th: th_default
+};
+var I18N_CONFIG_ALIAS = {
+ zh_CN: ["zh_CN", "\u7B80\u4F53\u4E2D\u6587", "\u4E2D\u6587", "\u7B80\u4F53"],
+ zh_TW: ["zh_TW", "\u7E41\u9AD4\u4E2D\u6587", "\u7E41\u9AD4"],
+ ja: ["ja", "Japanese", "\u306B\u307B\u3093\u3054"],
+ ko: ["ko", "Korean", "\uD55C\uAD6D\uC5B4"],
+ cs: ["cs", "Czech", "\u010Desky"],
+ de: ["de", "German", "Deutsch"],
+ fr: ["fr", "French", "fran\xE7aise"],
+ it: ["it", "Italian", "italiano"],
+ nl: ["nl", "Dutch", "Nederlands"],
+ pt_br: ["pt_br", "Portuguese", "portugu\xEAs"],
+ vi_VN: ["vi_VN", "Vietnamese", "ti\u1EBFng Vi\u1EC7t"],
+ en: ["en", "English", "english"],
+ es_ES: ["es_ES", "Spanish", "espa\xF1ol"],
+ sv: ["sv", "Swedish", "Svenska"],
+ ru: ["ru", "Russian", "\u0440\u0443\u0441\u0441\u043A\u0438\u0439"],
+ id_ID: ["id_ID", "Bahasa", "bahasa"],
+ pl: ["pl", "Polish", "Polski"],
+ tr: ["tr", "Turkish", "Turkish"],
+ th: ["th", "Thai", "\u0E44\u0E17\u0E22"]
+};
+function getI18nLocal(value) {
+ for (const key in I18N_CONFIG_ALIAS) {
+ const aliases2 = I18N_CONFIG_ALIAS[key];
+ if (aliases2.includes(value)) {
+ return key;
+ }
+ }
+ return false;
+}
+
+// src/commands/config.ts
+dotenv.config();
+var DEFAULT_MODEL_TOKEN_LIMIT = 4096;
+var validateConfig = (key, condition, validationMessage) => {
+ if (!condition) {
+ ce(
+ `${source_default.red("\u2716")} Unsupported config key ${key}: ${validationMessage}`
+ );
+ process.exit(1);
+ }
+};
+var configValidators = {
+ ["OCO_OPENAI_API_KEY" /* OCO_OPENAI_API_KEY */](value, config8 = {}) {
+ validateConfig("API_KEY", value || config8.OCO_AI_PROVIDER == "ollama", "You need to provide an API key");
+ validateConfig(
+ "OCO_OPENAI_API_KEY" /* OCO_OPENAI_API_KEY */,
+ value.startsWith("sk-"),
+ 'Must start with "sk-"'
+ );
+ validateConfig(
+ "OCO_OPENAI_API_KEY" /* OCO_OPENAI_API_KEY */,
+ config8["OCO_OPENAI_BASE_PATH" /* OCO_OPENAI_BASE_PATH */] || value.length === 51,
+ "Must be 51 characters long"
+ );
+ return value;
+ },
+ ["OCO_DESCRIPTION" /* OCO_DESCRIPTION */](value) {
+ validateConfig(
+ "OCO_DESCRIPTION" /* OCO_DESCRIPTION */,
+ typeof value === "boolean",
+ "Must be true or false"
+ );
+ return value;
+ },
+ ["OCO_OPENAI_MAX_TOKENS" /* OCO_OPENAI_MAX_TOKENS */](value) {
+ if (typeof value === "string") {
+ value = parseInt(value);
+ validateConfig(
+ "OCO_OPENAI_MAX_TOKENS" /* OCO_OPENAI_MAX_TOKENS */,
+ !isNaN(value),
+ "Must be a number"
+ );
+ }
+ validateConfig(
+ "OCO_OPENAI_MAX_TOKENS" /* OCO_OPENAI_MAX_TOKENS */,
+ value ? typeof value === "number" : void 0,
+ "Must be a number"
+ );
+ return value;
+ },
+ ["OCO_EMOJI" /* OCO_EMOJI */](value) {
+ validateConfig(
+ "OCO_EMOJI" /* OCO_EMOJI */,
+ typeof value === "boolean",
+ "Must be true or false"
+ );
+ return value;
+ },
+ ["OCO_LANGUAGE" /* OCO_LANGUAGE */](value) {
+ validateConfig(
+ "OCO_LANGUAGE" /* OCO_LANGUAGE */,
+ getI18nLocal(value),
+ `${value} is not supported yet`
+ );
+ return getI18nLocal(value);
+ },
+ ["OCO_OPENAI_BASE_PATH" /* OCO_OPENAI_BASE_PATH */](value) {
+ validateConfig(
+ "OCO_OPENAI_BASE_PATH" /* OCO_OPENAI_BASE_PATH */,
+ typeof value === "string",
+ "Must be string"
+ );
+ return value;
+ },
+ ["OCO_MODEL" /* OCO_MODEL */](value) {
+ validateConfig(
+ "OCO_MODEL" /* OCO_MODEL */,
+ [
+ "gpt-3.5-turbo",
+ "gpt-4",
+ "gpt-3.5-turbo-16k",
+ "gpt-3.5-turbo-0613"
+ ].includes(value),
+ `${value} is not supported yet, use 'gpt-4', 'gpt-3.5-turbo-16k' (default), 'gpt-3.5-turbo-0613' or 'gpt-3.5-turbo'`
+ );
+ return value;
+ },
+ ["OCO_MESSAGE_TEMPLATE_PLACEHOLDER" /* OCO_MESSAGE_TEMPLATE_PLACEHOLDER */](value) {
+ validateConfig(
+ "OCO_MESSAGE_TEMPLATE_PLACEHOLDER" /* OCO_MESSAGE_TEMPLATE_PLACEHOLDER */,
+ value.startsWith("$"),
+ `${value} must start with $, for example: '$msg'`
+ );
+ return value;
+ },
+ ["OCO_PROMPT_MODULE" /* OCO_PROMPT_MODULE */](value) {
+ validateConfig(
+ "OCO_PROMPT_MODULE" /* OCO_PROMPT_MODULE */,
+ ["conventional-commit", "@commitlint"].includes(value),
+ `${value} is not supported yet, use '@commitlint' or 'conventional-commit' (default)`
+ );
+ return value;
+ },
+ ["OCO_AI_PROVIDER" /* OCO_AI_PROVIDER */](value) {
+ validateConfig(
+ "OCO_AI_PROVIDER" /* OCO_AI_PROVIDER */,
+ [
+ "",
+ "openai",
+ "ollama"
+ ].includes(value),
+ `${value} is not supported yet, use 'ollama' or 'openai' (default)`
+ );
+ return value;
+ }
+};
+var configPath = (0, import_path.join)((0, import_os.homedir)(), ".opencommit");
+var getConfig = () => {
+ const configFromEnv = {
+ OCO_OPENAI_API_KEY: process.env.OCO_OPENAI_API_KEY,
+ OCO_OPENAI_MAX_TOKENS: process.env.OCO_OPENAI_MAX_TOKENS ? Number(process.env.OCO_OPENAI_MAX_TOKENS) : void 0,
+ OCO_OPENAI_BASE_PATH: process.env.OCO_OPENAI_BASE_PATH,
+ OCO_DESCRIPTION: process.env.OCO_DESCRIPTION === "true" ? true : false,
+ OCO_EMOJI: process.env.OCO_EMOJI === "true" ? true : false,
+ OCO_MODEL: process.env.OCO_MODEL || "gpt-3.5-turbo-16k",
+ OCO_LANGUAGE: process.env.OCO_LANGUAGE || "en",
+ OCO_MESSAGE_TEMPLATE_PLACEHOLDER: process.env.OCO_MESSAGE_TEMPLATE_PLACEHOLDER || "$msg",
+ OCO_PROMPT_MODULE: process.env.OCO_PROMPT_MODULE || "conventional-commit",
+ OCO_AI_PROVIDER: process.env.OCO_AI_PROVIDER || "openai"
+ };
+ const configExists = (0, import_fs.existsSync)(configPath);
+ if (!configExists)
+ return configFromEnv;
+ const configFile = (0, import_fs.readFileSync)(configPath, "utf8");
+ const config8 = (0, import_ini.parse)(configFile);
+ for (const configKey of Object.keys(config8)) {
+ if (!config8[configKey] || ["null", "undefined"].includes(config8[configKey])) {
+ config8[configKey] = void 0;
+ continue;
+ }
+ try {
+ const validator = configValidators[configKey];
+ const validValue = validator(
+ config8[configKey] ?? configFromEnv[configKey],
+ config8
+ );
+ config8[configKey] = validValue;
+ } catch (error) {
+ ce(
+ `'${configKey}' name is invalid, it should be either 'OCO_${configKey.toUpperCase()}' or it doesn't exist.`
+ );
+ ce(
+ `Manually fix the '.env' file or global '~/.opencommit' config file.`
+ );
+ process.exit(1);
+ }
+ }
+ return config8;
+};
+var setConfig = (keyValues) => {
+ const config8 = getConfig() || {};
+ for (const [configKey, configValue] of keyValues) {
+ if (!configValidators.hasOwnProperty(configKey)) {
+ throw new Error(`Unsupported config key: ${configKey}`);
+ }
+ let parsedConfigValue;
+ try {
+ parsedConfigValue = JSON.parse(configValue);
+ } catch (error) {
+ parsedConfigValue = configValue;
+ }
+ const validValue = configValidators[configKey](parsedConfigValue);
+ config8[configKey] = validValue;
+ }
+ (0, import_fs.writeFileSync)(configPath, (0, import_ini.stringify)(config8), "utf8");
+ ce(`${source_default.green("\u2714")} Config successfully set`);
+};
+var configCommand = G3(
+ {
+ name: "config" /* config */,
+ parameters: ["", ""]
+ },
+ async (argv) => {
+ ae("opencommit \u2014 config");
+ try {
+ const { mode: mode2, keyValues } = argv._;
+ if (mode2 === "get" /* get */) {
+ const config8 = getConfig() || {};
+ for (const key of keyValues) {
+ ce(`${key}=${config8[key]}`);
+ }
+ } else if (mode2 === "set" /* set */) {
+ await setConfig(
+ keyValues.map((keyValue) => keyValue.split("="))
+ );
+ } else {
+ throw new Error(
+ `Unsupported mode: ${mode2}. Valid modes are: "set" and "get"`
+ );
+ }
+ } catch (error) {
+ ce(`${source_default.red("\u2716")} ${error}`);
+ process.exit(1);
+ }
+ }
+);
+
+// src/prompts.ts
+var import_openai3 = __toESM(require_dist(), 1);
+
+// src/modules/commitlint/constants.ts
+var COMMITLINT_LLM_CONFIG_PATH = `${process.env.PWD}/.opencommit-commitlint`;
+
+// src/modules/commitlint/crypto.ts
+var import_crypto = __toESM(require("crypto"), 1);
+var computeHash = async (content, algorithm = "sha256") => {
+ try {
+ const hash = import_crypto.default.createHash(algorithm);
+ hash.update(content);
+ return hash.digest("hex");
+ } catch (error) {
+ console.error("Error while computing hash:", error);
+ throw error;
+ }
+};
+
+// src/modules/commitlint/prompts.ts
+var import_openai = __toESM(require_dist(), 1);
+var import_types = __toESM(require_lib(), 1);
+var config2 = getConfig();
+var translation = i18n[config2?.OCO_LANGUAGE || "en"];
+var getTypeRuleExtraDescription = (type, prompt) => prompt?.questions?.type?.enum?.[type]?.description;
+var llmReadableRules = {
+ blankline: (key, applicable) => `There should ${applicable} be a blank line at the beginning of the ${key}.`,
+ caseRule: (key, applicable, value) => `The ${key} should ${applicable} be in ${Array.isArray(value) ? `one of the following case:
+ - ${value.join("\n - ")}.` : `${value} case.`}`,
+ emptyRule: (key, applicable) => `The ${key} should ${applicable} be empty.`,
+ enumRule: (key, applicable, value) => `The ${key} should ${applicable} be one of the following values:
+ - ${Array.isArray(value) ? value.join("\n - ") : value}.`,
+ enumTypeRule: (key, applicable, value, prompt) => `The ${key} should ${applicable} be one of the following values:
+ - ${Array.isArray(value) ? value.map((v4) => {
+ const description = getTypeRuleExtraDescription(v4, prompt);
+ if (description) {
+ return `${v4} (${description})`;
+ } else
+ return v4;
+ }).join("\n - ") : value}.`,
+ fullStopRule: (key, applicable, value) => `The ${key} should ${applicable} end with '${value}'.`,
+ maxLengthRule: (key, applicable, value) => `The ${key} should ${applicable} have ${value} characters or less.`,
+ minLengthRule: (key, applicable, value) => `The ${key} should ${applicable} have ${value} characters or more.`
+};
+var rulesPrompts = {
+ "body-case": (applicable, value) => llmReadableRules.caseRule("body", applicable, value),
+ "body-empty": (applicable) => llmReadableRules.emptyRule("body", applicable, void 0),
+ "body-full-stop": (applicable, value) => llmReadableRules.fullStopRule("body", applicable, value),
+ "body-leading-blank": (applicable) => llmReadableRules.blankline("body", applicable, void 0),
+ "body-max-length": (applicable, value) => llmReadableRules.maxLengthRule("body", applicable, value),
+ "body-max-line-length": (applicable, value) => `Each line of the body should ${applicable} have ${value} characters or less.`,
+ "body-min-length": (applicable, value) => llmReadableRules.minLengthRule("body", applicable, value),
+ "footer-case": (applicable, value) => llmReadableRules.caseRule("footer", applicable, value),
+ "footer-empty": (applicable) => llmReadableRules.emptyRule("footer", applicable, void 0),
+ "footer-leading-blank": (applicable) => llmReadableRules.blankline("footer", applicable, void 0),
+ "footer-max-length": (applicable, value) => llmReadableRules.maxLengthRule("footer", applicable, value),
+ "footer-max-line-length": (applicable, value) => `Each line of the footer should ${applicable} have ${value} characters or less.`,
+ "footer-min-length": (applicable, value) => llmReadableRules.minLengthRule("footer", applicable, value),
+ "header-case": (applicable, value) => llmReadableRules.caseRule("header", applicable, value),
+ "header-full-stop": (applicable, value) => llmReadableRules.fullStopRule("header", applicable, value),
+ "header-max-length": (applicable, value) => llmReadableRules.maxLengthRule("header", applicable, value),
+ "header-min-length": (applicable, value) => llmReadableRules.minLengthRule("header", applicable, value),
+ "references-empty": (applicable) => llmReadableRules.emptyRule("references section", applicable, void 0),
+ "scope-case": (applicable, value) => llmReadableRules.caseRule("scope", applicable, value),
+ "scope-empty": (applicable) => llmReadableRules.emptyRule("scope", applicable, void 0),
+ "scope-enum": (applicable, value) => llmReadableRules.enumRule("type", applicable, value),
+ "scope-max-length": (applicable, value) => llmReadableRules.maxLengthRule("scope", applicable, value),
+ "scope-min-length": (applicable, value) => llmReadableRules.minLengthRule("scope", applicable, value),
+ "signed-off-by": (applicable, value) => `The commit message should ${applicable} have a "Signed-off-by" line with the value "${value}".`,
+ "subject-case": (applicable, value) => llmReadableRules.caseRule("subject", applicable, value),
+ "subject-empty": (applicable) => llmReadableRules.emptyRule("subject", applicable, void 0),
+ "subject-full-stop": (applicable, value) => llmReadableRules.fullStopRule("subject", applicable, value),
+ "subject-max-length": (applicable, value) => llmReadableRules.maxLengthRule("subject", applicable, value),
+ "subject-min-length": (applicable, value) => llmReadableRules.minLengthRule("subject", applicable, value),
+ "type-case": (applicable, value) => llmReadableRules.caseRule("type", applicable, value),
+ "type-empty": (applicable) => llmReadableRules.emptyRule("type", applicable, void 0),
+ "type-enum": (applicable, value, prompt) => llmReadableRules.enumTypeRule("type", applicable, value, prompt),
+ "type-max-length": (applicable, value) => llmReadableRules.maxLengthRule("type", applicable, value),
+ "type-min-length": (applicable, value) => llmReadableRules.minLengthRule("type", applicable, value)
+};
+var getPrompt = (ruleName, ruleConfig, prompt) => {
+ const [severity, applicable, value] = ruleConfig;
+ if (severity === import_types.RuleConfigSeverity.Disabled)
+ return null;
+ const promptFn = rulesPrompts[ruleName];
+ if (promptFn) {
+ return promptFn(applicable, value, prompt);
+ }
+ ce(`${source_default.red("\u2716")} No prompt handler for rule "${ruleName}".`);
+ return `Please manualy set the prompt for rule "${ruleName}".`;
+};
+var inferPromptsFromCommitlintConfig = (config8) => {
+ const { rules, prompt } = config8;
+ if (!rules)
+ return [];
+ return Object.keys(rules).map(
+ (ruleName) => getPrompt(ruleName, rules[ruleName], prompt)
+ ).filter((prompt2) => prompt2 !== null);
+};
+var STRUCTURE_OF_COMMIT = `
+- Header of commit is composed of type, scope, subject: ():
+- Description of commit is composed of body and footer (optional):
+