diff --git a/README.md b/README.md index 787b44d..38f6865 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,10 @@ using AI, prompt you to review and edit it, then commit it for you. ![cfme demo](./demo/demo.gif) +> There is also a demo available showing how to use `cfme` from within +> [Lazygit](https://github.com/jesseduffield/lazygit/). +> Jump to the [Lazygit Integration](#lazygit) section below. + ## Features ✨ - **AI-Powered Commit Messages** - Leverages modern AI models @@ -425,7 +429,9 @@ CFME_DEFAULT_PROMPT_VARIABLES_FILE_FETCH_URL [Lazygit](https://github.com/jesseduffield/lazygit) is awesome. But `cfme` allows you to be even lazier! You can use `cfme` -from within Lazygit's TUI to generate commit messages. +from within Lazygit's TUI to generate commit messages: + +![cfme lazygit demo](./demo/lazygit-demo.gif) Just add the following custom command to your Lazygit config file (e.g. `~/.config/lazygit/config.yml`): diff --git a/demo/demo.gif b/demo/demo.gif index bd4b1c8..93ae4e8 100644 Binary files a/demo/demo.gif and b/demo/demo.gif differ diff --git a/demo/demo.tape b/demo/demo.tape index b009b6e..5d95696 100644 --- a/demo/demo.tape +++ b/demo/demo.tape @@ -12,31 +12,36 @@ Set WindowBar Colorful Type "# Welcome to the demo for cfme (Commit For Me)! 🐦 " Sleep 500ms Enter 2 + Type "# Add some changes, then stage them:" Sleep 500ms Enter 2 + Type "echo 'Example changes for demo' > my-changes.example" Sleep 500ms Enter + Type "git add my-changes.example" Sleep 500ms Enter 2 -Type "# Run cfme to generate commit message candidates" -Sleep 50ms -Enter -Type "# pick from the candidates," + +Type "# cfme will generate a few commit message candidates based on the changes we made," Sleep 50ms Enter -Type "# and then review/edit the chosen message," + +Type "# we can then pick one of the candidates," Sleep 50ms Enter -Type "# before finally committing the changes." + +Type "# edit or accept one message, and then commit." Sleep 50ms Enter 2 -Sleep 500ms + Type "cfme" Sleep 750ms Enter + +# Wait for the screen, then add review changes and save the commit Wait@30000ms /Select commit/ Sleep 1500ms Up 1 @@ -50,66 +55,104 @@ Ctrl+C Sleep 3000ms Type ":wq" Enter -Sleep 500ms -Type "# We have committed the changes with the chosen message!" + Sleep 1000ms Enter 2 -Type "# Cool! Now let's look at some additional options:" + +Type "# Cool! But we can do more:" Sleep 500ms Enter 2 -Type "# Supply additional instructions on generating the messages:" + +Type "# We can run cfme with custom prompts." +Sleep 500ms +Enter + +Type "# For example, let's say your team always writes commit messages in pirate speak." +Sleep 50ms +Enter + +Type "# You can create a custom prompt for that! Let's take a look at the pirate prompt:" Sleep 500ms Enter 2 -Type "git reset --soft HEAD~1 # Undo last commit so we can run the demo again" + +Type "cat pirate-prompt.md" Sleep 500ms +Enter + +Sleep 5000ms Enter 2 -Type "cfme \" -Sleep 50ms -Enter -Type "--instructions 'These are not real changes, the header should be in ALL CAPS.' \" -Sleep 50ms + +Type "# We chose to slot in our 'PIRATE_EXPRESSIONS' with a string from a YAML file:" +Sleep 500ms +Enter 2 + +Type "cat pirate-vars.yaml" +Sleep 500ms Enter -Type "--response \" + +Sleep 5000ms +Enter 2 + +Type "# Now let's run cfme with our custom pirate prompt!" +Enter 2 + +# Run cfme with the custom prompt and variables, wait for the screen +Type "git reset --soft HEAD~1 # We undo the last commit so we can run the demo again" +Sleep 500ms +Enter 2 +Type "# -p will specify the prompt file, -v the variables file" Sleep 50ms Enter -Type "--silent \" +Type "# -r will print the AI response directly, -s will run in silent mode" Sleep 50ms -Enter -Type "# -r prints the response only (useful for piping), -s suppresses debug output" +Enter 2 +Type "cfme -p pirate-prompt.md -v pirate-vars.yaml -rs" Sleep 750ms Enter Wait+Screen@30000ms /commitMessages/ + Sleep 3000ms Enter -Type "# You get the idea! Here are some more options, we won't run them now:" + +Type "# You get the idea now! Here are some more options" Sleep 750ms Enter 2 -Type "# Supplying a custom prompt and prompt variables file:" + +Type "# Supply instructions to help the AI process your changes:" Sleep 250ms Enter -Type "# cfme -p my-prompt.md -v my-variables.yaml" + +Type "# cfme -i 'This commit changes xyz for abc reason'" Sleep 250ms Enter 2 + Type "# Print the parsed prompt only (useful for debugging):" Sleep 250ms Enter + Type "# cfme --print-parsed-prompt" Sleep 250ms Enter 2 -Type "# Printing the reviewed message instead of committing:" + +Type "# Printing the reviewed message (useful for piping to other tools):" Sleep 250ms Enter -Type "# cfme --message (useful for piping to other tools)" + +Type "# cfme -m" Sleep 250ms Enter 2 -Type "# Remember, you can easily customize cfme to use prompts that fit our own workflow!" + +Type "# Remember, it is really easy to customize cfme to use prompts that fit your workflow!" Sleep 50ms Enter -Type "# Be sure to check out the documentation for more details." + +Type "# Be sure to check out the documentation for more information." Sleep 750ms Enter 2 + Type "# Now, go download cfme, and thanks for watching!" Sleep 500ms Enter + Type "# - codevogel 🐦 (codevogel.com)" Sleep 3000ms diff --git a/demo/lazygit-demo.gif b/demo/lazygit-demo.gif new file mode 100644 index 0000000..ab2017f Binary files /dev/null and b/demo/lazygit-demo.gif differ diff --git a/demo/lazygit-demo.tape b/demo/lazygit-demo.tape new file mode 100644 index 0000000..a8c28c7 --- /dev/null +++ b/demo/lazygit-demo.tape @@ -0,0 +1,66 @@ +# Where should we write the GIF? +Output lazygit-demo.gif + +# Set up a 1200x600 terminal with 46px font. +Set FontSize 20 +Set FontFamily "JetBrains Mono" +Set Width 1200 +Set Height 600 +Set Theme "Kanagawa" +Set WindowBar Colorful + +Type "# Welcome to the lazygit demo for cfme (Commit For Me)! 🐦 " +Sleep 500ms +Enter 2 +Type "# We will add some changes, then stage them, and then press Ctrl-a to run cfme." +Sleep 50ms +Enter +Type "# cfme will generate a few commit message candidates based on the changes we made," +Sleep 50ms +Enter +Type "# we can then pick one of the candidates," +Sleep 50ms +Enter +Type "# edit or accept one message, and then commit." +Sleep 50ms +Enter 2 +Type "echo 'Example changes for demo' > my-changes.example" +Sleep 500ms +Enter +Type "lazygit" +Sleep 500ms +Enter +Sleep 500ms +Type "a" +Sleep 1000ms +Ctrl+A +Wait@30000ms /Select commit/ +Sleep 1500ms +Up 1 +Sleep 500ms +Up 1 +Sleep 1000ms +Enter +Sleep 1000ms +Type "G$a - my review changes" +Ctrl+C +Sleep 3000ms +Type ":wq" +Enter +Sleep 2000ms +Type "q" +Sleep 500ms +Type "# We have committed the changes with the chosen message using lazygit!" +Sleep 1000ms +Enter 2 +Type "# Remember, it is really easy to customize cfme to use prompts that fit your workflow!" +Sleep 50ms +Enter +Type "# Be sure to check out the documentation for more information." +Sleep 750ms +Enter 2 +Type "# Now, go download cfme, and thanks for watching!" +Sleep 500ms +Enter +Type "# - codevogel 🐦 (codevogel.com)" +Sleep 3000ms diff --git a/demo/pirate-prompt.md b/demo/pirate-prompt.md new file mode 100644 index 0000000..ee3dfd5 --- /dev/null +++ b/demo/pirate-prompt.md @@ -0,0 +1,11 @@ +You write git commit messages in pirate speak. + +Get inspired by these pirate expressions: +<__PIRATE_EXPRESSIONS__> + +You MUST generate exactly 3 commit messages + +<__RESPONSE_FORMAT_REQUIREMENTS__> + +These are the changes: +<__GIT_DIFF__> diff --git a/demo/pirate-vars.yaml b/demo/pirate-vars.yaml new file mode 100644 index 0000000..59dd18a --- /dev/null +++ b/demo/pirate-vars.yaml @@ -0,0 +1,9 @@ +vars: + - template_string: "<__PIRATE_EXPRESSIONS__>" + value: | + 1. Avast! + 2. Shiver me timbers! + 3. Yo-ho-ho! + # Or use 'value_from' with one or more commands to fetch the value, e.g.: + value_from: | + curl -s https://pirate.com/pirate-expressions.txt | head -n 3