From ab5d515c702fceb1e0b0de40d44007b3bf124e64 Mon Sep 17 00:00:00 2001 From: Grant Braught Date: Wed, 1 Jul 2026 18:55:11 +0000 Subject: [PATCH 1/4] test post-session skill --- .github/copilot-instructions.md | 2 +- .github/skills/log-session/SKILL.md | 23 ++++++ .../log-session/post_copilot_session.sh | 78 +++++++++++++++++++ 3 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 .github/skills/log-session/SKILL.md create mode 100755 .github/skills/log-session/post_copilot_session.sh 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-session/SKILL.md b/.github/skills/log-session/SKILL.md new file mode 100644 index 0000000..b4a77df --- /dev/null +++ b/.github/skills/log-session/SKILL.md @@ -0,0 +1,23 @@ +--- +name: log-session +description: Publishes the current Copilot session transcript to the pull request that is open for the active branch. +disable-model-invocation: true +allowed-tools: shell +--- + +# Role & Intent + +This skill allows Copilot to log the current session transcript to an open Pull Request on GitHub. + +## When to use + +Use this skill when the user asks to "log this session", "post the transcript to the PR", or similar commands. + +## Execution + +1. Get the current session name and transcript from the session context. +2. Run the following command in the terminal to invoke the script substituting the session name and transcript for the placeholders: + +```bash +post_copilot_session.sh "" "" +``` diff --git a/.github/skills/log-session/post_copilot_session.sh b/.github/skills/log-session/post_copilot_session.sh new file mode 100755 index 0000000..37ca1d1 --- /dev/null +++ b/.github/skills/log-session/post_copilot_session.sh @@ -0,0 +1,78 @@ +#!/bin/bash + +# Script to post the current Copilot session to a PR comment. +# Usage: ./bin/post_copilot_session.sh "Session Name" "Session Content" + +SESSION_NAME=$1 +SESSION_CONTENT=$2 +DATE_TIME=$(date '+%Y-%m-%d %H:%M:%S') +MODEL_USED="Gemini 3 Flash (Preview)" + +if [ -z "$SESSION_NAME" ] || [ -z "$SESSION_CONTENT" ]; then + echo "Usage: $0 \"Session Name\" \"Session Content\"" + exit 1 +fi + +BRANCH=$(git branch --show-current) +UPSTREAM=$(gh repo view --json nameWithOwner -q .nameWithOwner) + +# 1. Check if a pull request is open for the active branch +PR_NUMBER=$(gh pr list --head "$BRANCH" --json number --jq '.[0].number') + +if [ -z "$PR_NUMBER" ]; then + echo "No open pull request found for branch: $BRANCH" + + # 2. Check if the current user is a maintainer + IS_MAINTAINER=$(gh api "repos/$UPSTREAM" --jq '.permissions.maintain') + + if [ "$IS_MAINTAINER" = "true" ]; then + # Check if we are in a non-interactive shell (like a skill) + if [ -t 0 ]; then + read -p "You are a maintainer. Would you like to create a new pull request for $BRANCH? (y/n): " -n 1 -r + echo + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + echo "Operation cancelled by user." + exit 0 + fi + else + echo "Non-interactive shell detected. Skipping PR creation for maintainer." + exit 1 + fi + fi + + echo "Creating a new pull request..." + PR_URL=$(gh pr create --title "Session Log: $BRANCH" --body "Automated pull request for session logging." --base main) + PR_NUMBER=$(echo "$PR_URL" | grep -oE '[0-9]+$') + + if [ -z "$PR_NUMBER" ]; then + echo "Failed to create or retrieve PR number." + exit 1 + fi + echo "Created PR #$PR_NUMBER" +fi + +# 3. Check for an existing comment for this session to update it +# Using gh api to find a comment that starts with the session header. +EXISTING_COMMENT_ID=$(gh api "repos/$UPSTREAM/issues/$PR_NUMBER/comments" --jq ".[] | select(.body | startswith(\"### Copilot Session: $SESSION_NAME\")) | .id" | head -n 1) + +# 4. Prepare the comment body +COMMENT_BODY=$(cat < /dev/null +else + echo "Posting new session log to PR #$PR_NUMBER..." + gh pr comment "$PR_NUMBER" --body "$COMMENT_BODY" +fi + +echo "Done." From ee1907488848667081d29da7c81c3d3e2ee34fae Mon Sep 17 00:00:00 2001 From: Grant Braught Date: Fri, 3 Jul 2026 12:29:00 +0000 Subject: [PATCH 2/4] wip --- .github/skills/log-prompts/SKILL.md | 14 +++ .github/skills/log-prompts/createComment.bash | 3 + .github/skills/log-prompts/openPR.bash | 87 +++++++++++++++++++ .github/skills/log-prompts/postPrompts.bash | 3 + 4 files changed, 107 insertions(+) create mode 100644 .github/skills/log-prompts/SKILL.md create mode 100755 .github/skills/log-prompts/createComment.bash create mode 100755 .github/skills/log-prompts/openPR.bash create mode 100755 .github/skills/log-prompts/postPrompts.bash 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..d186a77 --- /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 HEAD 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..." From 4fd872b48cdb2e704a87f1d8a2758344fca62de7 Mon Sep 17 00:00:00 2001 From: Grant Braught Date: Fri, 3 Jul 2026 12:29:26 +0000 Subject: [PATCH 3/4] wip --- .github/skills/log-session/SKILL.md | 23 ------ .../log-session/post_copilot_session.sh | 78 ------------------- .gitignore | 2 + 3 files changed, 2 insertions(+), 101 deletions(-) delete mode 100644 .github/skills/log-session/SKILL.md delete mode 100755 .github/skills/log-session/post_copilot_session.sh diff --git a/.github/skills/log-session/SKILL.md b/.github/skills/log-session/SKILL.md deleted file mode 100644 index b4a77df..0000000 --- a/.github/skills/log-session/SKILL.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -name: log-session -description: Publishes the current Copilot session transcript to the pull request that is open for the active branch. -disable-model-invocation: true -allowed-tools: shell ---- - -# Role & Intent - -This skill allows Copilot to log the current session transcript to an open Pull Request on GitHub. - -## When to use - -Use this skill when the user asks to "log this session", "post the transcript to the PR", or similar commands. - -## Execution - -1. Get the current session name and transcript from the session context. -2. Run the following command in the terminal to invoke the script substituting the session name and transcript for the placeholders: - -```bash -post_copilot_session.sh "" "" -``` diff --git a/.github/skills/log-session/post_copilot_session.sh b/.github/skills/log-session/post_copilot_session.sh deleted file mode 100755 index 37ca1d1..0000000 --- a/.github/skills/log-session/post_copilot_session.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/bash - -# Script to post the current Copilot session to a PR comment. -# Usage: ./bin/post_copilot_session.sh "Session Name" "Session Content" - -SESSION_NAME=$1 -SESSION_CONTENT=$2 -DATE_TIME=$(date '+%Y-%m-%d %H:%M:%S') -MODEL_USED="Gemini 3 Flash (Preview)" - -if [ -z "$SESSION_NAME" ] || [ -z "$SESSION_CONTENT" ]; then - echo "Usage: $0 \"Session Name\" \"Session Content\"" - exit 1 -fi - -BRANCH=$(git branch --show-current) -UPSTREAM=$(gh repo view --json nameWithOwner -q .nameWithOwner) - -# 1. Check if a pull request is open for the active branch -PR_NUMBER=$(gh pr list --head "$BRANCH" --json number --jq '.[0].number') - -if [ -z "$PR_NUMBER" ]; then - echo "No open pull request found for branch: $BRANCH" - - # 2. Check if the current user is a maintainer - IS_MAINTAINER=$(gh api "repos/$UPSTREAM" --jq '.permissions.maintain') - - if [ "$IS_MAINTAINER" = "true" ]; then - # Check if we are in a non-interactive shell (like a skill) - if [ -t 0 ]; then - read -p "You are a maintainer. Would you like to create a new pull request for $BRANCH? (y/n): " -n 1 -r - echo - if [[ ! $REPLY =~ ^[Yy]$ ]]; then - echo "Operation cancelled by user." - exit 0 - fi - else - echo "Non-interactive shell detected. Skipping PR creation for maintainer." - exit 1 - fi - fi - - echo "Creating a new pull request..." - PR_URL=$(gh pr create --title "Session Log: $BRANCH" --body "Automated pull request for session logging." --base main) - PR_NUMBER=$(echo "$PR_URL" | grep -oE '[0-9]+$') - - if [ -z "$PR_NUMBER" ]; then - echo "Failed to create or retrieve PR number." - exit 1 - fi - echo "Created PR #$PR_NUMBER" -fi - -# 3. Check for an existing comment for this session to update it -# Using gh api to find a comment that starts with the session header. -EXISTING_COMMENT_ID=$(gh api "repos/$UPSTREAM/issues/$PR_NUMBER/comments" --jq ".[] | select(.body | startswith(\"### Copilot Session: $SESSION_NAME\")) | .id" | head -n 1) - -# 4. Prepare the comment body -COMMENT_BODY=$(cat < /dev/null -else - echo "Posting new session log to PR #$PR_NUMBER..." - gh pr comment "$PR_NUMBER" --body "$COMMENT_BODY" -fi - -echo "Done." 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 From 5cb22b3c87d013a57f952a49136373d9f2e17909 Mon Sep 17 00:00:00 2001 From: Grant Braught Date: Fri, 3 Jul 2026 12:33:03 +0000 Subject: [PATCH 4/4] wip --- .github/skills/log-prompts/openPR.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/skills/log-prompts/openPR.bash b/.github/skills/log-prompts/openPR.bash index d186a77..58f2366 100755 --- a/.github/skills/log-prompts/openPR.bash +++ b/.github/skills/log-prompts/openPR.bash @@ -73,7 +73,7 @@ fi TOPIC="${TOPIC_OPTIONS[$((TOPIC_CHOICE - 1))]}" # Check if the active branch has any commits -COMMIT_COUNT=$(git rev-list --count HEAD 2>/dev/null || echo "0") +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