Compare commits

..

23 Commits

Author SHA1 Message Date
di-sukharev
b79aef5fad build 2023-09-18 14:23:43 +08:00
di-sukharev
57d9cc59b5 fix(config.ts): add default value for config parameter in OCO_OPENAI_API_KEY validator function
The OCO_OPENAI_API_KEY validator function now accepts an optional config parameter with a default value of an empty object {}. This change ensures that the function can be called without providing the config parameter, improving flexibility and avoiding potential errors when the parameter is not provided.
2023-09-18 14:21:55 +08:00
di-sukharev
e599700d72 build 2023-09-09 15:52:29 +08:00
di-sukharev
2761403735 Merge remote-tracking branch 'origin/master' into dev 2023-09-09 15:52:13 +08:00
di-sukharev
e57033c4a1 chore(README.md): update information about default model and cost
The default model used by OpenCommit is ChatGPT (3.5-turbo-16k) official model. It is mentioned that the cost should not exceed $0.10 per casual working day. Additionally, it is now mentioned that users have the option to switch to gpt-4, which is better but more expensive. This update provides users with more information about the available models and their associated costs.
2023-09-05 20:30:39 +08:00
di-sukharev
ca049e4b5d chore(package.json): update deploy script to push tags before publishing to npm
The deploy script in package.json has been updated to push tags before publishing to npm. This ensures that the latest version tag is pushed to the remote repository before publishing the package.
2023-09-05 13:57:20 +08:00
di-sukharev
2d48648f52 chore(package.json): update version to 3.0.3
The version in package.json has been updated from 3.0.2 to 3.0.3. This change is made to reflect the latest version of the project.
2023-09-05 13:51:21 +08:00
di-sukharev
40297e0c6a chore(package.json): update version to 3.0.2
The version in package.json has been updated from 3.0.1 to 3.0.2. This change is made to reflect the latest version of the project.
2023-09-05 13:49:17 +08:00
di-sukharev
75f0cd47b8 chore(package.json): update version to 3.0.1
The version in package.json has been updated from 3.0.0 to 3.0.1. This change is made to reflect the new version of the project.
2023-09-05 13:48:09 +08:00
Sukharev
c76313737d #247: fix (#248) 2023-09-05 13:45:34 +08:00
di-sukharev
a2b1890e7e build 2023-09-05 13:42:30 +08:00
di-sukharev
df705b97b7 Merge remote-tracking branch 'origin/master' into dev 2023-09-05 13:42:22 +08:00
di-sukharev
df280b7db7 fix(commitlint): use process.cwd() as fallback for process.env.PWD to ensure compatibility across platforms
The commitlint module now uses process.cwd() as a fallback when process.env.PWD is not available. This ensures compatibility across different platforms and environments when determining the path to the node_modules directory.
2023-09-05 13:39:49 +08:00
Sukharev
67dff60a7d chore(prompts.ts): update INIT_MAIN_PROMPT content to provide clearer instructions and improve readability (#245) 2023-09-03 15:39:52 +08:00
di-sukharev
08fb4d801f chore: add .npmignore file and update package.json to include specific files in the "files" field
The .npmignore file is added to the project. It currently includes the file "out/github-action.cjs" to be ignored when publishing the package to npm.

In the package.json file, the "files" field is updated to include the files "out/cli.cjs" and "out/tiktoken_bg.wasm". This ensures that these files are included when publishing the package to npm.

The "deploy" script in the package.json file is also updated to include pushing tags to the remote repository using "git push --tags". This ensures that the newly created version tags are pushed along with the code changes.
2023-09-03 15:29:29 +08:00
di-sukharev
ac8c87be9e docs(README.md): add note about MacOS potentially requiring 'sudo' when installing package globally
The README.md file now includes a note that MacOS may prompt the user to run the 'npm install -g opencommit' command with 'sudo' when installing the package globally. This note is added to provide clarity and help users who encounter this situation.
2023-09-03 15:22:47 +08:00
di-sukharev
a9050fda39 build 2023-09-03 15:17:12 +08:00
Sukharev
b98b892ba1 v3.0.0 (#243)
* update major version

---------

Co-authored-by: E Einowski <5124085+EwiththeBowtie@users.noreply.github.com>
Co-authored-by: Max Zavodniuk <lovemaxonly@gmail.com>
Co-authored-by: Malthe Poulsen <30603252+malpou@users.noreply.github.com>
Co-authored-by: Sébastien Fichot <fichot.sebastien@gmail.com>
2023-09-03 15:16:02 +08:00
di-sukharev
0460a252e2 update major version 2023-09-03 15:11:14 +08:00
di-sukharev
ebeb68fd9b chore(package.json): update deploy script to use 'git push --follow-tags' instead of 'git push --tags'
The deploy script in package.json has been updated to use 'git push --follow-tags' instead of 'git push --tags'. This change ensures that tags are pushed along with the commit when deploying the application.
2023-09-03 15:07:43 +08:00
di-sukharev
a9f550fb79 Merge remote-tracking branch 'origin/master' into dev 2023-09-03 15:04:09 +08:00
Sukharev
4181c0b20d Refactoring and cleaning for v3 (#244)
* chore(README.md): update setup instructions for OpenCommit as a GitHub Action
fix(commit.ts): check if OCO_MESSAGE_TEMPLATE_PLACEHOLDER exists before replacing it in the commit message template
The README.md file has been updated to reflect the changes in the setup instructions for using OpenCommit as a GitHub Action. The new instructions provide a file template for the GitHub Action workflow and include the latest version of the OpenCommit GitHub Action.

In the commit.ts file, a fix has been made to check if the OCO_MESSAGE_TEMPLATE_PLACEHOLDER exists before replacing it in the commit message template. This ensures that the replacement is only performed when the placeholder is present, preventing any potential errors.
2023-09-03 14:59:37 +08:00
Sukharev
ba5dd848b8 Update README.md 2023-08-24 12:00:43 +08:00
9 changed files with 42 additions and 23 deletions

1
.npmignore Normal file
View File

@@ -0,0 +1 @@
out/github-action.cjs

1
.opencommitignore Normal file
View File

@@ -0,0 +1 @@
out

View File

@@ -29,6 +29,8 @@ You can use OpenCommit by simply running it via the CLI like this `oco`. 2 secon
npm install -g opencommit
```
MacOS may ask to run the command with `sudo` when installing a package globally.
2. Get your API key from [OpenAI](https://platform.openai.com/account/api-keys). Make sure that you add your payment details, so the API works.
3. Set the key to OpenCommit config:
@@ -326,4 +328,10 @@ Interactive rebase (`rebase -i`) changes commits' SHA, so the commit history in
## Payments
You pay for your requests to OpenAI API. OpenCommit uses ChatGPT (3.5-turbo) official model, which is ~15x times cheaper than GPT-4.
You pay for your requests to OpenAI API on your own.
OpenCommit stores your key locally.
OpenCommit by default uses 3.5-turbo-16k model, it should not exceed $0.10 per casual working day.
You may switch to gpt-4, it's better, but more expensive.

View File

@@ -16384,7 +16384,7 @@ function G3(t, e2) {
// package.json
var package_default = {
name: "opencommit",
version: "2.4.2",
version: "3.0.4",
description: "Auto-generate impressive commits in 1 second. Killing lame commits with AI \u{1F92F}\u{1F52B}",
keywords: [
"git",
@@ -16410,7 +16410,8 @@ var package_default = {
author: "https://github.com/di-sukharev",
license: "MIT",
files: [
"out/**/*"
"out/cli.cjs",
"out/tiktoken_bg.wasm"
],
release: {
branches: [
@@ -16426,7 +16427,7 @@ var package_default = {
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",
deploy: "npm run build:push && npm version patch && git push --tags && git push && npm publish --tag latest",
deploy: "npm version patch && npm run build:push && git push --tags && npm publish --tag latest",
lint: "eslint src --ext ts && tsc --noEmit",
format: "prettier --write src"
},
@@ -21477,7 +21478,7 @@ var validateConfig = (key, condition, validationMessage) => {
}
};
var configValidators = {
["OCO_OPENAI_API_KEY" /* OCO_OPENAI_API_KEY */](value, config8) {
["OCO_OPENAI_API_KEY" /* OCO_OPENAI_API_KEY */](value, config8 = {}) {
validateConfig("OCO_OPENAI_API_KEY" /* OCO_OPENAI_API_KEY */, value, "Cannot be empty");
validateConfig(
"OCO_OPENAI_API_KEY" /* OCO_OPENAI_API_KEY */,
@@ -21906,7 +21907,7 @@ var commitlintPrompts = {
// src/modules/commitlint/pwd-commitlint.ts
var import_path2 = __toESM(require("path"), 1);
var nodeModulesPath = import_path2.default.join(
process.env.PWD,
process.env.PWD || process.cwd(),
"node_modules",
"@commitlint",
"load"
@@ -21997,10 +21998,10 @@ var translation3 = i18n[config5?.OCO_LANGUAGE || "en"];
var IDENTITY = "You are to act as the author of a commit message in git.";
var INIT_MAIN_PROMPT2 = (language) => ({
role: import_openai3.ChatCompletionRequestMessageRoleEnum.System,
content: `${IDENTITY} Your mission is to create clean and comprehensive commit messages in the conventional commit convention and explain WHAT were the changes and WHY the changes were done. I'll send you an output of 'git diff --staged' command, and you convert it into a commit message.
content: `${IDENTITY} Your mission is to create clean and comprehensive commit messages as per the conventional commit convention and explain WHAT were the changes and mainly WHY the changes were done. I'll send you an output of 'git diff --staged' command, and you are to convert it into a commit message.
${config5?.OCO_EMOJI ? "Use GitMoji convention to preface the commit." : "Do not preface the commit with anything."}
${config5?.OCO_DESCRIPTION ? `Add a short description of WHY the changes are done after the commit message. Don't start it with "This commit", just describe the changes.` : "Don't add any descriptions to the commit, only commit message."}
Use the present tense. Lines must not be longer than 74 characters. Use ${language} to answer.`
Use the present tense. Lines must not be longer than 74 characters. Use ${language} for the commit message.`
});
var INIT_DIFF_PROMPT = {
role: import_openai3.ChatCompletionRequestMessageRoleEnum.User,
@@ -22312,7 +22313,7 @@ var generateCommitMessageFromGitDiff = async (diff, extraArgs2) => {
try {
let commitMessage = await generateCommitMessageByDiff(diff);
const messageTemplate = checkMessageTemplate(extraArgs2);
if (typeof messageTemplate === "string") {
if (config7?.OCO_MESSAGE_TEMPLATE_PLACEHOLDER && typeof messageTemplate === "string") {
commitMessage = messageTemplate.replace(
config7?.OCO_MESSAGE_TEMPLATE_PLACEHOLDER,
commitMessage

View File

@@ -27900,7 +27900,7 @@ var validateConfig = (key, condition, validationMessage) => {
}
};
var configValidators = {
["OCO_OPENAI_API_KEY" /* OCO_OPENAI_API_KEY */](value, config7) {
["OCO_OPENAI_API_KEY" /* OCO_OPENAI_API_KEY */](value, config7 = {}) {
validateConfig("OCO_OPENAI_API_KEY" /* OCO_OPENAI_API_KEY */, value, "Cannot be empty");
validateConfig(
"OCO_OPENAI_API_KEY" /* OCO_OPENAI_API_KEY */,
@@ -28320,7 +28320,7 @@ var commitlintPrompts = {
// src/modules/commitlint/pwd-commitlint.ts
var import_path2 = __toESM(require("path"), 1);
var nodeModulesPath = import_path2.default.join(
process.env.PWD,
process.env.PWD || process.cwd(),
"node_modules",
"@commitlint",
"load"
@@ -28411,10 +28411,10 @@ var translation3 = i18n[config5?.OCO_LANGUAGE || "en"];
var IDENTITY = "You are to act as the author of a commit message in git.";
var INIT_MAIN_PROMPT2 = (language) => ({
role: import_openai3.ChatCompletionRequestMessageRoleEnum.System,
content: `${IDENTITY} Your mission is to create clean and comprehensive commit messages in the conventional commit convention and explain WHAT were the changes and WHY the changes were done. I'll send you an output of 'git diff --staged' command, and you convert it into a commit message.
content: `${IDENTITY} Your mission is to create clean and comprehensive commit messages as per the conventional commit convention and explain WHAT were the changes and mainly WHY the changes were done. I'll send you an output of 'git diff --staged' command, and you are to convert it into a commit message.
${config5?.OCO_EMOJI ? "Use GitMoji convention to preface the commit." : "Do not preface the commit with anything."}
${config5?.OCO_DESCRIPTION ? `Add a short description of WHY the changes are done after the commit message. Don't start it with "This commit", just describe the changes.` : "Don't add any descriptions to the commit, only commit message."}
Use the present tense. Lines must not be longer than 74 characters. Use ${language} to answer.`
Use the present tense. Lines must not be longer than 74 characters. Use ${language} for the commit message.`
});
var INIT_DIFF_PROMPT = {
role: import_openai3.ChatCompletionRequestMessageRoleEnum.User,

View File

@@ -1,6 +1,6 @@
{
"name": "opencommit",
"version": "2.4.2",
"version": "3.0.4",
"description": "Auto-generate impressive commits in 1 second. Killing lame commits with AI 🤯🔫",
"keywords": [
"git",
@@ -26,7 +26,8 @@
"author": "https://github.com/di-sukharev",
"license": "MIT",
"files": [
"out/**/*"
"out/cli.cjs",
"out/tiktoken_bg.wasm"
],
"release": {
"branches": [
@@ -42,7 +43,7 @@
"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",
"deploy": "npm run build:push && npm version patch && git push --tags && git push && npm publish --tag latest",
"deploy": "npm version patch && npm run build:push && git push --tags && npm publish --tag latest",
"lint": "eslint src --ext ts && tsc --noEmit",
"format": "prettier --write src"
},

View File

@@ -47,7 +47,7 @@ const validateConfig = (
};
export const configValidators = {
[CONFIG_KEYS.OCO_OPENAI_API_KEY](value: any, config?: any) {
[CONFIG_KEYS.OCO_OPENAI_API_KEY](value: any, config: any = {}) {
validateConfig(CONFIG_KEYS.OCO_OPENAI_API_KEY, value, 'Cannot be empty');
validateConfig(
CONFIG_KEYS.OCO_OPENAI_API_KEY,

View File

@@ -1,7 +1,7 @@
import path from 'path';
const nodeModulesPath = path.join(
process.env.PWD as string,
process.env.PWD || process.cwd(),
'node_modules',
'@commitlint',
'load'

View File

@@ -20,11 +20,18 @@ export const IDENTITY =
const INIT_MAIN_PROMPT = (language: string): ChatCompletionRequestMessage => ({
role: ChatCompletionRequestMessageRoleEnum.System,
// prettier-ignore
content: `${IDENTITY} Your mission is to create clean and comprehensive commit messages in the conventional commit convention and explain WHAT were the changes and WHY the changes were done. I'll send you an output of 'git diff --staged' command, and you convert it into a commit message.
${config?.OCO_EMOJI ? 'Use GitMoji convention to preface the commit.' : 'Do not preface the commit with anything.'}
${config?.OCO_DESCRIPTION ? 'Add a short description of WHY the changes are done after the commit message. Don\'t start it with "This commit", just describe the changes.' : "Don't add any descriptions to the commit, only commit message."}
Use the present tense. Lines must not be longer than 74 characters. Use ${language} to answer.`
content: `${IDENTITY} Your mission is to create clean and comprehensive commit messages as per the conventional commit convention and explain WHAT were the changes and mainly WHY the changes were done. I'll send you an output of 'git diff --staged' command, and you are to convert it into a commit message.
${
config?.OCO_EMOJI
? 'Use GitMoji convention to preface the commit.'
: 'Do not preface the commit with anything.'
}
${
config?.OCO_DESCRIPTION
? 'Add a short description of WHY the changes are done after the commit message. Don\'t start it with "This commit", just describe the changes.'
: "Don't add any descriptions to the commit, only commit message."
}
Use the present tense. Lines must not be longer than 74 characters. Use ${language} for the commit message.`
});
export const INIT_DIFF_PROMPT: ChatCompletionRequestMessage = {