Initial commit

This commit is contained in:
Zhongwei Li
2025-11-30 09:01:58 +08:00
commit aa33fffdfe
25 changed files with 4562 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
#!/bin/bash
# get-pr-diff.sh - Gets the diff for a PR
# Usage: get-pr-diff.sh <branch_name> [main_branch]
# Output: Diff text with stats
set -e
BRANCH_NAME="$1"
MAIN_BRANCH="${2:-main}"
if [ -z "$BRANCH_NAME" ]; then
echo "Error: Branch name required"
echo "Usage: get-pr-diff.sh <branch_name> [main_branch]"
exit 1
fi
# Verify main branch exists, fallback to master
if ! git show-ref --verify --quiet "refs/heads/$MAIN_BRANCH"; then
if git show-ref --verify --quiet refs/heads/master; then
MAIN_BRANCH="master"
else
echo "Error: Could not find main or master branch"
exit 1
fi
fi
# Get diff stats
echo "=== DIFF STATS ==="
git diff "$MAIN_BRANCH...$BRANCH_NAME" --stat
echo ""
echo "=== FILES CHANGED ==="
git diff "$MAIN_BRANCH...$BRANCH_NAME" --name-status
echo ""
echo "=== FULL DIFF ==="
git diff "$MAIN_BRANCH...$BRANCH_NAME"

View File

@@ -0,0 +1,32 @@
#!/bin/bash
# get-pr-info.sh - Fetches PR information for the current branch
# Usage: get-pr-info.sh [branch_name]
# Output: JSON with PR details
set -e
BRANCH_NAME="${1:-$(git rev-parse --abbrev-ref HEAD)}"
# Check if gh CLI is installed
if ! command -v gh &> /dev/null; then
echo '{"error": "GitHub CLI (gh) not installed. Install: https://cli.github.com/"}' | jq
exit 1
fi
# Check if authenticated
if ! gh auth status &> /dev/null; then
echo '{"error": "Not authenticated with GitHub CLI. Run: gh auth login"}' | jq
exit 1
fi
# Get PR for current branch
PR_DATA=$(gh pr view "$BRANCH_NAME" --json number,title,body,url,state,isDraft,additions,deletions,changedFiles 2>/dev/null || echo '{"error": "No PR found for branch: '"$BRANCH_NAME"'"}')
# Check if error in PR_DATA
if echo "$PR_DATA" | jq -e '.error' &> /dev/null; then
echo "$PR_DATA"
exit 1
fi
# Add branch name to output
echo "$PR_DATA" | jq --arg branch "$BRANCH_NAME" '. + {branch: $branch}'

View File

@@ -0,0 +1,53 @@
#!/bin/bash
# save-review.sh - Saves PR review to feature directory
# Usage: save-review.sh <branch_name> <review_file_path>
set -e
BRANCH_NAME="$1"
REVIEW_FILE_PATH="$2"
if [ -z "$BRANCH_NAME" ] || [ -z "$REVIEW_FILE_PATH" ]; then
echo "Error: Missing required arguments"
echo "Usage: save-review.sh <branch_name> <review_file_path>"
exit 1
fi
# Verify feature directory exists
FEATURE_DIR=".specimin/plans/$BRANCH_NAME"
if [ ! -d "$FEATURE_DIR" ]; then
echo "Error: Feature directory not found: $FEATURE_DIR"
echo "This PR was not created through the spec/plan/implement flow."
exit 1
fi
# Verify review file exists
if [ ! -f "$REVIEW_FILE_PATH" ]; then
echo "Error: Review file not found: $REVIEW_FILE_PATH"
exit 1
fi
# Create reviews directory if it doesn't exist
REVIEWS_DIR="$FEATURE_DIR/reviews"
mkdir -p "$REVIEWS_DIR"
# Find the next review number
NEXT_NUM=1
if [ -d "$REVIEWS_DIR" ]; then
# Find highest existing review number
HIGHEST=$(find "$REVIEWS_DIR" -name "review_*.md" -type f 2>/dev/null | \
sed 's/.*review_\([0-9]*\)\.md/\1/' | \
sort -n | \
tail -1)
if [ -n "$HIGHEST" ]; then
NEXT_NUM=$((HIGHEST + 1))
fi
fi
# Copy review file to reviews directory with incremental number
REVIEW_DEST="$REVIEWS_DIR/review_$NEXT_NUM.md"
cp "$REVIEW_FILE_PATH" "$REVIEW_DEST"
# Output success message with JSON
echo "{\"feature_dir\": \"$FEATURE_DIR\", \"branch_name\": \"$BRANCH_NAME\", \"review_path\": \"$REVIEW_DEST\", \"review_number\": $NEXT_NUM}"