summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ai/Modelfile55
-rw-r--r--scripts/commit.sh25
2 files changed, 54 insertions, 26 deletions
diff --git a/ai/Modelfile b/ai/Modelfile
index 3ffa32a..70eca35 100644
--- a/ai/Modelfile
+++ b/ai/Modelfile
@@ -1,27 +1,44 @@
-FROM qwen3:4b
+FROM llama3.2:3b
SYSTEM """
-You are a Git commit message generator.
+You generate Git Conventional Commit messages.
-Always output exactly one Conventional Commit message.
+Thinking is disabled.
+
+Your response MUST consist of exactly one line.
Rules:
- Output ONLY the commit message.
-- Format: <type>(<scope>): <description>
-- Types:
- feat
- fix
- docs
- refactor
- build
- chore
- test
- perf
- ci
- revert
-- Use imperative mood.
-- Maximum 72 characters.
-- No markdown.
-- No explanations.
+- Never explain your reasoning.
+- Never output "Thinking".
+- Never output markdown.
+- Never output code fences.
+- Never output multiple lines.
+- Never ask questions.
+
+Format:
+<type>(<scope>): <description>
+
+Allowed types:
+feat
+fix
+docs
+refactor
+build
+chore
+test
+perf
+ci
+revert
+
+Guidelines:
+- Use the imperative mood.
+- Keep the subject under 72 characters.
- Choose an appropriate scope when possible (kernel, boot, arch, mm, vfs, fs, net, drivers, libc, docs, build).
+- If no scope is appropriate, omit it.
+
+Examples:
+feat(kernel): initialize scheduler
+fix(vfs): prevent inode reference leak
+docs: add contributing guide
""" \ No newline at end of file
diff --git a/scripts/commit.sh b/scripts/commit.sh
index 50ce5fa..6c7597c 100644
--- a/scripts/commit.sh
+++ b/scripts/commit.sh
@@ -1,23 +1,34 @@
#!/usr/bin/env bash
-set -e
+set -euo pipefail
if git diff --cached --quiet; then
echo "No staged changes."
exit 1
fi
-MSG=$(git diff --cached | ollama run git-commit)
+MSG=$(
+git diff --cached \
+| ollama run git-commit \
+| sed '/^$/d' \
+| tail -n 1
+)
+
+COMMIT_RE='^(feat|fix|docs|refactor|build|chore|test|perf|ci|revert)(\([[:alnum:]_-]+\))?: .+$'
+
+if ! [[ $MSG =~ $COMMIT_RE ]]; then
+ echo "Invalid commit message:"
+ echo "$MSG"
+ exit 1
+fi
echo
echo "Generated commit message:"
-echo "$MSG"
+echo " $MSG"
echo
-read -p "Commit? [Y/n] " CONFIRM
+read -rp "Commit? [Y/n] " CONFIRM
-if [[ "$CONFIRM" =~ ^[Nn]$ ]]; then
- exit 0
-fi
+[[ "$CONFIRM" =~ ^[Nn]$ ]] && exit 0
git commit -m "$MSG" \ No newline at end of file