64 lines
1.3 KiB
Bash
Executable File
64 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
|
REPO_ROOT=$(git rev-parse --show-toplevel)
|
|
REPORT_DIR="$REPO_ROOT/.reports"
|
|
SYSTEM_PROMPT_FILE="$SCRIPT_DIR/coder.md"
|
|
|
|
mkdir -p "$REPORT_DIR"
|
|
|
|
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
|
REPORT_FILE="$REPORT_DIR/diff_$TIMESTAMP.md"
|
|
LATEST_LINK="$REPORT_DIR/latest.md"
|
|
|
|
PROMPT='
|
|
Summarize the changes made in this diff, given the diff and the after code.
|
|
The rest of the code repository is not provided. Based on the changes, infer
|
|
the reasons behind the changes, try to find problems with the proposed changes,
|
|
and offer suggestions for improvements.
|
|
|
|
OUTPUT FORMAT:
|
|
|
|
```
|
|
# Digest
|
|
|
|
one liner detailing what has been changed
|
|
|
|
# Summary
|
|
|
|
short paragraph summary of the changes made in the diff
|
|
|
|
# Details
|
|
|
|
detailed breakdown of the changes, grouped by topic
|
|
|
|
# Comments
|
|
|
|
comments about inferred intent, possible issues, and potential improvements
|
|
```
|
|
'
|
|
|
|
MODEL="gemini-3-flash-preview"
|
|
FALLBACK="claude-sonnet-4.6"
|
|
|
|
context() {
|
|
git diff --name-only --cached | xargs -I {} echo -i "{}" | xargs code2prompt .
|
|
}
|
|
|
|
diff() {
|
|
git diff --cached
|
|
}
|
|
|
|
aicli \
|
|
-m "$MODEL" \
|
|
-b "$FALLBACK" \
|
|
-sf "$SYSTEM_PROMPT_FILE" \
|
|
-p "$PROMPT" \
|
|
-p "DIFF:\n\n$(diff)" \
|
|
-p "AFTER CODE:\n\n$(context)" \
|
|
-o "$REPORT_FILE"
|
|
|
|
ln -sf "$REPORT_FILE" "$LATEST_LINK"
|
|
|
|
glow -p "$REPORT_FILE"
|