SLM Git Repo Manager
Lightweight local Git utility that processes raw diff streams and formats standards-compliant Conventional Commit messages offline.
💻 Installation
# Install in editable mode locally
pip install -e ./slm_git_repo_manager
# Set runtime thread performance
export SLM_GIT_REPO_MANAGER_N_THREADS=4
🐙 Checkout from GitHub
Clone only this agent's folder from the monorepo using Git sparse-checkout — no need to download the full repository:
Option 1 — Sparse Checkout (Recommended)
Option 2 — Full Repository Clone
💡 Tip: After checkout, install the package locally with pip install -e ./slm_git_repo_manager to run in editable mode without publishing to PyPI.
⚙️ Configuration API
Constructor Parameters
| Parameter | Type / Default | Description |
|---|---|---|
| model_path | str | None | Explicit path to the ONNX model directory. Defaults to caching/sharing the main model in the monorepo. |
| cache_dir | str | None | HF model directory path. Also settable via SLM_GIT_REPO_MANAGER_CACHE_DIR. |
| n_ctx | int | 2048 | Context window size in tokens. Also settable via SLM_GIT_REPO_MANAGER_N_CTX. |
| n_threads | int | 4 | CPU threads for ONNX Runtime. Also settable via SLM_GIT_REPO_MANAGER_N_THREADS. |
| system_prompt | str | None | Optional custom system prompt instructions overriding the default template. |
| user_input | str | None | Optional additional user-supplied target parameters or variables. |
generate_commit_message() Parameters
| Parameter | Type / Default | Description |
|---|---|---|
| diff_text | str | Required. The raw output of your git diff script sequence. |
| stream | bool | False | If True, enables token streaming of the model's Conventional Commit generation in real-time. Returns a Python generator. |
| system_prompt | str | None | Optional custom system prompt instructions overriding the default template. |
| user_input | str | None | Optional additional user-supplied target parameters or variables. |
from slm_git_repo_manager.git_repo_manager import SLMGitRepoManager
copilot = SLMGitRepoManager()
diff_data = """diff --git a/slm_core/orchestrator.py b/slm_core/orchestrator.py
--- a/slm_core/orchestrator.py
+++ b/slm_core/orchestrator.py
@@ -12,5 +12,12 @@ class SLMOrchestrator:
- print("Running orchestrator route...")
+ logger.info("Initializing query router path routing details")
- return self.fallback_run(query)
+ route = self.classifier.predict(query)
+ if route == "rag":
+ return self.rag_agent.query(query)
diff --git a/tests/test_orchestrator.py b/tests/test_orchestrator.py
--- a/tests/test_orchestrator.py
+++ b/tests/test_orchestrator.py
@@ -2,4 +2,9 @@
-def test_orchestrator():
+def test_orchestrator_routing():
"""
msg = copilot.generate_commit_message(diff_data)
print(msg)
# Output:
# feat(slm_core): Implement classifier-based routing in SLMOrchestrator
# - Replace print statement with structured logger info
# - Add test_orchestrator_routing to verify query routing
Conventional Commit Standards
The Git Repo Manager forces structural formatting that aligns strictly with standard guidelines:
- Formats:
<type>(<scope>): <description>followed by optional description paragraphs. - Permitted Types:
feat,fix,docs,style,refactor,perf,test,build,ci,chore,revert. - Zero explanation output: Synthesizes only standard git message blocks without conversational prefaces.
🔀 Advanced Git Workflows
Git Repo Manager exposes advanced instance methods to automate local staging, commits, merges, and auto-conflict resolutions:
1. Automated Conventional Commit
Stages tracked changes, generates a message, and commits in a single line:
success, log_msg = copilot.commit()
2. Branch Merge and Conflict Resolution
Merges developer branches and automatically rewrites standard git conflict markers with combined resolutions from the local SLM model:
success, merge_status = copilot.merge("feature-branch")
if not success:
resolution_results = copilot.resolve_conflicts()
print("Resolved files:", resolution_results["resolved"])
🔌 VS Code Task Integration
You can run commit and conflict resolution workflows directly within your VS Code workspace using the task runner config. Add the following to your .vscode/tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "SLM Git: Auto-Commit Changes",
"type": "shell",
"command": "python -c \"from slm_git_repo_manager.git_repo_manager import SLMGitRepoManager; print(SLMGitRepoManager().commit()[1])\"",
"problemMatcher": []
},
{
"label": "SLM Git: Resolve Merge Conflicts",
"type": "shell",
"command": "python -c \"from slm_git_repo_manager.git_repo_manager import SLMGitRepoManager; print(SLMGitRepoManager().resolve_conflicts())\"",
"problemMatcher": []
}
]
}
Run these tasks by triggering the Command Palette (Cmd+Shift+P or Ctrl+Shift+P), selecting Run Task, and choosing the desired Git helper task.
Context Truncation Safeguard
Raw git diff outputs can scale to tens of thousands of tokens, which can overflow the context limits of small models or cause massive performance latency.