Compare commits

..

7 Commits

Author SHA1 Message Date
di-sukharev
c71a9e6604 chore(prompts.ts): update INIT_MAIN_PROMPT content to provide clearer instructions and improve readability
The content of the INIT_MAIN_PROMPT has been updated to provide clearer instructions on how to create clean and comprehensive commit messages in the conventional commit convention. The changes include clarifying the purpose of the mission, specifying the use of 'git diff --staged' command, and providing guidelines on prefaces, descriptions, tense, and line length. The update also includes using the language variable for the commit message. This improves the readability and usability of the prompt for users.
2023-09-03 15:38:37 +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
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
6 changed files with 24 additions and 10 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

@@ -326,4 +326,8 @@ 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 ChatGPT (3.5-turbo-16k) official model, which is a lot cheaper than gpt-4.

View File

@@ -22312,7 +22312,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

@@ -1,6 +1,6 @@
{
"name": "opencommit",
"version": "2.4.2",
"version": "3.0.0",
"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 run build:push && npm version patch && git push --tags && npm publish --tag latest",
"lint": "eslint src --ext ts && tsc --noEmit",
"format": "prettier --write src"
},

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 = {