Compare commits

..

137 Commits

Author SHA1 Message Date
di-sukharev
bf931b0c3c chore: update package and action descriptions to better reflect the purpose of the project and remove unnecessary details
feat: add keywords to package and action descriptions to improve searchability and discoverability of the project
feat: update deploy script in package.json to include version bump and publish to npm registry with latest tag
2023-05-21 16:15:13 +08:00
di-sukharev
f687709abe build 2023-05-21 15:57:29 +08:00
di-sukharev
a969d9819e build 2023-05-21 15:53:32 +08:00
di-sukharev
d0d4b2d11d build 2023-05-21 15:35:01 +08:00
di-sukharev
d03f16c6ee build 2023-05-21 15:10:18 +08:00
di-sukharev
925f004f28 build 2023-05-21 15:10:18 +08:00
di-sukharev
f7f878b6dd build 2023-05-21 15:10:18 +08:00
di-sukharev
2f923f94ea build 2023-05-21 15:10:18 +08:00
di-sukharev
60410e6404 build 2023-05-21 15:10:18 +08:00
di-sukharev
f42e1ff9a3 build 2023-05-21 15:10:18 +08:00
di-sukharev
0c92feb3ae build 2023-05-21 15:10:18 +08:00
di-sukharev
8ae293e947 build 2023-05-21 15:10:18 +08:00
di-sukharev
68746fa17d build 2023-05-21 15:10:18 +08:00
di-sukharev
1aeed7c9ca build 2023-05-21 15:10:18 +08:00
di-sukharev
867a0158ed build 2023-05-21 15:10:18 +08:00
di-sukharev
942c2d8612 build 2023-05-21 15:10:18 +08:00
di-sukharev
2932a1fc28 build 2023-05-21 15:10:18 +08:00
di-sukharev
fef923a099 build 2023-05-21 15:10:18 +08:00
di-sukharev
851c8baff1 build 2023-05-21 15:10:18 +08:00
di-sukharev
f5517ed59f build 2023-05-21 15:10:18 +08:00
di-sukharev
3c9aabd239 build 2023-05-21 15:10:18 +08:00
di-sukharev
f506c1287c build 2023-05-21 15:10:18 +08:00
di-sukharev
1012e3948a build 2023-05-21 15:10:18 +08:00
di-sukharev
f6e2d439a4 build 2023-05-21 15:10:18 +08:00
di-sukharev
bcdc976c49 build 2023-05-21 15:10:18 +08:00
di-sukharev
ed9729e327 build 2023-05-21 15:10:18 +08:00
di-sukharev
1bdcc8adae build 2023-05-21 15:10:18 +08:00
di-sukharev
efdd98318e build 2023-05-21 15:10:18 +08:00
di-sukharev
af2e25dce0 build 2023-05-21 15:10:18 +08:00
di-sukharev
a0961f899e build 2023-05-21 15:10:18 +08:00
di-sukharev
5065c75730 build 2023-05-21 15:10:18 +08:00
di-sukharev
447a938a48 build 2023-05-21 15:10:18 +08:00
di-sukharev
b4ecce224b build 2023-05-21 15:10:18 +08:00
di-sukharev
07f07e5e18 build 2023-05-21 15:10:18 +08:00
di-sukharev
cd89054f0f build 2023-05-21 15:10:18 +08:00
di-sukharev
430f08a705 build 2023-05-21 15:10:17 +08:00
di-sukharev
65c9c729de build 2023-05-21 15:10:17 +08:00
di-sukharev
6c3bcdb6f9 build 2023-05-21 15:10:17 +08:00
di-sukharev
730bebe8f5 build 2023-05-21 15:10:17 +08:00
di-sukharev
2265e92e84 build 2023-05-21 15:10:17 +08:00
di-sukharev
939deca46f build 2023-05-21 15:10:17 +08:00
di-sukharev
d715685f0d build 2023-05-21 15:10:17 +08:00
di-sukharev
f2cf084bbf build 2023-05-21 15:10:17 +08:00
di-sukharev
eb4da47642 build 2023-05-21 15:10:17 +08:00
di-sukharev
b475d16c82 build 2023-05-21 15:10:17 +08:00
di-sukharev
fee4371bc6 build 2023-05-21 15:10:17 +08:00
di-sukharev
69e398ea2f build 2023-05-21 15:10:17 +08:00
di-sukharev
de4b2bd74a build 2023-05-21 15:10:17 +08:00
di-sukharev
b8c1e8c5ba build 2023-05-21 15:10:17 +08:00
di-sukharev
b0363fa638 build 2023-05-21 15:10:17 +08:00
di-sukharev
223a587765 build 2023-05-21 15:10:17 +08:00
di-sukharev
22f37e0da5 build 2023-05-21 15:10:17 +08:00
di-sukharev
2c5a37525c build 2023-05-21 15:10:17 +08:00
di-sukharev
9c87d8f7b8 build 2023-05-21 15:10:17 +08:00
di-sukharev
8f50c021c4 build 2023-05-21 15:10:17 +08:00
di-sukharev
9fb6946a6b build 2023-05-21 15:10:17 +08:00
di-sukharev
03210f16d0 build 2023-05-21 15:10:17 +08:00
di-sukharev
cec6890525 build 2023-05-21 15:10:17 +08:00
di-sukharev
3d199eb6d3 build 2023-05-21 15:10:17 +08:00
di-sukharev
a17462e9a2 build 2023-05-21 15:10:17 +08:00
di-sukharev
cfa5462cbd build 2023-05-21 15:10:17 +08:00
di-sukharev
c30d34e1b5 build 2023-05-21 15:10:17 +08:00
di-sukharev
b2ef14c586 build 2023-05-21 15:10:17 +08:00
di-sukharev
88f367d662 build 2023-05-21 15:10:17 +08:00
di-sukharev
32df5d5fe1 build 2023-05-21 15:10:17 +08:00
di-sukharev
13afc81858 build 2023-05-21 15:10:17 +08:00
di-sukharev
bf430b23db build 2023-05-21 15:10:17 +08:00
di-sukharev
820365dd06 build 2023-05-21 15:10:17 +08:00
di-sukharev
dd39ef2473 build 2023-05-21 15:10:17 +08:00
di-sukharev
5b0e3bf061 build 2023-05-21 15:10:17 +08:00
di-sukharev
a7da40f151 build 2023-05-21 15:10:17 +08:00
di-sukharev
23037a3988 build 2023-05-21 15:10:17 +08:00
di-sukharev
66eb8e1008 build 2023-05-21 15:10:17 +08:00
di-sukharev
90361b65ee build 2023-05-21 15:10:17 +08:00
di-sukharev
b7938e3488 build 2023-05-21 15:10:17 +08:00
di-sukharev
13db5f4498 build 2023-05-21 15:10:17 +08:00
di-sukharev
885b653e2e build 2023-05-21 15:10:17 +08:00
di-sukharev
f7ca45540a build 2023-05-21 15:10:17 +08:00
di-sukharev
10c89ded6e build 2023-05-21 15:10:17 +08:00
di-sukharev
542a53f3db build 2023-05-21 15:10:17 +08:00
di-sukharev
3b32ef3608 build 2023-05-21 15:10:17 +08:00
di-sukharev
6d23333305 build 2023-05-21 15:10:17 +08:00
di-sukharev
bd65b100a5 build 2023-05-21 15:10:16 +08:00
di-sukharev
b1e099f4bc build 2023-05-21 15:10:16 +08:00
di-sukharev
cfe891fec4 build 2023-05-21 15:10:16 +08:00
di-sukharev
fd5bccbcb1 build 2023-05-21 15:10:16 +08:00
di-sukharev
cbd2138552 build 2023-05-21 15:10:16 +08:00
di-sukharev
432fe88e82 build 2023-05-21 15:10:16 +08:00
di-sukharev
0f0c976b08 build 2023-05-21 15:10:16 +08:00
di-sukharev
06574056d7 build 2023-05-21 15:10:16 +08:00
di-sukharev
39e6568d73 build 2023-05-21 15:10:16 +08:00
di-sukharev
1867c96f22 build 2023-05-21 15:10:16 +08:00
di-sukharev
7f83ff9943 build 2023-05-21 15:10:16 +08:00
di-sukharev
f6749f38e9 build 2023-05-21 15:10:16 +08:00
di-sukharev
bb2dc327a7 build 2023-05-21 15:10:16 +08:00
di-sukharev
c45d5aa12b build 2023-05-21 15:10:16 +08:00
di-sukharev
17e80e0b4f build 2023-05-21 15:10:16 +08:00
di-sukharev
8acaf4c860 build 2023-05-21 15:10:16 +08:00
di-sukharev
20a2f68389 build 2023-05-21 15:10:16 +08:00
di-sukharev
25f791cfd5 build 2023-05-21 15:10:16 +08:00
di-sukharev
c9eb947148 build 2023-05-21 15:10:16 +08:00
di-sukharev
d6219478fc build 2023-05-21 15:10:16 +08:00
di-sukharev
be06729ad8 build 2023-05-21 15:10:16 +08:00
di-sukharev
f2680f2bf3 build 2023-05-21 15:10:16 +08:00
di-sukharev
f7afa94c9e build 2023-05-21 15:10:16 +08:00
di-sukharev
291cb2b5b6 build 2023-05-21 15:10:16 +08:00
di-sukharev
4552cc49a8 build 2023-05-21 15:10:16 +08:00
di-sukharev
8d09fe0b7c build 2023-05-21 15:10:16 +08:00
di-sukharev
490d209c64 build 2023-05-21 15:10:16 +08:00
di-sukharev
52a71728d4 build 2023-05-21 15:10:16 +08:00
di-sukharev
ffdf45dc17 build 2023-05-21 15:10:16 +08:00
di-sukharev
211ad20c34 build 2023-05-21 15:10:16 +08:00
di-sukharev
17802dcbd6 build 2023-05-21 15:10:16 +08:00
di-sukharev
053e1da0f1 removed logs 2023-05-21 15:10:16 +08:00
di-sukharev
666760d412 fixed 2023-05-21 15:10:16 +08:00
di-sukharev
c0e183797f build 2023-05-21 15:10:16 +08:00
di-sukharev
3dfa1e4a33 build 2023-05-21 15:10:16 +08:00
di-sukharev
2f5ea33f0f build 2023-05-21 15:10:16 +08:00
di-sukharev
476136a391 build 2023-05-21 15:10:16 +08:00
di-sukharev
fe555c66ed fix(api.ts): handle unknown errors in catch block and log error message if available
refactor(github-action.ts): remove console.log statements and improve readability of code
2023-05-21 15:10:16 +08:00
di-sukharev
431e10cb54 build 2023-05-21 15:10:16 +08:00
di-sukharev
e356b5dcf3 added log 2023-05-21 15:10:16 +08:00
di-sukharev
9fea9e244c build 2023-05-21 15:10:16 +08:00
di-sukharev
b16271a62f build 2023-05-21 15:10:16 +08:00
di-sukharev
87c978a58a build 2023-05-21 15:10:16 +08:00
di-sukharev
d6caa0c73c refactor(github-action.ts): remove unused spinner import and usage
refactor(github-action.ts): remove unused retries parameter from run function
refactor(github-action.ts): remove unused core.info call
refactor(github-action.ts): remove unused intro call
refactor(github-action.ts): remove unused spinner.stop call and replace with outro call
2023-05-21 15:10:16 +08:00
di-sukharev
efe0172f2d chore(action.yml): update node version to 16 to match the latest LTS version 2023-05-21 15:10:16 +08:00
di-sukharev
ba9503142c build 2023-05-21 15:10:16 +08:00
di-sukharev
b87faf0096 chore(README.md): update OpenCommit configuration variables to match new naming convention
fix(api.ts): change config variable names to match new naming convention
fix(api.ts): increase default max_tokens to 500
fix(commit.ts): stop spinner after commit message is generated

