Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
14 changes: 14 additions & 0 deletions .github/skills/log-prompts/SKILL.md
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 3 additions & 0 deletions .github/skills/log-prompts/createComment.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

echo "Creating Prompt Log comment for pull request..."
87 changes: 87 additions & 0 deletions .github/skills/log-prompts/openPR.bash
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions .github/skills/log-prompts/postPrompts.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

echo "Posting prompts to pull request..."
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down