Giter Site home page Giter Site logo

appleboy / codegpt Goto Github PK

View Code? Open in Web Editor NEW
1.1K 15.0 90.0 983 KB

A CLI written in Go language that writes git commit messages or do a code review brief for you using ChatGPT AI (gpt-4, gpt-3.5-turbo model) and automatically installs a git prepare-commit-msg hook.

License: MIT License

Go 92.90% Makefile 2.55% Shell 0.12% JavaScript 0.28% Dockerfile 0.91% Smarty 0.17% D2 3.07%
chatgpt chatgpt-api golang openai openai-api git git-hook

codegpt's Introduction

CodeGPT

Lint and Testing codecov Go Report Card

cover

A CLI written in Go language that writes git commit messages or do a code review brief for you using ChatGPT AI (gpt-3.5-turbo, gpt-4 model) and automatically installs a git prepare-commit-msg hook.

flow

Feature

  • Support Azure OpenAI Service or OpenAI API.
  • Support conventional commits specification.
  • Support Git prepare-commit-msg Hook, see the Git Hooks documentation.
  • Support customize generate diffs with n lines of context, the default is three.
  • Support for excluding files from the git diff command.
  • Support commit message translation into another language (support en, zh-tw or zh-cn).
  • Support socks proxy or custom network HTTP proxy.
  • Support model lists like gpt-4, gpt-3.5-turbo ...etc.
  • Support do a brief code review.

code review

Installation

Install from Homebrew on MacOS

brew tap appleboy/tap
brew install codegpt

Install from Chocolatey on Windows

choco install codegpt

The pre-compiled binaries can be downloaded from release page.Change the binary permissions to 755 and copy the binary to the system bin directory. Use the codegpt command as shown below.

$ codegpt version
version: v0.4.3 commit: xxxxxxx

Install from source code:

go install github.com/appleboy/CodeGPT/cmd/codegpt@latest

Setup

Please first create your OpenAI API Key. The OpenAI Platform allows you to generate a new API Key.

register

An environment variable is a variable that is set on your operating system, rather than within your application. It consists of a name and value.We recommend that you set the name of the variable to OPENAI_API_KEY.

See the Best Practices for API Key Safety.

export OPENAI_API_KEY=sk-xxxxxxx

or store your API key in custom config file.

codegpt config set openai.api_key sk-xxxxxxx

