From b9b5aaea288ad81de679cae9eacacbac73e87cff Mon Sep 17 00:00:00 2001 From: Franck Cuny <59291+fcuny@users.noreply.github.com> Date: Fri, 28 Feb 2025 19:19:53 -0800 Subject: =?UTF-8?q?=F0=9F=9A=80=20Refactor=20LLM=20config:=20Move=20to=20s?= =?UTF-8?q?tandardized=20templates=20and=20improve=20setup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Migrated prompts from text files to YAML templates in `.config/llm/templates/` directory - Updated fish shell aliases to use the new template system with `-t` flag instead of reading files - Enhanced justfile's `llm` target with proper Claude model setup and 1Password integration - Added `LLM_USER_PATH` environment variable for consistent configuration path - Fixed PR prompt format to better organize content and remove issue resolution section - Updated Nix configuration to support the new file structure The changes standardize our LLM prompt system and make it more maintainable, while improving the setup experience for new users. 🧰 --- configs/llm/templates/commit-prompt.yaml | 23 +++++++++++++++++++++++ configs/llm/templates/pr-prompt.yaml | 14 ++++++++++++++ configs/prompts/commit-system-prompt.txt | 20 -------------------- configs/prompts/pr-prompt.txt | 12 ------------ justfile | 7 +++++-- nix/users/fcuny/llm.nix | 18 ++++++++++++------ 6 files changed, 54 insertions(+), 40 deletions(-) create mode 100644 configs/llm/templates/commit-prompt.yaml create mode 100644 configs/llm/templates/pr-prompt.yaml delete mode 100644 configs/prompts/commit-system-prompt.txt delete mode 100644 configs/prompts/pr-prompt.txt diff --git a/configs/llm/templates/commit-prompt.yaml b/configs/llm/templates/commit-prompt.yaml new file mode 100644 index 0000000..780375e --- /dev/null +++ b/configs/llm/templates/commit-prompt.yaml @@ -0,0 +1,23 @@ +prompt: > + Write a concise, informative commit message for these changes: + - Review the whole context of the diff carefully to see what effect the change would have on the rest of the code and explain that. Be specific about the effect. + - Do not guess about intent. + - The goal of this commit message is that someone familiar with the codebase, but not with these changes would understand why the changes were made and what was changed. + - The first line should be a short summary of the changes + - Explain the 'why' behind changes + - Use bullet points for multiple changes + - Tone: Use some emojis, be funny, expressive, but stay professional + - If there are no changes, or the input is blank - then return a blank string + + Think carefully about what would be most helpful to someone trying to understand the intent of this commit before you write your commit message. Your commit message will be used as an example to train other team members about the content of a good commit message. + + The output format should be: + + Summary of changes + - changes + - changes + and so on + + What you write will be passed directly to git commit -m "[message]" + + Text to use for the commit message: $input diff --git a/configs/llm/templates/pr-prompt.yaml b/configs/llm/templates/pr-prompt.yaml new file mode 100644 index 0000000..4c13c0d --- /dev/null +++ b/configs/llm/templates/pr-prompt.yaml @@ -0,0 +1,14 @@ +prompt: > + Write a clear, informative pull request message in markdown: + + * Start with a summary + * Remember to mention the files that were changed, and what was changed + * Explain the 'why' behind changes + * Include a bulleted list to outline all of the changes + * If there are no changes, or the input is blank - then return a blank string + + Think carefully before you write your pull request body. + + What you write will be passed to create a github pull request + + Text to use for the pull request message: $input diff --git a/configs/prompts/commit-system-prompt.txt b/configs/prompts/commit-system-prompt.txt deleted file mode 100644 index 8ddc434..0000000 --- a/configs/prompts/commit-system-prompt.txt +++ /dev/null @@ -1,20 +0,0 @@ -Write a concise, informative commit message for these changes: -- Review the whole context of the diff carefully to see what effect the change would have on the rest of the code and explain that. Be specific about the effect. -- Do not guess about intent. -- The goal of this commit message is that someone familiar with the codebase, but not with these changes would understand why the changes were made and what was changed. -- The first line should be a short summary of the changes -- Explain the 'why' behind changes -- Use bullet points for multiple changes -- Tone: Use some emojis, be funny, expressive, but stay professional -- If there are no changes, or the input is blank - then return a blank string - -Think carefully about what would be most helpful to someone trying to understand the intent of this commit before you write your commit message. Your commit message will be used as an example to train other team members about the content of a good commit message. - -The output format should be: - -Summary of changes -- changes -- changes -and so on - -What you write will be passed directly to git commit -m "[message]" diff --git a/configs/prompts/pr-prompt.txt b/configs/prompts/pr-prompt.txt deleted file mode 100644 index 625c893..0000000 --- a/configs/prompts/pr-prompt.txt +++ /dev/null @@ -1,12 +0,0 @@ -Write a clear, informative pull request message in markdown: - -* Remember to mention the files that were changed, and what was changed -* Start with a summary -* Explain the 'why' behind changes -* Include a bulleted list to outline all of the changes -* If there are changes that resolve specified issues add the issues to a list of closed issues -* If there are no changes, or the input is blank - then return a blank string - -Think carefully before you write your pull request body. - -What you write will be passed to create a github pull request diff --git a/justfile b/justfile index 84c7a00..e378239 100644 --- a/justfile +++ b/justfile @@ -112,5 +112,8 @@ vm-copy: [group('llm')] llm: - uv tool install llm - llm install llm-anthropic + #!/usr/bin/env fish + uv tool install llm -U + llm install -U llm-anthropic + llm models default anthropic/claude-3-7-sonnet-20250219 + llm keys set anthropic --value (op read --account my.1password.com "op://Private/anthropic llm/credential") diff --git a/nix/users/fcuny/llm.nix b/nix/users/fcuny/llm.nix index 48604c3..407cead 100644 --- a/nix/users/fcuny/llm.nix +++ b/nix/users/fcuny/llm.nix @@ -1,16 +1,22 @@ { ... }: { - home.file.".config/prompts/pr-prompt.txt".text = - builtins.readFile ../../../configs/prompts/pr-prompt.txt; + # we need this path to be created. + home.file.".configs/llm/templates/.keep".text = "# Managed by Home Manager"; + home.file.".config/llm/templates/pr-prompt.yaml".text = + builtins.readFile ../../../configs/llm/templates/pr-prompt.yaml; - home.file.".config/prompts/commit-system-prompt.txt".text = - builtins.readFile ../../../configs/prompts/commit-system-prompt.txt; + home.file.".config/llm/templates/commit-prompt.yaml".text = + builtins.readFile ../../../configs/llm/templates/commit-prompt.yaml; programs.fish = { shellAliases = { - commit-msg = "git diff HEAD | llm -m claude-3.5-sonnet -s (cat ~/.config/prompts/commit-system-prompt.txt |psub)"; - pr-msg = "git diff HEAD | llm -m claude-3.5-sonnet -s (cat ~/.config/prompts/pr-prompt.txt |psub)"; + commit-msg = "git diff --cached | llm -t commit-prompt"; + pr-msg = "git diff HEAD | llm -t pr-prompt"; }; }; + + home.sessionVariables = { + LLM_USER_PATH = "$HOME/.config/llm"; + }; } -- cgit v1.2.3