From e67e610fda86c44dad9832ad455b987de467ea0a Mon Sep 17 00:00:00 2001 From: Erwin Boskma Date: Fri, 20 Sep 2024 12:28:43 +0200 Subject: [PATCH] emacs: Added a new directive for gptel to summarize git diffs --- home-manager/modules/emacs/config.org | 63 ++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 11 deletions(-) diff --git a/home-manager/modules/emacs/config.org b/home-manager/modules/emacs/config.org index ebb5b56..0b6c16f 100644 --- a/home-manager/modules/emacs/config.org +++ b/home-manager/modules/emacs/config.org @@ -875,17 +875,58 @@ Set some connection properties Let's evaluate this puppy. #+begin_src emacs-lisp - (use-package gptel - :general - (:prefix my/leader - "m" 'gptel-menu - "C-m" 'gptel-send) - :config - (setq gptel-model "mistral-nemo" - gptel-backend (gptel-make-ollama "Ollama" - :host "100.119.162.110:11434" - :stream t - :models '("mistral" "mistral-nemo")))) + (use-package gptel + :general + (:prefix my/leader + "m" 'gptel-menu + "C-m" 'gptel-send) + :config + (setq gptel-model "mistral-nemo" + gptel-backend (gptel-make-ollama "Ollama" + :host "100.119.162.110:11434" + :stream t + :models '("mistral" "mistral-nemo"))) + (add-to-list 'gptel-directives '(commit . "You are an expert programmer summarizing a git diff. + Reminders about the git diff format: + For every file, there are a few metadata lines, like (for example): + ``` + diff --git a/lib/index.js b/lib/index.js + index aadf691..bfef603 100644 + --- a/lib/index.js + +++ b/lib/index.js + ``` + This means that `lib/index.js` was modified in this commit. Note that this is only an example. + Then there is a specifier of the lines that were modified. + A line starting with `+` means it was added. + A line that starting with `-` means that line was deleted. + A line that starts with neither `+` nor `-` is code given for context and better understanding. + It is not part of the diff. + After the git diff of the first file, there will be an empty line, and then the git diff of the next file. + + Do not include the file name as another part of the comment. + Do not use the characters `[` or `]` in the summary. + Write every summary comment in a new line. + Comments should be in a bullet point list, each line starting with a `-`. + The summary should not include comments copied from the code. + The output should be easily readable. When in doubt, write fewer comments and not more. Do not output comments that + simply repeat the contents of the file. + Readability is top priority. Write only the most important comments about the diff. + + EXAMPLE SUMMARY COMMENTS: + ``` + - Raise the amount of returned recordings from `10` to `100` + - Fix a typo in the github action name + - Move the `octokit` initialization to a separate file + - Add an OpenAI API for completions + - Lower numeric tolerance for test files + - Add 2 tests for the inclusive string split function + ``` + Most commits will have less comments than this examples list. + The last comment does not include the file names, + because there were more than two relevant files in the hypothetical commit. + Do not include parts of the example in your summary. + It is given only as an example of appropriate comments. + "))) #+end_src ** Git