This will create a .codegpt.yaml file in your home directory ($HOME/.config/codegpt/.codegpt.yaml). The following options are available.

  • openai.base_url: replace the default base URL (https://api.openai.com/v1).
  • openai.api_key: generate API key from openai platform page.
  • openai.org_id: Identifier for this organization sometimes used in API requests. see organization settings. only for openai service.
  • openai.model: default model is gpt-3.5-turbo, you can change to gpt-4 or other available model list.
  • openai.proxy: http/https client proxy.
  • openai.socks: socks client proxy.
  • openai.timeout: default http timeout is 10s (ten seconds).
  • openai.max_tokens: default max tokens is 300. see reference max_tokens.
  • openai.temperature: default temperature is 1. see reference temperature.
  • git.diff_unified: generate diffs with <n> lines of context, default is 3.
  • git.exclude_list: exclude file from git diff command.
  • openai.provider: default service provider is openai, you can change to azure.
  • openai.model_name: model deployment name (for azure).
  • output.lang: default language is en and available languages zh-tw, zh-cn, ja.
  • openai.top_p: default top_p is 1.0. see reference top_p.
  • openai.frequency_penalty: default frequency_penalty is 0.0. see reference frequency_penalty.
  • openai.presence_penalty: default presence_penalty is 0.0. see reference presence_penalty.

How to change to Azure OpenAI Service

Please get the API key, Endpoint and Model deployments list from Azure Resource Management Portal on left menu.

azure01

azure02

Update your config file.

codegpt config set openai.provider azure
codegpt config set openai.base_url https://xxxxxxxxx.openai.azure.com/
codegpt config set openai.api_key xxxxxxxxxxxxxxxx
codegpt config set openai.model_name xxxxx-gpt-35-turbo

How to change to Groq API Service

Please get the API key from Groq API Service, please vist here. Update the base_url and api_key in your config file.

codegpt config set openai.provider openai
codegpt config set openai.base_url https://api.groq.com/openai/v1
codegpt config set openai.api_key gsk_xxxxxxxxxxxxxx
codegpt config set openai.model llama3-8b-8192

Support the following models:

  1. llama3-8b-8192 (Meta) recommended
  2. llama3-70b-8192 (Meta)
  3. mixtral-8x7b-32768 (Mistral)
  4. gemma-7b-it (Google)

Usage

There are two methods for generating a commit message using the codegpt command. The first is CLI mode, and the second is Git Hook.

CLI mode

You can call codegpt directly to generate a commit message for your staged changes:

git add <files...>
codegpt commit --preview

The commit message is shown below.

Summarize the commit message use gpt-3.5-turbo model
We are trying to summarize a git diff
We are trying to summarize a title for pull request
================Commit Summary====================

feat: Add preview flag and remove disableCommit flag in commit command and template file.

- Add a `preview` flag to the `commit` command
- Remove the `disbaleCommit` flag from the `prepare-commit-msg` template file

==================================================
Write the commit message to .git/COMMIT_EDITMSG file

or translate all git commit messages into a different language (Traditional Chinese, Simplified Chinese or Japanese)

codegpt commit --lang zh-tw --preview

Consider the following outcome:

Summarize the commit message use gpt-3.5-turbo model
We are trying to summarize a git diff
We are trying to summarize a title for pull request
We are trying to translate a git commit message to Traditional Chinese language
================Commit Summary====================

功能:重構 codegpt commit 命令標記

- 將「codegpt commit」命令新增「預覽」標記
- 從「codegpt commit」命令中移除「--disableCommit」標記

==================================================
Write the commit message to .git/COMMIT_EDITMSG file

You can replace the tip of the current branch by creating a new commit. just use --amend flag

codegpt commit --amend

Change commit message template

Default commit message template as following:

{{ .summarize_prefix }}: {{ .summarize_title }}

{{ .summarize_message }}

change format with template string using --template_string parameter:

codegpt commit --preview --template_string \
  "[{{ .summarize_prefix }}]: {{ .summarize_title }}"

change format with template file using --template_file parameter:

codegpt commit --preview --template_file your_file_path

Add custom variable to git commit message template:

{{ .summarize_prefix }}: {{ .summarize_title }}

{{ .summarize_message }}

{{ if .JIRA_URL }}{{ .JIRA_URL }}{{ end }}

Add custom variable to git commit message template using --template_vars parameter:

codegpt commit --preview --template_file your_file_path --template_vars \
  JIRA_URL=https://jira.example.com/ABC-123

Load custom variable from file using --template_vars_file parameter:

codegpt commit --preview --template_file your_file_path --template_vars_file your_file_path

See the template_vars_file format as following:

JIRA_URL=https://jira.example.com/ABC-123

Git hook

You can also use the prepare-commit-msg hook to integrate codegpt with Git. This allows you to use Git normally and edit the commit message before committing.

Install

You want to install the hook in the Git repository:

codegpt hook install

Uninstall

You want to remove the hook from the Git repository:

codegpt hook uninstall

Stage your files and commit after installation:

git add <files...>
git commit

codegpt will generate the commit message for you and pass it back to Git. Git will open it with the configured editor for you to review/edit it. Then, to commit, save and close the editor!

$ git commit
Summarize the commit message use gpt-3.5-turbo model
We are trying to summarize a git diff
We are trying to summarize a title for pull request
================Commit Summary====================

Improve user experience and documentation for OpenAI tools

- Add download links for pre-compiled binaries
- Include instructions for setting up OpenAI API key
- Add a CLI mode for generating commit messages
- Provide references for OpenAI Chat completions and ChatGPT/Whisper APIs

==================================================
Write the commit message to .git/COMMIT_EDITMSG file
[main 6a9e879] Improve user experience and documentation for OpenAI tools
 1 file changed, 56 insertions(+)

Code Review

You can use codegpt to generate a code review message for your staged changes:

codegpt review

or translate all code review messages into a different language (Traditional Chinese, Simplified Chinese or Japanese)

codegpt review --lang zh-tw

See the following result:

Code review your changes using gpt-3.5-turbo model
We are trying to review code changes
PromptTokens: 1021, CompletionTokens: 200, TotalTokens: 1221
We are trying to translate core review to Traditional Chinese language
PromptTokens: 287, CompletionTokens: 199, TotalTokens: 486
================Review Summary====================

總體而言,此程式碼修補似乎在增加 Review 指令的功能,允許指定輸出語言並在必要時進行翻譯。以下是需要考慮的潛在問題:

- 輸出語言沒有進行輸入驗證。如果指定了無效的語言代碼,程式可能會崩潰或產生意外結果。
- 此使用的翻譯 API 未指定,因此不清楚是否存在任何安全漏洞。
- 無法處理翻譯 API 調用的錯誤。如果翻譯服

==================================================

another php example code:

<?php
if( isset( $_POST[ 'Submit' ]  ) ) {
  // Get input
  $target = $_REQUEST[ 'ip' ];
  // Determine OS and execute the ping command.
  if( stristr( php_uname( 's' ), 'Windows NT' ) ) {
    // Windows
    $cmd = shell_exec( 'ping  ' . $target );
  }
  else {
    // *nix
    $cmd = shell_exec( 'ping  -c 4 ' . $target );
  }
  // Feedback for the end user
  $html .= "<pre>{$cmd}</pre>";
}
?>

code review result:

================Review Summary====================

Code review:

1. Security: The code is vulnerable to command injection attacks as the user input is directly used in the shell_exec() function. An attacker can potentially execute malicious commands on the server by injecting them into the 'ip' parameter.
2. Error handling: There is no error handling in the code. If the ping command fails, the error message is not displayed to the user.
3. Input validation: There is no input validation for the 'ip' parameter. It should be validated to ensure that it is a valid IP address or domain name.
4. Cross-platform issues: The code assumes that the server is either running Windows or *nix operating systems. It may not work correctly on other platforms.

Suggestions for improvement:

1. Use escapeshellarg() function to sanitize the user input before passing it to shell_exec() function to prevent command injection.
2. Implement error handling to display error messages to the user if the ping command fails.
3. Use a regular expression to validate the 'ip' parameter to ensure that it is a valid IP address or domain name.
4. Use a more robust method to determine the operating system, such as the PHP_OS constant, which can detect a wider range of operating systems.

==================================================

Star History

Star History Chart

Reference

codegpt's People

Contributors

adlternative avatar appleboy avatar bresilla avatar charon11 avatar davidleitw avatar dependabot[bot] avatar doggy8088 avatar hero19931012 avatar i-pva avatar louis70109 avatar maarten1c96 avatar p50815 avatar peterxcli avatar rancejen avatar ryan961 avatar stavhaygn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codegpt's Issues

The model: `gpt-4` does not exist

This is my codegpt.yaml:

openai:
    api_key: sk-foobar123examplekey
    base_url: ""
    model: 'gpt-4'
    org_id: ""
    proxy: ""
    socks: ""
    timeout: 30s

The error message 'Error: error, status code: 404, message: The model: gpt-4 does not exist' pop up after I input codegpt commit --preview.
Is there any errors on my config?
( I'm using CHATGPT-4 )

Bug: cannot open .git/COMMIT_EDITMSG in the git worktree

When I try to use CodeGPT in the git worktree:

Summarize the commit message use gpt-3.5-turbo model
We are trying to summarize a git diff
PromptTokens: 522, CompletionTokens: 17, TotalTokens: 539
We are trying to summarize a title for pull request
PromptTokens: 189, CompletionTokens: 6, TotalTokens: 195
We are trying to get conventional commit prefix
PromptTokens: 284, CompletionTokens: 1, TotalTokens: 285
================Commit Summary====================

feat: add new file with content

- Add a new file named `t5` with the content `aaaaaaa`

==================================================
Write the commit message to .git/COMMIT_EDITMSG file
Error: open .git/COMMIT_EDITMSG: not a directory

That's because git worktree‘s ".git" is a file which content is the
address of real ".git", maybe we should consider about compatibility here.

Exceeding ChatGPT API Context Length

When I add too many files using git, the following error message appears:

Error: error, status code: 400, message: This model's maximum context length is 4097 tokens. However, you requested 4355 tokens (4055 in the messages, 300 in the completion). Please reduce the length of the messages or completion.

Summary format

有辦法修改Summary的格式嗎?
原本是 xxx: xxxxxxx, 改成[xxx] xxxxxx 之類的

GPT-4 is not working

Using gpt-4 as a model is not working.

~/Documents/reports fix/SOBI-5969-main *6 ❯ codegpt commit --amend                                                                                                                                      3s
Summarize the commit message use gpt-4 model
We are trying to summarize a git diff
Error: error, status code: 404, message: This is a chat model and not supported in the v1/completions endpoint. Did you mean to use v1/chat/completions?

Config file:

~/.config ❯ cat codegpt/.codegpt.yaml 

       │ File: codegpt/.codegpt.yaml
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ git:
   2   │     diff_unified: 3
   3   │     exclude_list: []
   4   │     template_file: ""
   5   │     template_string: ""
   6   │ openai:
   7   │     api_key: sk-xxxxx
   8   │     base_url: ""
   9   │     model: gpt-4
  10   │     org_id: ""
  11   │     proxy: ""
  12   │     socks: ""
  13   │     timeout: 20s
  14   │ output:
  15   │     file: .git/COMMIT_EDITMSG
  16   │     lang: en

Please add support in the switch statement:

case openai.GPT3Dot5Turbo, openai.GPT3Dot5Turbo0301:

I only see support for gpt-3 and gpt-3-turbo

name duplicates

There are many executables named codegpt for all possible ends via ChatGPT.
How about the more specific CommitGPT (surely also taken, but likely less often).

Chocolatey package: CodeGPT

Chocolatey is software management automation for Windows that wraps installers, executables, zips, and scripts into compiled packages.

I made a Chocolatey package for this project: https://community.chocolatey.org/packages/codegpt

The package hasn't been approved by a moderator yet. So it might wait for a couple days to release. After it been released, I will check for new version of this repo daily by CI/CD and release to the Chocolatey repository automatically.

Error Message: Post "https://api.openai.com/v1/chat/completions": net/http: request canceled (Client.Timeout exceeded while awaiting headers)

What happened

When I use codegpt review or codegpt commit --preview command
CLI says Error: Post "https://api.openai.com/v1/chat/completions": net/http: request canceled (Client.Timeout exceeded while awaiting headers)

It has been like this for many days. (maybe 1 ~ 2 weeks)
These tasks was successfully executed in the past.

Log

$ codegpt review 

Code review your changes using gpt-3.5-turbo model
We are trying to review code changes
Error: Post "https://api.openai.com/v1/chat/completions": net/http: request canceled (Client.Timeout exceeded while awaiting headers)
$ codegpt commit --preview

Summarize the commit message use gpt-3.5-turbo model
We are trying to summarize a git diff
PromptTokens: 2361, CompletionTokens: 100, TotalTokens: 2461
We are trying to summarize a title for pull request
Error: Post "https://api.openai.com/v1/chat/completions": net/http: request canceled (Client.Timeout exceeded while awaiting headers)

Config list

$ codegpt config list           
                                                       
Key                       Value             
git.diff_unified          3                 
git.exclude_list                            
git.template_file                           
git.template_string                         
openai.api_key            ****************  
openai.api_version                          
openai.base_url                             
openai.frequency_penalty  <nil>             
openai.headers                              
openai.max_tokens         300               
openai.model              gpt-3.5-turbo     
openai.model_name                           
openai.org_id                               
openai.presence_penalty   <nil>             
openai.provider           openai            
openai.proxy                                
openai.skip_verify        false             
openai.socks                                
openai.temperature        0.7               
openai.timeout            10s               
openai.top_p              <nil>             
output.lang               en       

codegpt config set does not update .codegpt.yaml

OS: macOS Ventura 13/6
CodeGPT Version: 0.6.1 commit: d24af1a (using Homebrew)

codegpt config set does not update .codegpt.yaml.

$ cat ~/.config/codegpt/.codegpt.yaml
output:
    file: ""

$ codegpt config set openai.api_key sk-xxxxxxxxx
you can see the config file: /Users/xxxxx/.config/codegpt/.codegpt.yaml

$ cat ~/.config/codegpt/.codegpt.yaml
output:
    file: ""

Editting .codegpt.yaml directly, codegpt config list shows its value correctly. However, codegpt config set still does not work.

$ cat ~/.config/codegpt/.codegpt.yaml
output:
  file: ""
  lang: ja

$ codegpt config list
Key                       Value
git.diff_unified          <nil>
git.exclude_list          <nil>
git.template_file         <nil>
git.template_string       <nil>
openai.api_key            ****************
openai.api_version        <nil>
openai.base_url           <nil>
openai.frequency_penalty  <nil>
openai.headers            <nil>
openai.max_tokens         <nil>
openai.model              <nil>
openai.model_name         <nil>
openai.org_id             <nil>
openai.presence_penalty   <nil>
openai.provider           <nil>
openai.proxy              <nil>
openai.skip_verify        <nil>
openai.socks              <nil>
openai.temperature        <nil>
openai.timeout            <nil>
openai.top_p              <nil>
output.lang               ja

$ codegpt config set output.lang en
you can see the config file: /Users/xxxxx/.config/codegpt/.codegpt.yaml

$ codegpt config list
Key                       Value
git.diff_unified          <nil>
git.exclude_list          <nil>
git.template_file         <nil>
git.template_string       <nil>
openai.api_key            ****************
openai.api_version        <nil>
openai.base_url           <nil>
openai.frequency_penalty  <nil>
openai.headers            <nil>
openai.max_tokens         <nil>
openai.model              <nil>
openai.model_name         <nil>
openai.org_id             <nil>
openai.presence_penalty   <nil>
openai.provider           <nil>
openai.proxy              <nil>
openai.skip_verify        <nil>
openai.socks              <nil>
openai.temperature        <nil>
openai.timeout            <nil>
openai.top_p              <nil>
output.lang               ja

$ cat ~/.config/codegpt/.codegpt.yaml
output:
    file: ""
    lang: ja

unexpected character string

Hi appleboy,

I hope this message finds you well. I wanted to bring to your attention a small issue I noticed in your latest commit with the message:

chore: add support for @nuxt-themes/docus theme

Upon reviewing the commit summary, I noticed that there is an unexpected character string

Summarize the commit message use gpt-3.5-turbo model
We are trying to summarize a git diff
PromptTokens: 651, CompletionTokens: 14, TotalTokens: 665
We are trying to summarize a title for pull request
PromptTokens: 192, CompletionTokens: 12, TotalTokens: 204
We are trying to get conventional commit prefix
PromptTokens: 287, CompletionTokens: 2, TotalTokens: 289
================Commit Summary====================

chore: add support for @nuxt-themes/docus theme

  • Add "@nuxt-themes/docus" dependency to package.json

==================================================

that appears in the message. This may be due to a parsing error with the tool you used to generate the commit message.

I believe that this may be resolved by ensuring that conventional commit prefixes are properly formatted in your future commits. This will help maintain consistency and clarity in your commit history.

Thank you for your attention to this matter. Please let me know if you have any questions or concerns.

Best regards

How to deal with large git diff that over model's maximum context length limit?

When git diff returned too much changes. The CodeGPT will show this:

We are trying to summarize a git diff
Error: error, status code: 400, message: This model's maximum context length is 8192 tokens. However, your messages resulted in 28846 tokens. Please reduce the length of the messages.

Is it possible trimming the git diff result so that CodeGPT can still summarize part of the changes?

Cant upgrade 0.4.3

i am use homebrow install codegpt
'''
brew tap appleboy/tap
brew install codegpt
'''
then it show me this error messanger

Error: codegpt: SHA256 mismatch
Expected: a6172371b0b9ea4c090556b0fcdae6516c3a108a728f6bbd52afeb0b5a8e8e55
Actual: 4b518efaada8f2dd4611be9c6b4d367377625ad19185ddf4d2384af4fad9f2fd
File: /Users/user/Library/Caches/Homebrew/downloads/3137512ca8a4413716207f21c8ab610f1ee72059e681fa42612f3f5ef65b761d--CodeGPT-0.4.3-darwin-arm64.xz

API Key for chat window not working

Hello,

If I enter my API Key the code generation from comments is working but everytime I try the chat window it shows that I have to enter an API key.

I tried:

  • Restart VSCode
  • removed & added api key
  • deactivated & activated the extension

image

Model maximum lenght

Hello,

I get this error quite often when I try to commit "a lot" of code.
Is there a workaround?

CleanShot 2023-03-26 at 23 27 31

Regards,
Maxence

zh-tw commit summary show ###

If the language is set to zh-tw in the .codegpt.yaml file for the commit's Summary, it will be displayed with three ### symbols on the first line, which might impact the overall readability of the commit list. Could you please advise on how to configure it in a way that prevents ### from appearing as the header on the first line?

update script

Here's a script to update to the latest version in the absence of a packet manager:

#!/usr/bin/env sh

# debug output and exit on error or use of undeclared variable or pipe error:
set -o xtrace -o errtrace -o errexit -o nounset -o pipefail

url="https://github.com/appleboy/CodeGPT/releases"
latest_tag="$(curl --location --head "${url}/latest" | grep -i location: | sed 's/^.*\/tag\/\([^\/]*\)\r$/\1/')"
latest_tag="${latest_tag:1}"
filename="codegpt-${latest_tag}-linux-amd64"
uri_to_download="${url}/download/v${latest_tag}/${filename}"

{
   cd "$(mktemp --directory "${TMPDIR:-/tmp}/git-absorb-update.XXXXXXXXXX")"
   curl --fail --show-error --remote-name --location "$uri_to_download"
   cp -u "$filename" "$HOME/bin/codegpt"

   tmpdir="$PWD"
   trap 'rm -rf "$tmpdir"' EXIT
}

if [ ! -x "$HOME/bin/codegpt" ]; then
   echo '"codegpt" was not successfully installed!' >&2
   # DISPLAY=:0 notify-send --urgency=critical "Failed updating peco!
   # Run $0 to check."
   exit 2
fi

The model: `gpt-4` does not exist

Love this tool so much but for some reason I can't get gpt-4 model to work at all. gpt-3.5-turbo works just fine. Any help would be greatly appreciated.

codegpt version
version: 0.1.3 commit: 51a0f34

codegpt commit
Summarize the commit message use gpt-4 model
We are trying to summarize a git diff
Error: error, status code: 404, message: The model: `gpt-4` does not exist
git:
    diff_unified: 3
    exclude_list: []
    template_file: ""
    template_string: ""
openai:
    api_key: sk-########
    base_url: ""
    model: gpt-4
    org_id: org-#######
    proxy: ""
    socks: ""
    timeout: 15s
output:
    file: .git/COMMIT_EDITMSG
    lang: en

Lowercase the first character of first word of the commit message and remove last period

Take "feat: Add preview flag and remove disableCommit flag in commit command and template file."

To pass commitlint, The first character of Add needs to be lowercase. And last period . needs to be removed.

So it would be feat: add preview flag and remove disableCommit flag in commit command and template file.

echo 'feat: Add preview flag and remove disableCommit flag in commit command and template file.' | commitlint

⧗   input: feat: Add preview flag and remove disableCommit flag in commit command and template file.
✖   subject must not be sentence-case, start-case, pascal-case, upper-case [subject-case]
✖   subject may not end with full stop [subject-full-stop]

✖   found 2 problems, 0 warnings
ⓘ   Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlintecho 'feat: add preview flag and remove disableCommit flag in commit command and template file' | commitlint

image

Make `codegpt commit` command trigger the git pre-commit hook

Hi,

I hope the codegpt commit can trigger the git pre-commit hook, before generate the commit message.

I know I can install the prepare-commit-hook to the project. But I don't want to use codegpt for every commit.

So I prefer to use codegpt commit when it's needed.

感謝!

Prompt issue: The commit message contains "請注意保留原有格式。"

I'm trying to get a commit message and translate it to zh-tw.

codegpt commit --lang zh-tw --preview

The result:

工作:重構項目配置以增強安全性

- 在 csproj 文件中添加使用者秘密 ID
- 從 launchSettings.json 中刪除 http applicationUrl

請注意保留原有格式。

I think the 請注意保留原有格式。 is not necessary.

Also, the following footnote are shown from time to time:

  • 請注意保持原有格式,並確保翻譯符合程式設計師的共識。
  • 請注意保持格式不變。

I already tried to tune temperature to 0:

codegpt config set openai.temperature 0

It still happens.

Suggestion

Provide a way to configure FrequencyPenalty, NucleusSamplingFactor and PresencePenalty to 0.

Is it possible to support "codegpt commit --amend"?

Currently, I am facing a dilemma where if I am unsatisfied with the commit message generated by codegpt, I have to use "git reset --soft HEAD~" and then generate a new commit message using codegpt. It would be great if I could use "codegpt commit --amend" to achieve this in one step.

Specify a type of summary_prefix

當我在修改 bug 時,例如下面這個例子,我忘記對 list 進行 sum,經過修正後,commit message 應該要是 fix,但 GPT 還是總結成 feat 或 refactor。

雖然我可以用 codegpt commit --amend 修改,但希望可以在 codegpt commit 時指定用哪種 summary_prefix,讓 GPT 可以針對該 prefix 生成更準確的 message。

image

Git commit title without prefix

Some tests of mine produced this simple commit msg output:

================Commit Summary====================

Add Swift Package Manager installation instructions and test file

  • Add instructions for installing with Swift Package Manager to README.md
  • Create a new file test/mycode.go

==================================================

But in this repo you are got prefixes like docs(readme): ...
How to achieve this, or do you still change this prefix manually?

Also I would like to replace readme in this example with a Ticket maybe. Any idea how it could be accomplished?

EDIT: Oh. Do you got 50 chars instead of 72 in your prompt because you added the prefix in your git commit hook?

File window closes when running VScode

When I start VScode, I see the file window open for a few seconds, after which it closes when it shouldn't. I tried disabling this extension and the window didn't close anymore. This is somehow affected by the Code GPT extension.

Support do a brief code review

like

================Review Summary====================

Overall, the code patch looks good. Here are some suggestions for improvement:

1. In `cmd/commit.go`, the code block that checks for the existence of Git and sets various configuration options has been moved to a separate function `check()` in `cmd/helper.go`. This is a good refactoring, as it separates concerns and makes the code easier to read and maintain.

2. In `cmd/cmd.go`, a new command `reviewCmd` has been added. However, there is no implementation of this command in the patch. It is unclear what this command is intended to do. If it is not yet implemented, it should be removed from `cmd/cmd.go` until it is ready.

3. In `cmd/commit.go`, the code that sets the `openai.proxy` and `openai.socks` options has been removed. It is unclear why this was done, as these options were previously supported. If these options are no longer needed, then the code patch is

image

[Suggestion] Provide "codegpt config list" to list all config settings

I'd like to suggest you to add a list subcommand to list existing config settings like this:

codegpt config list

It will be better to mask the sensitive data such as openai.api_key on the output of the codegpt config list.

By the way, the codegpt config only have a set subcommand, but the help message didn't show that.

Inconsistencies in preview of Simplified Chinese and Traditional Chinese commit messages

Hello,

I've noticed that there are some inconsistencies in the preview of Simplified Chinese and Traditional Chinese commit messages on Github. Specifically, when I use Simplified Chinese characters in my commit message, the preview looks different from when I use Traditional Chinese characters.

I believe this may be an issue for other users who work with Chinese characters as well.

截圖 2023-04-14 下午2 53 27
截圖 2023-04-14 下午2 53 48

I noticed this inconsistency when I included the phrase "GIT提交信息" in my commit message.

Could you please take a look at this issue and see if there's anything that can be done to make the preview consistent for both Simplified and Traditional Chinese characters? It would be great if the preview could accurately reflect how the commit message will appear once it's posted.

Thank you for your attention to this matter.

❓Templating capabilities

Hi @appleboy 👋🏻

Thanks for the tool,I 😍 it!

I am wondering what the templating capabilities are.

Would it be possible to parse stuff or to have "parameters" that would be processed by the template?
My use case is that in my company, we need to pass the Jira issue ID as part of the commit subject for later automation.

Thanks a lot for your time and considering my question 🙏🏻

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.