Code Monkey home page Code Monkey logo

Comments (3)

sebastienfi avatar sebastienfi commented on June 15, 2024 2

Great feature. @JumpLink would you like to propose a PR? I've outlined a few things to consider and implementation steps to get you started.

To implement the new -m flag feature in OpenCommit, which allows users to specify their own commit message for enhancement by an LLM, you'll need to follow several steps. This feature involves integrating a new command-line flag, processing the user's input, and leveraging the LLM to enhance the commit message. Here's a guide to help you get started:

Understanding the Current Architecture

  1. Entry Point (cli.ts): The main entry point of OpenCommit is the cli.ts file, where the CLI is configured and initialized. This file processes command-line arguments and dispatches commands based on user input.

  2. Commit Command (commit.ts): The commit.ts module is crucial for handling commit-related operations. It includes logic for generating commit messages based on git diffs, staging files, and executing the git commit command.

  3. LLM Integration (ollama.ts and openAi.ts): The ollama.ts and openAi.ts modules under the engine directory are responsible for interfacing with the LLM to generate or enhance commit messages. Depending on the configuration, OpenCommit uses either a local model (Ollama) or OpenAI's API.

Integrating the -m Flag

  1. Modify CLI Configuration (cli.ts): Add a new flag definition for -m in the cli function call. This involves updating the flags object to accept a string value for the -m flag.

  2. Process User Input: In the main async function within cli.ts, add logic to check if the -m flag is present in the flags object. If so, extract the custom commit message provided by the user.

  3. Enhance Commit Message: Use the extracted commit message as input to the LLM for enhancement. This might involve modifying the commit function in commit.ts or creating a new function specifically for handling and enhancing user-provided commit messages. Ensure that the LLM's output is used as the final commit message.

Leveraging Existing Functionality

  • LLM Invocation: The logic for invoking the LLM and processing its output is already implemented in the ollama.ts and openAi.ts modules. You can reuse this functionality by ensuring that the user-provided commit message is passed correctly to the LLM.

  • Commit Message Processing: The existing commit process, including staging files and executing the git commit command, can be reused. After enhancing the user-provided commit message, follow the same flow to complete the commit operation.

Testing and Compatibility

  • Unit Tests: Add unit tests for the new -m flag processing logic. Ensure that the user-provided commit message is correctly passed to the LLM and that the enhanced message is used for the commit.

  • Integration Tests: Perform integration tests to verify that the new feature works seamlessly with existing functionalities, such as staging changes and generating commit messages from diffs when the -m flag is not used.

  • Manual Testing: Manually test the new feature in various scenarios, including providing valid and invalid commit messages, to ensure that the behavior is as expected.

Initial Steps

  1. Start by adding the -m flag definition in cli.ts.
  2. Implement logic to check for the -m flag and process the user-provided commit message.
  3. Modify the commit process to enhance the user-provided message using the LLM.
  4. Test thoroughly to ensure compatibility and correctness.

You should be able to successfully implement the new -m flag feature in OpenCommit. We'll provide you with assistance once you (or someone else) creates a PR.

from opencommit.

github-actions avatar github-actions commented on June 15, 2024

Stale issue message

from opencommit.

di-sukharev avatar di-sukharev commented on June 15, 2024

great idea, sometimes it cant understand why the change was made, this can solve it

from opencommit.

Related Issues (20)

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.