fix(config.ts): change config keys to use OCO prefix to avoid conflicts with other libraries
feat(config.ts): add support for OCO_EXCLUDE environment variable to exclude files from being committed
fix(prepare-commit-msg-hook.ts): change OPENAI_API_KEY to OCO_OPENAI_API_KEY to match new config keys
fix(generateCommitMessageFromGitDiff.ts): change config keys to use OCO prefix to match new config keys
2023-05-21 15:10:16 +08:00
di-sukharev
2681db1635 fix(action.yml): update path to main file to reflect new build output directory 2023-05-21 15:10:16 +08:00
di-sukharev
462798d7d2 remove /out from .gitignore to ba able to run opencommit via github action from other repos 2023-05-21 15:10:16 +08:00
di-sukharev
1abe655e00 chore(README.md): add instructions to setup OpenCommit as a Github Action
chore(action.yml): update description of the Github Action
feat(github-action.ts): add support for pattern input to only improve messages that match the regexp, e.g. ^fix$
2023-05-21 15:10:16 +08:00
di-sukharev
177a219ccb feat(commit.ts): add try-catch block to handle errors and show proper error messages
fix(commit.ts): fix indentation and formatting
feat(commit.ts): add support for selecting remote to push to when there are multiple remotes
fix(prepare-commit-msg-hook.ts): remove unnecessary if-else block and improve formatting
2023-05-21 15:10:16 +08:00
di-sukharev
373c90c760 refactor(commit.ts, prepare-commit-msg-hook.ts, generateCommitMessageFromGitDiff.ts, github-action.ts): rename generateCommitMessageWithChatCompletion to generateCommitMessageByDiff to improve semantics and consistency with other function names
feat(github-action.ts): add support for retrying the action in case of failure to improve robustness
2023-05-21 15:10:15 +08:00
di-sukharev
7652116e77 feat(github-action.ts): add support for pull_request events and improve event handling
refactor(github-action.ts): extract types for ListCommitsResponse, CommitsData, and CommitsArray
fix(github-action.ts): update improveCommitMessagesWithRebase function to accept CommitsArray type
2023-05-21 15:10:15 +08:00
di-sukharev
707d90de1c feat(package.json): add @octokit/webhooks-schemas and @octokit/webhooks-types for better webhook handling
refactor(github-action.ts): replace child_process with execa for better command execution
refactor(github-action.ts): use octokit/webhooks-types for improved typing and handling of GitHub events
feat(github-action.ts): add support for improving commit messages on push and pull_request events
2023-05-21 15:10:15 +08:00
di-sukharev
7615b95261 feat(action.yml): add OpenCommit GitHub Action configuration
feat(package.json): add @actions/core and @actions/github dependencies
feat(src/github-action.ts): create GitHub Action to check and replace 'oc' in commit messages with AI-generated messages
2023-05-21 15:10:15 +08:00
13 changed files with 42 additions and 50 deletions

