Comments (3)
I also see this as a useful yet dangerous option, but you, "use at your own risks".
@marco76tv would you like to propose a PR? Here are some guidelines to get you started. We'll provide you with assistance once you start a PR.
To implement the --yes or -y option for the aic command line utility, allowing users to bypass interactive selection and automatically accept the first AI-generated commit message, you'll need to modify several parts of the codebase. Here's a step-by-step guide based on the provided context:
1. Understanding the Current Interaction Mechanism
The current interaction with users primarily happens in the commit function within ./src/commands/commit.ts. This function uses prompts (from @clack/prompts) to interactively ask users to confirm commit messages or select files to stage.
2. Integrating the --yes or -y Option
To add the --yes or -y option, you'll need to modify the CLI setup in ./src/cli.ts to recognize the new flags and alter the flow based on these flags.
Modifying ./src/cli.ts:
- Add the new flags to the flags object within the cli function call. This will allow the CLI to recognize --yes and -y as valid options.
flags: {
fgm: Boolean,
yes: Boolean, // Add this line
y: 'yes' // Alias -y to --yes
},
Handling the Flag in the Commit Process:
- In the commit function within ./src/commands/commit.ts, check if the --yes or -y flag is set and adjust the flow accordingly.
// At the beginning of the commit function, add a check for the flag
if (flags.yes) {
// If the flag is set, automatically select the first AI-generated commit message
// and bypass any other interactive prompts (e.g., file staging or commit confirmation)
// You might need to adjust the logic to directly use the first AI-generated message
// and proceed with the commit without further user interaction.
}
3. Best Practices
- Backward Compatibility: Ensure that adding this option does not alter the default behavior for existing users. The interactive mode should remain the default unless the --yes or -y flag is explicitly used.
- Clear Documentation: Update the CLI's help text and any associated documentation to explain the new option and its intended use case.
- Error Handling: Consider scenarios where the AI might not generate any commit messages or generates an error. Ensure there's graceful handling for these cases, even in non-interactive mode.
4. Testing the Feature
- Unit Tests: Add unit tests for the new flag, ensuring that it correctly alters the command's flow.
- Integration Tests: Test the command in a CI/CD pipeline setup to verify it works as expected in automated environments. Mock the AI response to simulate different scenarios, including success, no messages generated, and error responses.
5. Relevant Files and Preliminary Steps
- ./src/cli.ts: To register the new flag and its behavior.
- ./src/commands/commit.ts: To modify the commit process based on the flag.
- Preliminary Steps: Before coding, sketch out the logic changes and how they interact with existing code. Consider any edge cases, such as no AI-generated messages available.
6. Usability and Existing Users
- Ensure the introduction of the --yes or -y option is communicated clearly in the version release notes.
- Provide examples of how to use the new option in automation scripts or CI/CD pipelines, helping users integrate it smoothly into their workflows.
You should be able to implement the --yes or -y option, let us know how this works for you.
from opencommit.
Stale issue message
from opencommit.
will look into this, thanks
from opencommit.
Related Issues (20)
- [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
- [Bug]: Punycode warning HOT 4
- [Feature]: gpt-4o model
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.