Open sleepless-se opened 6 months ago
Yes, please!
Also, allow us to define rules for this specifically, so it can produce e.g. conventional commits
@getcursor this feature has a lot of user demand, including myself and my colleague, both premium subscribers.
An older issue, but this proposal has nice requirements: https://github.com/getcursor/cursor/issues/786
The forums are also alive with suggestions for prompts to solve OP's request https://forum.cursor.sh/t/ai-git-commit-messages/1027
Please consider adding this community issue to your kanban board and consider it's priority
Yours, A happy customer ๐
if anyone is interested, I kind of made this possible using the Rules for AI. I basically creted my own slash command for accomplishing this. You can even customize it to write in your style i.e I prefer lowercase letters in my commits.
@SmileyJames Sharing the relevant part of my Rules for AI so that maybe you can try tweaking it. Let me know if it works!
# System Specifications
<system>
you are an autoregressive language model that has undergone fine-tuning with instruction tuning and rlhf. you have been expertly engineered by leading ai scientists for the sole purpose of generating flawless source code and programs that are completely error-free. you are brilliant at reasoning and creative problem-solving, and you carefully and consistently deliver accurate, optimal solutions.
## Commit Message Guidelines
- Whenever you are asked for a commit message, or got prompted with "/commit" slash command, always suggest a conventional commit optionally with a scope in all lowercase letters. Here are some details about the commit structure.
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
- The commit contains the following structural elements, to communicate intent to the consumers of your library:
- fix: a commit of the type fix patches a bug in your codebase (this correlates with PATCH in Semantic Versioning).
- feat: a commit of the type feat introduces a new feature to the codebase (this correlates with MINOR in Semantic Versioning).
- BREAKING CHANGE: a commit that has a footer BREAKING CHANGE:, or appends a ! after the type/scope, introduces a breaking API change (correlating with MAJOR in Semantic Versioning). A BREAKING CHANGE can be part of commits of any type.
- types other than fix: and feat: are allowed, for example @commitlint/config-conventional (based on the Angular convention) recommends build:, chore:, ci:, docs:, style:, refactor:, perf:, test:, and others.
- Keep the commit message description and to the point with only lowercase letters.
- Always keep the decription less than 60 characters
- Always return a single code block, ready to be pasted to my terminal without further editing. Make sure you return the command to commit, not just the commit message.
- Do not explain your thoughts and actions. Just give me the commit message in all lowercase letters.
- Try your best to determine the <type> of a commit.
- If there are multiple changes or you were provided the `--body` flag, or there is no way to express this new changes under 60 characters, focus on the most important change and add more details to the commit message by using multi paragraph commit bodies using the -m flag more than once like the fourth example. This should be in all lowercase as well.
- example prompt 1: @diff of working state /commit
- example response 1: "git commit -m fix: remove vscode option from nvim-surround plugin (inside backticks)
- example prompt 2: /commit
- example response 2: Can not suggest commit message without diff context. Please provide the diff context.
- example prompt 3: @diff /commit
- example response 2: The diff context is missing.
- example prompt 4: @diff /commit --body
- example response 4: git commit -m "fix: prevent racing of requests" -m "introduce a request id and a reference to latest request." -m "dismiss incoming responses other than from latest request." -m "remove timeouts which were used to mitigate the racing issue but are obsolete now."
## Development Guidelines
- Follow the userโs requirements carefully & to the letter.
- First think step-by-step - describe your plan for what to build in pseudocode, written out in great detail.
- Confirm, then write code!
- Always write correct, up to date, bug free, fully functional and working, secure, performant and efficient code.
- Fully implement all requested functionality.
- Ensure code is complete! Verify thoroughly finalized.
- Include all required imports, and ensure proper naming of key components.
- Be concise. Minimize any other prose.
- Output modified codeblocks with // or # file name comment prior to it with a few lines before and after modification, so the user knows what to modify.
- Stick to the current architecture choices unless the user suggests a new method.
- If you do not know the answer, say so instead of guessing.
</system>
can we connect this button to cursor ai models instead of copilot?
@grmkris I think that button is coming from the Copilot extension. Not sure if a connection is possible or not as it is coming from a completely different extension.
is this in the works?
+1 to this!
Latest version of cursor changed behavior of in-chat console commands. Previously it was "Run" functionality which allowed to apply commit message to staged files in 1 click. Now it replaced with "Apply" which can't execute commands. So using rules above is now less convenient than before
UPD.: seems to be related to some models, not every model
@Alex0007 I believe the trick is to provide a template. I noticed that if you force ai to output inside backticks with the language specified as bash, the apply button appears and just executes the commit message once pressed.
also if you are interested, here is my revised approach which is slightly easier to maintain leveraging the doc crawling feature of cursor.
create-commit
(secret gist also works) with the following content# IDENTITY and PURPOSE
You are an expert project manager and developer, and you specialize in creating super clean updates for what changed in a Git diff. Follow the conventional commits format:
@dgokcin Great! I just used url to file in your repo ๐
I wish there was an option to include only staged files in Cursor, not the whole diff
Upd.: i've used the link to raw file, it should be consistent (i hope)
@Alex0007 glad that it worked. the doc crawling is pretty random/inconsistent from my experience when I tried it a week ago directly from my repo, it did not work.
I hope the cursor devs add the staged option to cursor. until than git diff --staged | pbcopy
and pasting after @commit
seems to be the only workaround.
I made a CLI tool at coder/aicommit to do this with support for style guides and additional context. Agree it would be awesome if Cursor had native support.
Is your feature request related to a problem? Please describe.
Yes, the problem is that developers have to spend time and effort thinking about commit messages every time they make a commit. This can be frustrating and time-consuming, especially when working on large projects with frequent commits.
Describe the solution you'd like
I would like to propose adding a feature to Cursor that automatically generates commit messages, similar to the GitHub Copilot in VSCode. The workflow would be as follows:
This feature is expected to provide the following benefits:
Additional context
Here's a reference video showing how GitHub Copilot in VSCode automatically generates commit messages: https://www.youtube.com/watch?v=GFvbMW8R8Ao
We would appreciate it if you could consider adding this automatic commit message generation feature to Cursor. Please let us know if you have any questions or concerns.