View File

@@ -21,8 +21,8 @@
"rules": {
"prettier/prettier": "error",
"no-console": "error",
"import/order": "off",
"sort-imports": "off",
"import/order": "off",
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"import/first": "error",

View File

@@ -1,3 +1,2 @@
/build
/dist
/out
/dist

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) Dima Sukharev, https://github.com/di-sukharev
Copyright (c) Dima Sukharev
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View File

@@ -5,7 +5,7 @@
<h4 align="center">Follow the bird <a href="https://twitter.com/io_Y_oi"><img src="https://img.shields.io/twitter/follow/io_Y_oi?style=flat&label=io_Y_oi&logo=twitter&color=0bf&logoColor=fff" align="center"></a>
</h4>
</div>
<h2>Auto-generate meaningful commits in 1 second</h2>
<h2>GPT CLI to auto-generate impressive commits in 1 second</h2>
<p>Killing lame commits with AI 🤯🔫</p>
<a href="https://www.npmjs.com/package/opencommit"><img src="https://img.shields.io/npm/v/opencommit" alt="Current version"></a>
</div>
@@ -18,16 +18,22 @@
All the commits in this repo are done with OpenCommit — look into [the commits](https://github.com/di-sukharev/opencommit/commit/eae7618d575ee8d2e9fff5de56da79d40c4bc5fc) to see how OpenCommit works. Emoji and long commit description text is configurable.
## Setup OpenCommit as a Github Action 🔥
## Setup OpenCommit as a Github Action
OpenCommit is now available as a GitHub Action which automatically improves all new commits messages when you push to remote!
This is great if you want to make sure all of the commits in all of repository branches are meaningful and not lame like `fix1` or `done2`.
### Automatic 1 click setup
You can simply [setup the action automatically via the GitHub Marketplace](TODO).
### Manual 3 clicks setup
Create a file `.github/workflows/opencommit.yml` with contents below:
```yml
name: 'OpenCommit Action'
name: 'OpenCommit'
on:
push:
@@ -48,7 +54,7 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: di-sukharev/opencommit@github-action-v1.0.4
- uses: di-sukharev/opencommit@github-action
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -1,10 +1,7 @@
name: 'OpenCommit — improve commits with AI 🧙'
description: 'Replaces lame commit messages with meaningful AI-generated messages when you push to remote'
name: 'OpenCommit'
description: 'Replaces lame commit messages with meaningful AI-generated messages when you push to remote 🤯🔫'
author: 'https://github.com/di-sukharev'
repo: 'https://github.com/di-sukharev/opencommit/tree/github-action'
branding:
icon: 'git-commit'
color: 'green'
keywords:
[
'git',

View File

@@ -16272,7 +16272,7 @@ function G3(t, e2) {
// package.json
var package_default = {
name: "opencommit",
version: "2.0.17",
version: "2.0.15",
description: "Auto-generate impressive commits in 1 second. Killing lame commits with AI \u{1F92F}\u{1F52B}",
keywords: [
"git",
@@ -16315,7 +16315,6 @@ var package_default = {
dev: "ts-node ./src/cli.ts",
build: "rimraf out && node esbuild.config.js",
deploy: "npm run build && npm version patch && npm publish --tag latest",
"build:push": "npm run build && git add . && git commit -m 'build' && git push",
lint: "eslint src --ext ts && tsc --noEmit",
format: "prettier --write src"
},
@@ -17644,7 +17643,7 @@ var configValidators = {
}
validateConfig(
"OCO_OPENAI_MAX_TOKENS" /* OCO_OPENAI_MAX_TOKENS */,
value ? typeof value === "number" : void 0,
typeof value === "number",
"Must be a number"
);
return value;
@@ -17675,8 +17674,8 @@ var configValidators = {
},
["OCO_MODEL" /* OCO_MODEL */](value) {
validateConfig(
"OCO_MODEL" /* OCO_MODEL */,
["gpt-3.5-turbo", "gpt-4"].includes(value),
"OCO_OPENAI_BASE_PATH" /* OCO_OPENAI_BASE_PATH */,
value === "gpt-3.5-turbo" || value === "gpt-4",
`${value} is not supported yet, use 'gpt-4' or 'gpt-3.5-turbo' (default)`
);
return value;
@@ -17686,12 +17685,12 @@ 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_MAX_TOKENS: Number(process.env.OCO_OPENAI_MAX_TOKENS),
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",
OCO_LANGUAGE: process.env.OCO_LANGUAGE || "en"
OCO_MODEL: process.env.OCO_MODEL,
OCO_LANGUAGE: process.env.OCO_LANGUAGE
};
const configExists = (0, import_fs.existsSync)(configPath);
if (!configExists)
@@ -17699,10 +17698,6 @@ var getConfig = () => {
const configFile = (0, import_fs.readFileSync)(configPath, "utf8");
const config4 = (0, import_ini.parse)(configFile);
for (const configKey of Object.keys(config4)) {
if (!config4[configKey] || ["null", "undefined"].includes(config4[configKey])) {
config4[configKey] = void 0;
continue;
}
try {
const validator = configValidators[configKey];
const validValue = validator(

View File

@@ -26839,7 +26839,7 @@ var configValidators = {
}
validateConfig(
"OCO_OPENAI_MAX_TOKENS" /* OCO_OPENAI_MAX_TOKENS */,
value ? typeof value === "number" : void 0,
typeof value === "number",
"Must be a number"
);
return value;
@@ -26870,8 +26870,8 @@ var configValidators = {
},
["OCO_MODEL" /* OCO_MODEL */](value) {
validateConfig(
"OCO_MODEL" /* OCO_MODEL */,
["gpt-3.5-turbo", "gpt-4"].includes(value),
"OCO_OPENAI_BASE_PATH" /* OCO_OPENAI_BASE_PATH */,
value === "gpt-3.5-turbo" || value === "gpt-4",
`${value} is not supported yet, use 'gpt-4' or 'gpt-3.5-turbo' (default)`
);
return value;
@@ -26881,12 +26881,12 @@ 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_MAX_TOKENS: Number(process.env.OCO_OPENAI_MAX_TOKENS),
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",
OCO_LANGUAGE: process.env.OCO_LANGUAGE || "en"
OCO_MODEL: process.env.OCO_MODEL,
OCO_LANGUAGE: process.env.OCO_LANGUAGE
};
const configExists = (0, import_fs.existsSync)(configPath);
if (!configExists)
@@ -26894,10 +26894,6 @@ var getConfig = () => {
const configFile = (0, import_fs.readFileSync)(configPath, "utf8");
const config4 = (0, import_ini.parse)(configFile);
for (const configKey of Object.keys(config4)) {
if (!config4[configKey] || ["null", "undefined"].includes(config4[configKey])) {
config4[configKey] = void 0;
continue;
}
try {
const validator = configValidators[configKey];
const validValue = validator(

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "opencommit",
"version": "2.0.18",
"version": "2.0.15",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "opencommit",
"version": "2.0.18",
"version": "2.0.15",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.10.0",

View File

@@ -1,6 +1,6 @@
{
"name": "opencommit",
"version": "2.0.18",
"version": "2.0.15",
"description": "Auto-generate impressive commits in 1 second. Killing lame commits with AI 🤯🔫",
"keywords": [
"git",
@@ -43,7 +43,6 @@
"dev": "ts-node ./src/cli.ts",
"build": "rimraf out && node esbuild.config.js",
"deploy": "npm run build && npm version patch && npm publish --tag latest",
"build:push": "npm run build && git add . && git commit -m 'build' && git push",
"lint": "eslint src --ext ts && tsc --noEmit",
"format": "prettier --write src"
},

View File

@@ -1,5 +1,6 @@
import { execa } from 'execa';
import {
GenerateCommitMessageErrorEnum,
generateCommitMessageByDiff
} from '../generateCommitMessageFromGitDiff';
import {

View File

@@ -80,7 +80,7 @@ export const configValidators = {
}
validateConfig(
CONFIG_KEYS.OCO_OPENAI_MAX_TOKENS,
value ? typeof value === 'number' : undefined,
typeof value === 'number',
'Must be a number'
);
@@ -117,8 +117,8 @@ export const configValidators = {
[CONFIG_KEYS.OCO_MODEL](value: any) {
validateConfig(
CONFIG_KEYS.OCO_MODEL,
['gpt-3.5-turbo', 'gpt-4'].includes(value),
CONFIG_KEYS.OCO_OPENAI_BASE_PATH,
value === 'gpt-3.5-turbo' || value === 'gpt-4',
`${value} is not supported yet, use 'gpt-4' or 'gpt-3.5-turbo' (default)`
);
return value;
@@ -134,12 +134,12 @@ const configPath = pathJoin(homedir(), '.opencommit');
export const getConfig = (): ConfigType | null => {
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) : undefined,
OCO_OPENAI_MAX_TOKENS: Number(process.env.OCO_OPENAI_MAX_TOKENS),
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',
OCO_LANGUAGE: process.env.OCO_LANGUAGE || 'en'
OCO_MODEL: process.env.OCO_MODEL,
OCO_LANGUAGE: process.env.OCO_LANGUAGE
};
const configExists = existsSync(configPath);
@@ -149,10 +149,6 @@ export const getConfig = (): ConfigType | null => {
const config = iniParse(configFile);
for (const configKey of Object.keys(config)) {
if (!config[configKey] || ['null', 'undefined'].includes(config[configKey])) {
config[configKey] = undefined;
continue;
}
try {
const validator = configValidators[configKey as CONFIG_KEYS];
const validValue = validator(

View File

@@ -74,6 +74,9 @@ export enum GenerateCommitMessageErrorEnum {
emptyMessage = 'EMPTY_MESSAGE'
}
interface GenerateCommitMessageError {
error: GenerateCommitMessageErrorEnum;
}
const INIT_MESSAGES_PROMPT_LENGTH = INIT_MESSAGES_PROMPT.map(
(msg) => tokenCount(msg.content) + 4

View File

@@ -5,8 +5,8 @@
"module": "ESNext",
// "rootDir": "./src",
"resolveJsonModule": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"allowJs": true,