From dc5fb67ac1aeb803f322d3f0d962c8ee5e836501 Mon Sep 17 00:00:00 2001 From: Dita Aji Pratama Date: Wed, 10 Jun 2026 11:27:59 +0700 Subject: [PATCH] feat: add git policy - never auto commit without user permission - Add git policy section in system prompt (gadget.py): no auto git add/commit - Add policy warning in git_operation tool description (coder.py) - LLM must ask user before running git add or git commit - Safe commands (git status, git diff, git log) can run without asking - When user asks to commit: show changes first, then wait for confirmation --- scripts/gadget.py | 7 +++++++ tools/coder.py | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/gadget.py b/scripts/gadget.py index 3f1522b..4a6991a 100644 --- a/scripts/gadget.py +++ b/scripts/gadget.py @@ -33,6 +33,13 @@ def build_system_prompt(tools_definition): f"Your workspace directory is: {os.getcwd()}. " "All file operations are relative to this directory.", "", + "⚠️ GIT POLICY — IMPORTANT:", + "- NEVER run 'git add' or 'git commit' automatically after making changes.", + "- After editing/creating files, always ASK the user first before committing.", + "- Only run git commands when the user explicitly asks you to commit.", + "- You may run 'git status', 'git diff', 'git log' freely to inspect state.", + "- When user asks to commit: show them the changes first, then wait for confirmation.", + "", "RAG capabilities (knowledge retrieval):", "- list_collections → see available collections & doc counts.", "- create_collection → create a new collection for a new topic.", diff --git a/tools/coder.py b/tools/coder.py index 4e4929b..9f633ae 100644 --- a/tools/coder.py +++ b/tools/coder.py @@ -146,7 +146,10 @@ schema_git_operation = { "type": "function", "function": { "name": "git_operation", - "description": "Run a git command. Pass the git arguments as a list (e.g., ['status', '--short'] for 'git status --short').", + "description": "Run a git command. Pass the git arguments as a list (e.g., ['status', '--short'] for 'git status --short'). " + "POLICY: Never run 'git add' or 'git commit' without explicit user permission. " + "Safe to run without asking: git status, git diff, git log. " + "Always ask first before committing.", "parameters": { "type": "object", "properties": {