From d9396a176d3bde077435bf3696f6d17d866ebce4 Mon Sep 17 00:00:00 2001 From: KaySar12 Date: Tue, 20 May 2025 16:38:47 +0700 Subject: [PATCH] refactor(scripts): streamline git diff usage and update commit generation logic --- scripts/interpreter/gen_commit.py | 20 +++++++++---------- ...git_commit.md => git_commit_convention.md} | 0 2 files changed, 10 insertions(+), 10 deletions(-) rename scripts/interpreter/resources/{git_commit.md => git_commit_convention.md} (100%) diff --git a/scripts/interpreter/gen_commit.py b/scripts/interpreter/gen_commit.py index 0a9fd67..7cd4eb8 100755 --- a/scripts/interpreter/gen_commit.py +++ b/scripts/interpreter/gen_commit.py @@ -29,8 +29,13 @@ def gen_commit(project_path): convention_path = os.path.join( os.path.dirname(__file__), "resources/commit_convention.md" ) + git_commit_convention_path = os.path.join( + os.path.dirname(__file__), "resources/git_commit_convention.md" + ) with open(convention_path, "r") as f: convention_content = f.read() + with open(git_commit_convention_path, "r") as f: + git_commit_convention_content = f.read() agent.system_message = f""" You are a helpful assistant that generates concise, conventional commit messages based on code diffs. @@ -38,19 +43,14 @@ You are a helpful assistant that generates concise, conventional commit messages Guidelines: - Use English. - Do not include explanations—only output commit message in under 100 characters. -- Follow this convention: +- Use this git commit convention to get uncommitted changes: +{git_commit_convention_content} +- After getting uncommitted changes, analyze and generate a commit message Follow this convention: {convention_content} +- Commit Message should be in under 100 characters. """ - - diff_output = get_git_diff(project_path) - if not diff_output: - return "chore: no changes to commit" - prompt = f""" -Analyze the following git diff and generate a commit message: - - -{diff_output} +Analyze the git commit and generate a commit message for this project: {project_path} """ response = agent.chat(prompt) diff --git a/scripts/interpreter/resources/git_commit.md b/scripts/interpreter/resources/git_commit_convention.md similarity index 100% rename from scripts/interpreter/resources/git_commit.md rename to scripts/interpreter/resources/git_commit_convention.md