From ab5d515c702fceb1e0b0de40d44007b3bf124e64 Mon Sep 17 00:00:00 2001 From: Grant Braught Date: Wed, 1 Jul 2026 18:55:11 +0000 Subject: [PATCH 1/7] 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/7] 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/7] 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/7] 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 From b250803bdadfe5360284e28ffe219291957c85b1 Mon Sep 17 00:00:00 2001 From: Grant Braught Date: Fri, 3 Jul 2026 12:55:13 +0000 Subject: [PATCH 5/7] completes OpenPR script Assisted-by Claude Haiku 4.5: --- .cspell.json | 2 ++ .github/skills/log-prompts/openPR.bash | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.cspell.json b/.cspell.json index a9e8d9f..2bf7a11 100644 --- a/.cspell.json +++ b/.cspell.json @@ -4,6 +4,7 @@ "files": [ "**/*.{js,vue,md,html,css,bash}", ".github/**/*.md", + ".github/skills/**/*.bash", ".devcontainer/**/*.bash" ], "ignorePaths": [ @@ -28,6 +29,7 @@ "prettier", "setsid", "streetsidesoftware", + "toplevel", "vite", "vitejs", "vuejs", diff --git a/.github/skills/log-prompts/openPR.bash b/.github/skills/log-prompts/openPR.bash index 58f2366..f9fe6fa 100755 --- a/.github/skills/log-prompts/openPR.bash +++ b/.github/skills/log-prompts/openPR.bash @@ -1,5 +1,7 @@ #!/bin/bash +REPO_ROOT=$(git rev-parse --show-toplevel) + # Get the current branch name CURRENT_BRANCH=$(git branch --show-current) @@ -29,7 +31,7 @@ if [[ ! $REPLY =~ ^[Yy]$ ]]; then fi # Read PULL_REQUEST_TEMPLATE.md and extract options dynamically -TEMPLATE_FILE="../../PULL_REQUEST_TEMPLATE.md" +TEMPLATE_FILE="$REPO_ROOT/.github/PULL_REQUEST_TEMPLATE.md" if [ ! -f "$TEMPLATE_FILE" ]; then echo "Error: $TEMPLATE_FILE not found" @@ -84,4 +86,8 @@ 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 +# Read the PULL_REQUEST_TEMPLATE and check the selected Type of Work and Topic +PR_BODY=$(cat "$TEMPLATE_FILE" | sed "s/- \[ \] - $TYPE_OF_WORK/- [X] - $TYPE_OF_WORK/" | sed "s/- \[ \] - $TOPIC/- [X] - $TOPIC/") + +git push upstream "$CURRENT_BRANCH" +gh pr create --base main --head "$CURRENT_BRANCH" --title "$PR_TITLE" --body "$PR_BODY" \ No newline at end of file From ab3595d80bdd6482a45d5c3f48f7d1291601bb81 Mon Sep 17 00:00:00 2001 From: Grant Braught Date: Fri, 3 Jul 2026 12:57:05 +0000 Subject: [PATCH 6/7] makes user press enter after y --- .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 f9fe6fa..5a26427 100755 --- a/.github/skills/log-prompts/openPR.bash +++ b/.github/skills/log-prompts/openPR.bash @@ -22,7 +22,7 @@ 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 +read -p "Do you want to create a pull request? (y/n) " -r echo "" if [[ ! $REPLY =~ ^[Yy]$ ]]; then From 2233da571241cf7f0507d9422f74de80a9cc7ac2 Mon Sep 17 00:00:00 2001 From: Grant Braught Date: Fri, 3 Jul 2026 16:54:35 +0000 Subject: [PATCH 7/7] wip --- .github/skills/log-prompts/SKILL.md | 12 ++- .github/skills/log-prompts/createComment.bash | 87 ++++++++++++++++++- .../skills/log-prompts/processChatJson.bash | 2 + .../skills/log-prompts/processChatLog.bash | 23 +++++ .github/skills/log-prompts/tmp | 9 ++ 5 files changed, 128 insertions(+), 5 deletions(-) create mode 100644 .github/skills/log-prompts/processChatJson.bash create mode 100755 .github/skills/log-prompts/processChatLog.bash create mode 100644 .github/skills/log-prompts/tmp diff --git a/.github/skills/log-prompts/SKILL.md b/.github/skills/log-prompts/SKILL.md index ce5266e..9bb6643 100644 --- a/.github/skills/log-prompts/SKILL.md +++ b/.github/skills/log-prompts/SKILL.md @@ -8,7 +8,11 @@ The user will run this skill when they want to log the prompts in the active cha ## 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. +1. Do not think or reason, follow these instructions exactly. +2. If the chat window is empty, end this skill and do not log any prompts to the pull request. +3. Use the VSCode command `workbench.action.chat.export` to export the chat as json into `/var/tmp/chat-log.json`. +4. Stop. + + + + diff --git a/.github/skills/log-prompts/createComment.bash b/.github/skills/log-prompts/createComment.bash index d32b676..1305b64 100755 --- a/.github/skills/log-prompts/createComment.bash +++ b/.github/skills/log-prompts/createComment.bash @@ -1,3 +1,88 @@ #!/bin/bash -echo "Creating Prompt Log comment for pull request..." +# 1. Find the open pull request to the upstream for the active branch. +CURRENT_BRANCH=$(git branch --show-current) +PR_INFO=$(gh pr list --head "$CURRENT_BRANCH" --state open --json number,url --jq '.[0]') + +if [[ -z "$PR_INFO" || "$PR_INFO" == "null" ]]; then + echo "No open pull request found for branch '$CURRENT_BRANCH'." + echo "Please create a pull request before running this skill." + exit 1 +fi + +PR_NUMBER=$(echo "$PR_INFO" | jq -r '.number') +CHAT_FILE="$(dirname "$0")/chat.txt" + +if [[ ! -f "$CHAT_FILE" ]]; then + echo "Error: $CHAT_FILE not found." + exit 1 +fi + +# 2. Find all comments on the pull request that have the heading "Copilot Chat Log". +# We use the GitHub CLI to get all comments. +COMMENTS=$(gh pr view "$PR_NUMBER" --json comments --jq '.comments') + +# Function to extract User prompts from a comment body +get_user_prompts() { + echo "$1" | grep "^User:" +} + +# 3. Check if all "User:" prompts in existing "Copilot Chat Log" comments are in chat.txt +ALL_IN_CHAT=true +MATCHING_COMMENT_ID="" +MATCHING_COMMENT_BODY="" + +# We'll iterate through comments that have the heading +LOG_COMMENTS=$(echo "$COMMENTS" | jq -c '.[] | select(.body | startswith("# Copilot Chat Log"))') + +if [[ -z "$LOG_COMMENTS" ]]; then + ALL_IN_CHAT=false +else + # Check each log comment + while read -r comment; do + BODY=$(echo "$comment" | jq -r '.body') + URL=$(echo "$comment" | jq -r '.url') + # Extract numeric ID from URL (e.g., ...#issuecomment-123456) + ID=$(echo "$URL" | grep -oE "[0-9]+$") + + # Get all User lines from this comment + PROMPTS=$(get_user_prompts "$BODY") + + while read -r prompt; do + if [[ -n "$prompt" ]]; then + if ! grep -qF "$prompt" "$CHAT_FILE"; then + ALL_IN_CHAT=false + break 2 + fi + fi + done <<< "$PROMPTS" + + # If we reach here for this comment, it matches. + # We'll keep track of the last matching one to update it. + MATCHING_COMMENT_ID="$ID" + MATCHING_COMMENT_BODY="$BODY" + done <<< "$LOG_COMMENTS" +fi + +# 4. Update or Create +TIMESTAMP=$(date +"%Y-%m-%d %H:%M:%S %Z") +CHAT_CONTENT=$(cat "$CHAT_FILE") + +if [[ "$ALL_IN_CHAT" == "true" && -n "$MATCHING_COMMENT_ID" ]]; then + # We found a matching log, append/update it. + # The requirement says "append them to the comment". + # Usually this means refreshing the comment content to match the full chat history. + # We keep the original heading and timestamp if possible, or just overwrite. + # Let's preserve the original header and timestamp from the matching comment if we can. + HEADER_AND_TIME=$(echo "$MATCHING_COMMENT_BODY" | head -n 2) + NEW_BODY=$(printf "%s\n\n%s" "$HEADER_AND_TIME" "$CHAT_CONTENT") + + gh api -X PATCH "repos/{owner}/{repo}/issues/comments/$MATCHING_COMMENT_ID" -f body="$NEW_BODY" > /dev/null + echo "Updated existing Copilot Chat Log comment ($MATCHING_COMMENT_ID)." +else + # Add a new "Copilot Chat Log" comment. + NEW_BODY=$(printf "# Copilot Chat Log\n%s\n\n%s" "$TIMESTAMP" "$CHAT_CONTENT") + gh pr comment "$PR_NUMBER" --body "$NEW_BODY" + echo "Created new Copilot Chat Log comment." +fi + diff --git a/.github/skills/log-prompts/processChatJson.bash b/.github/skills/log-prompts/processChatJson.bash new file mode 100644 index 0000000..05a7907 --- /dev/null +++ b/.github/skills/log-prompts/processChatJson.bash @@ -0,0 +1,2 @@ +#!/bin/bash + diff --git a/.github/skills/log-prompts/processChatLog.bash b/.github/skills/log-prompts/processChatLog.bash new file mode 100755 index 0000000..f67e335 --- /dev/null +++ b/.github/skills/log-prompts/processChatLog.bash @@ -0,0 +1,23 @@ +#!/bin/bash + +# Path to the chat log file +CHAT_FILE="$(dirname "$0")/chat.txt" + +# Check if the chat file exists +if [[ ! -f "$CHAT_FILE" ]]; then + echo "Error: $CHAT_FILE not found." + exit 1 +fi + +TEMP_FILE=$(mktemp) +# Extract prompts, removing "User:" prefix but adding/preserving "---" separator +awk '/^User:/ { + print "---"; + sub(/^User: */, ""); + print; + p=1; + next +} /^Assistant:/ {p=0} p' "$CHAT_FILE" > "$TEMP_FILE" +mv "$TEMP_FILE" "$CHAT_FILE" + +echo "Processed $CHAT_FILE: User prompts extracted and separators preserved." diff --git a/.github/skills/log-prompts/tmp b/.github/skills/log-prompts/tmp new file mode 100644 index 0000000..611af22 --- /dev/null +++ b/.github/skills/log-prompts/tmp @@ -0,0 +1,9 @@ + +IGNORE THE REMAINING INSTRUCTIONS IN THIS FILE. +3. From that content, extract ALL of the prompts entered by the user. Do not omit any prompts. +4. Place the prompts entered by the user into a text file named `chat.txt` in the `skills/log-prompts` directory. Do not include any copilot generated output in `chat.txt`. + - place a line containing `---` before each prompt. + - Replace the `chat.txt` file if it already exists. +5. Run the `openPR.bash` script in the terminal. +6. Run the `createComment.bash` script in the terminal. +7. Run the `postPrompts.bash` script in the terminal. \ No newline at end of file