Coder Social home page Coder Social logo

bakaburg1 / aigitcraft Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 78 KB

AiGitCraft is an R package designed to enhance Git operations by leveraging Large Language Models (LLMs) to automatically generate meaningful commit messages, pull request descriptions, and other related documentation.

License: Other

R 100.00%

aigitcraft's Introduction

AiGitCraft

AiGitCraft is an R package designed to enhance Git operations by leveraging Large Language Models (LLMs) to automatically generate meaningful commit messages, pull request descriptions, and other related documentation. It simplifies the process of managing and documenting code changes, making it easier for developers to maintain a clear and informative history of their project’s evolution.

Installation

You can install the development version of AiGitCraft from GitHub with:

# install.packages("pkgload")
remotes::install_github("bakaburg1/AiGitCraft")

Features

  • Automatic Commit Messages: Generate commit messages that accurately reflect the changes made, using context from the code and project documentation.
  • Pull Request Descriptions: Generate detailed and structured pull request descriptions by analyzing the differences between branches.
  • Commit Differences: Retrieve and display the differences between commits in a human-readable format, aiding code reviews and documentation.
  • Uncommitted Changes Summary: Describe the changes from the last committed state in a repository, helping developers to keep track of modifications.
  • README Generation: Automatically write or update README files for repositories based on the content of the DESCRIPTION file and the code files.
  • LLM Integration: Utilize various LLM providers such as OpenAI, Azure, or a local LLM server to process natural language tasks related to Git operations.
  • Bonus! Create a twitter thread: Generate a twitter thread to present the repo based on the README.md file.

Usage

Generate pull request descriptions

To automatically create a pull request description:

library(AiGitCraft)

# Set the repository path and branches
repo_path <- "path/to/your/repo"
# or use getwd() or use getOption("aigitcraft_repo")

source_branch <- "main"
target_branch <- "feature-branch"

# Generate the pull request description
pr_description <- write_pull_request_description(
  repo_path, source_branch, target_branch,
  use_description = TRUE, # Optional, analyze the DESCRIPTION file to
                            # better understand the changes
  use_readme = TRUE, # Optional, analyze the README file to better understand
                       # the changes
  )
  
cat(pr_description)

Get description of uncommitted changes

To get the description of uncommitted changes in a repository:

# Get the uncommitted changes summary
uncommitted_changes_summary <- get_uncommitted_changes_summary(
    repo = repo_path,
    screened_folders = "R" # Optional, specify the folders to screen for changes
    staged = FALSE, # Optional, get the staged changes only
    use_description = TRUE, # Optional, analyze the DESCRIPTION file to
                            # better understand the changes
    use_readme = TRUE, # Optional, analyze the README file to better understand
                       # the changes
    cite_changes = TRUE, # Optional, cite the changes positions in the summary.
                         # doesn't work always
    suggest_commits = TRUE, # Optional, suggest commit messages for the changes

cat(uncommitted_changes_summary)

Generate commit messages

To generate a commit message for staged changes:

# Generate the commit message
commit_message <- write_commit_message(
  repo_path,
  use_conventional_commit = TRUE, # Optional, use the Conventional Commits
                                   # specification
  use_description = TRUE, # Optional, analyze the DESCRIPTION file to
                          # better understand the changes
  use_readme = TRUE, # Optional, analyze the README file to better understand
                     # the changes
  use_files = c(
  "this_file.R", "that_file.R") # Optional, specify a vector of files to analyze
                                # to help the LLM to understand the changes
  )

Generate README files

To automatically write or update README files for repositories:

# Generate the README file

write_repo_readme(
  repo_path,
  use_description = TRUE, # Optional, analyze the DESCRIPTION file to
                          # better understand the changes
  use_readme = TRUE, # Optional, analyze the README file to better understand
                     # the changes
  file_exts = c("R", "py") # Optional, include only the specified file
                            # extensions in the analysis
  code_folders = c("R", "test") # Optional, include only the specified
                                   # folders in the analysis, otherwise the
                                   # whole repository is analyzed
  recursive = TRUE # Optional, include the subfolders in the analysis
  )

Configuration

Before using AiGitCraft, you need to set up the necessary API keys and model identifiers for the language model providers you intend to use. This can be done by setting the appropriate options in R:

# OpenAI configuration example

options(
  
  # API providers
  aigitcraft_default_llm_provider = "openai",
  
  # OpenAI GPT API
  aigitcraft_openai_api_key_gpt = "your-openai-api-key",
)

# Azure configuration example

options(

  # API providers
  aigitcraft_default_llm_provider = "azure",

  # Azure GPT API
  aigitcraft_azure_resource_gpt = "your-azure-resource",
  aigitcraft_azure_deployment_gpt = "your-azure-deployment",
  aigitcraft_azure_api_key_gpt = "your-azure-api-key",

  # Azure common parameters
  aigitcraft_azure_api_version = "" # See Azure API documentation
)

# Local LLM server configuration example

options(

  # API providers
  aigitcraft_default_llm_provider = "local",

  # Local LLM server
  aigitcraft_local_llm_endpoint = "http://localhost:1234/v1/chat/completions"
)

License

AiGitCraft is licensed under the MIT License. See the LICENSE file for more details.


Please note that AiGitCraft is still under development and features may change. Always refer to the package’s documentation for the most up-to-date information.

aigitcraft's People

Contributors

bakaburg1 avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

jfontestad

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.