diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 72c92ff..d8641bb 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -1,4 +1,4 @@ -## Co-Pilot Pull Request Reviews +## Copilot Pull Request Reviews - When reviewing a pull request read the body of the pull request and identify the "Type of Work" and the "Topic". - If no "Type of Work" or "Topic" is checked in the task list or more than one "Type of Work" or more than one "Topic" is checked, leave a comment on the pull request asking the author to check exactly one "Type of Work" and exactly one "Topic" and do not perform a review. diff --git a/.github/skills/log-prompts/SKILL.md b/.github/skills/log-prompts/SKILL.md new file mode 100644 index 0000000..ce5266e --- /dev/null +++ b/.github/skills/log-prompts/SKILL.md @@ -0,0 +1,14 @@ +--- +name: log-prompts +description: Logs the prompts in the active chat window to a comment on the open pull request for the active branch. +allowed-tools: shell +--- + +The user will run this skill when they want to log the prompts in the active chat window to a comment on the open pull request for the active branch. + +## Instructions: + +1. Copy the entire contents of the chat window into a text file named `chat.txt` in the `skills/log-prompts` directory. +2. Run the `openPR.bash` script in the terminal. +3. Run the `createComment.bash` script in the terminal. +4. Run the `postPrompts.bash` script in the terminal. diff --git a/.github/skills/log-prompts/createComment.bash b/.github/skills/log-prompts/createComment.bash new file mode 100755 index 0000000..d32b676 --- /dev/null +++ b/.github/skills/log-prompts/createComment.bash @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "Creating Prompt Log comment for pull request..." diff --git a/.github/skills/log-prompts/openPR.bash b/.github/skills/log-prompts/openPR.bash new file mode 100755 index 0000000..58f2366 --- /dev/null +++ b/.github/skills/log-prompts/openPR.bash @@ -0,0 +1,87 @@ +#!/bin/bash + +# Get the current branch name +CURRENT_BRANCH=$(git branch --show-current) + +# Check if we're on a branch (not in detached HEAD state) +if [ -z "$CURRENT_BRANCH" ]; then + echo "Error: Not on a branch" + exit 1 +fi + +# Check if there's already an open pull request for this branch +EXISTING_PR=$(gh pr list --head "$CURRENT_BRANCH" --state open --json number --jq '.[0].number' 2>/dev/null) + +if [ -n "$EXISTING_PR" ]; then + # PR already exists, do nothing + exit 0 +fi + +# No PR exists, prompt the user +echo "" +echo "No open pull request found for branch: $CURRENT_BRANCH" +read -p "Do you want to create a pull request? (y/n) " -n 1 -r +echo "" + +if [[ ! $REPLY =~ ^[Yy]$ ]]; then + echo "Pull request creation cancelled." + exit 0 +fi + +# Read PULL_REQUEST_TEMPLATE.md and extract options dynamically +TEMPLATE_FILE="../../PULL_REQUEST_TEMPLATE.md" + +if [ ! -f "$TEMPLATE_FILE" ]; then + echo "Error: $TEMPLATE_FILE not found" + exit 1 +fi + +# Extract Type of Work options (between "### Type of Work" and "### Topic") +mapfile -t TYPE_OPTIONS < <(sed -n '/^### Type of Work/,/^### Topic/p' "$TEMPLATE_FILE" | grep -oP '(?<=- \[ \] - )\S+' | grep -v '^$') + +# Extract Topic options (between "### Topic" and "### Time Estimate") +mapfile -t TOPIC_OPTIONS < <(sed -n '/^### Topic/,/^### Time Estimate/p' "$TEMPLATE_FILE" | grep -oP '(?<=- \[ \] - ).+' | sed 's/^[[:space:]]*//') + +# Ask for Type of Work +echo "" +echo "Select Type of Work:" +for i in "${!TYPE_OPTIONS[@]}"; do + echo "$((i + 1))) ${TYPE_OPTIONS[$i]}" +done +read -p "Enter your choice (1-${#TYPE_OPTIONS[@]}): " -r TYPE_CHOICE + +if [[ ! $TYPE_CHOICE =~ ^[0-9]+$ ]] || [ "$TYPE_CHOICE" -lt 1 ] || [ "$TYPE_CHOICE" -gt ${#TYPE_OPTIONS[@]} ]; then + echo "Invalid choice. Exiting." + exit 1 +fi + +TYPE_OF_WORK="${TYPE_OPTIONS[$((TYPE_CHOICE - 1))]}" + +# Ask for Topic +echo "" +echo "Select Topic:" +for i in "${!TOPIC_OPTIONS[@]}"; do + echo "$((i + 1))) ${TOPIC_OPTIONS[$i]}" +done +read -p "Enter your choice (1-${#TOPIC_OPTIONS[@]}): " -r TOPIC_CHOICE + +if [[ ! $TOPIC_CHOICE =~ ^[0-9]+$ ]] || [ "$TOPIC_CHOICE" -lt 1 ] || [ "$TOPIC_CHOICE" -gt ${#TOPIC_OPTIONS[@]} ]; then + echo "Invalid choice. Exiting." + exit 1 +fi + +TOPIC="${TOPIC_OPTIONS[$((TOPIC_CHOICE - 1))]}" + +# Check if the active branch has any commits +COMMIT_COUNT=$(git rev-list --count main..$CURRENT_BRANCH 2>/dev/null || echo "0") + +if [ "$COMMIT_COUNT" -eq 0 ]; then + # No commits on this branch, create an empty commit + COMMIT_MESSAGE="Starting $TYPE_OF_WORK - $TOPIC" + git commit --allow-empty -m "$COMMIT_MESSAGE" +fi + +# Create the PR with a title that includes the Type of Work and Topic +PR_TITLE="$TYPE_OF_WORK - $TOPIC" + +gh pr create --base main --head "$CURRENT_BRANCH" --title "$PR_TITLE" --body "" --draft \ No newline at end of file diff --git a/.github/skills/log-prompts/postPrompts.bash b/.github/skills/log-prompts/postPrompts.bash new file mode 100755 index 0000000..13a8a8f --- /dev/null +++ b/.github/skills/log-prompts/postPrompts.bash @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "Posting prompts to pull request..." diff --git a/.gitignore b/.gitignore index a917fb2..a1e7a70 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,8 @@ yarn-error.log* pnpm-debug.log* lerna-debug.log* +.github/skills/log-prompts/chat*.txt + node_modules flashword/dist dist-ssr