Comments (3)
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
-
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.
-
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.
-
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
-
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.
-
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.
-
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
- Start by adding the -m flag definition in cli.ts.
- Implement logic to check for the -m flag and process the user-provided commit message.
- Modify the commit process to enhance the user-provided message using the LLM.
- 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.
Stale issue message
from opencommit.
great idea, sometimes it cant understand why the change was made, this can solve it
from opencommit.
Related Issues (20)
- Proposal for Expanding Maintenance Team HOT 17
- [Feature]: minimalistic output HOT 3
- Is this project alive? HOT 2
- [Bug]: Ollama documentation is incorrect
- [Bug]: ollama output erroneously considers sample data HOT 2
- [Feature]: Make ollama hostname configurable HOT 1
- [Feature]: Use different file type instead .env for local configuration HOT 1
- [Feature]: Perplexity Support HOT 5
- [Feature]: Add Gemini Support HOT 1
- [Bug]: Unable to use oco with ollama running mistral HOT 5
- [Bug]: Local Ollama with OpenCommit not working when internet is blocked HOT 5
- [Feature]: Claude 3 Support HOT 3
- [Bug]: Unsupported config key `OCO_MODEL` error when using `oco` command HOT 13
- [Bug]: Setting `OCO_ONE_LINE_COMMIT=true` generates a multi-line message HOT 1
- [Bug]: Request failed with status code 404 HOT 1
- [Feature]: add oco at Docker hub HOT 1
- [Bug]: ✖ Unsupported config key OCO_OPENAI_API_KEY: Must be 51 characters long
- [Bug]: Unsupported config key OCO_OPENAI_API_KEY: Must be 51 characters long HOT 3
- [Bug]: Commit Types Not Included in Generated Commit Messages HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opencommit.