Skip to content

Commit a7affe9

Browse files
committed
incremental updates
1 parent 62cca0d commit a7affe9

File tree

4 files changed

+106
-56
lines changed

4 files changed

+106
-56
lines changed

0-paths.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,4 @@ export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"
5959

6060
# to fix Library not loaded: @rpath/libllama.dylib
6161
export PATH="${HOME}/git/llama.cpp/bin:$PATH"
62+

16-ai.rc

Lines changed: 87 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ alias clinerulesd="cd /Users/samm/Library/Mobile\ Documents/com\~apple\~CloudDoc
99
alias sync_ollama_models="${HOME}/git/sammcj/scripts/ollama/export_ollama_model.py"
1010
alias '???'='copilot-comments'
1111
alias wtf='copilot'
12-
alias l="OLLAMA_HOST=http://localhost:11434 gollama -l"
12+
# alias l="OLLAMA_HOST=http://localhost:11434 gollama -l"
1313
alias i="ingest"
1414
alias code2prompt="ingest"
15-
alias ln="gollama -l"
15+
# alias ln="gollama -l"
1616
alias gl="gollama"
1717
alias ol="mods"
1818
alias idf='. $HOME/git/esp-idf/export.sh'
@@ -53,57 +53,91 @@ function claude_helper_exec {
5353
"$prompt" | bat --squeeze-blank --language=bash --theme Dracula --style=plain --paging=never
5454
}
5555

56-
57-
58-
copilot-comments() {
59-
# Function to list and display comments made by GitHub Copilot on the current PR
60-
local -r current_branch="$(git branch --show-current 2>/dev/null)" || {
61-
printf "Error: Not in a git repository or no current branch\n" >&2
62-
return 1
63-
}
64-
65-
local base_branch pr_num general_reviews inline_comments all_prs
66-
67-
# Use printf instead of echo for better portability and consistency
68-
base_branch="$(gh repo view --json defaultBranch --jq '.defaultBranch.name' 2>/dev/null)" || base_branch="main"
69-
pr_num="$(gh pr list --head "${current_branch}" --base "${base_branch}" --json number --jq '.[0].number' 2>/dev/null)" || pr_num=""
70-
71-
if [[ -z "${pr_num}" || "${pr_num}" == "null" ]]; then
72-
printf "No open PR found for current branch %s\n" "${current_branch}"
73-
74-
if all_prs="$(gh pr list --base "${base_branch}" --json number,title,headRefName --jq '.[] | "PR #\(.number): \(.title) (branch: \(.headRefName))"' 2>/dev/null)" && [[ -n "${all_prs}" ]]; then
75-
printf "All open PRs to %s:\n%s\n" "${base_branch}" "${all_prs}"
76-
fi
77-
return 1
78-
fi
79-
80-
# Helper function to reduce code duplication
81-
_fetch_copilot_data() {
82-
local -r endpoint="$1"
83-
local -r jq_filter="$2"
84-
gh api "repos/:owner/:repo/pulls/${pr_num}/${endpoint}" 2>/dev/null | jq -r "${jq_filter}" 2>/dev/null || true
85-
}
86-
87-
general_reviews="$(_fetch_copilot_data "reviews" '.[] | select(.user.login == "Copilot") | .body')"
88-
inline_comments="$(_fetch_copilot_data "comments" '.[] | select(.user.login == "Copilot") | "\(.path) (line \(.line))\n\(.body)\n" + ("=" * 50) + "\n"')"
89-
90-
if [[ -n "${general_reviews}" || -n "${inline_comments}" ]]; then
91-
printf "I submitted the changes to Github Copilot to review, keep in mind that Github Copilot doesn't use a very strong AI model so it may not be accurate.\n"
92-
93-
printf "🤖 GitHub Copilot comments on PR #%s:\n" "${pr_num}"
94-
95-
if [[ -n "${general_reviews}" ]]; then
96-
printf "## Copilot review comments\n"
97-
printf "%s\n" "${general_reviews}\n------\n"
98-
fi
99-
100-
if [[ -n "${inline_comments}" ]]; then
101-
printf "\n## Copilot inline comments\n"
102-
printf "%s\n" "${inline_comments}"
103-
fi
104-
105-
printf "⚠️ Be mindful that GitHub Copilot's comments may be inaccurate. Ignore any invalid or out of context comments. Please review them carefully before applying any changes. Discuss recommendations with me if the path forward is unclear.\n"
106-
fi
56+
copilot-comments () {
57+
# Fetches unresolved GitHub Copilot comments for the current branch's PR, useful for piping to pbcopy and providing to Claude Code etc.
58+
local -r current_branch="$(git branch --show-current 2>/dev/null)" || {
59+
printf "Error: Not in a git repository or no current branch\n" >&2
60+
return 1
61+
}
62+
local base_branch pr_num general_reviews inline_comments all_prs owner repo
63+
64+
base_branch="$(gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name' 2>/dev/null)" || base_branch="main"
65+
pr_num="$(gh pr list --head "${current_branch}" --base "${base_branch}" --json number --jq '.[0].number' 2>/dev/null)" || pr_num=""
66+
67+
if [[ -z "${pr_num}" || "${pr_num}" == "null" ]]
68+
then
69+
printf "No open PR found for current branch %s\n" "${current_branch}"
70+
if all_prs="$(gh pr list --base "${base_branch}" --json number,title,headRefName --jq '.[] | "PR #\(.number): \(.title) (branch: \(.headRefName))"' 2>/dev/null)" && [[ -n "${all_prs}" ]]
71+
then
72+
printf "All open PRs to %s:\n%s\n" "${base_branch}" "${all_prs}"
73+
fi
74+
return 1
75+
fi
76+
77+
# Get owner and repo for GraphQL query
78+
owner="$(gh repo view --json owner --jq '.owner.login' 2>/dev/null)"
79+
repo="$(gh repo view --json name --jq '.name' 2>/dev/null)"
80+
81+
# Fetch general review comments (these don't have resolved status)
82+
general_reviews="$(gh api "repos/:owner/:repo/pulls/${pr_num}/reviews" 2>/dev/null | jq -r '.[] | select(.user.login == "copilot-pull-request-reviewer" or .user.login == "Copilot") | .body' 2>/dev/null || true)"
83+
84+
# Fetch unresolved inline comments using GraphQL
85+
inline_comments="$(gh api graphql -f query='
86+
query($owner: String!, $repo: String!, $pr: Int!) {
87+
repository(owner: $owner, name: $repo) {
88+
pullRequest(number: $pr) {
89+
reviewThreads(first: 100) {
90+
nodes {
91+
isResolved
92+
comments(first: 100) {
93+
nodes {
94+
author {
95+
login
96+
}
97+
body
98+
path
99+
line
100+
}
101+
}
102+
}
103+
}
104+
}
105+
}
106+
}
107+
' -F owner="${owner}" -F repo="${repo}" -F pr="${pr_num}" 2>/dev/null | \
108+
jq -r '
109+
.data.repository.pullRequest.reviewThreads.nodes[] |
110+
select(.isResolved == false) |
111+
.comments.nodes[] |
112+
select(.author.login == "copilot-pull-request-reviewer" or .author.login == "Copilot") |
113+
if .line then
114+
"\(.path) (line \(.line))\n\(.body)\n" + ("=" * 50) + "\n"
115+
else
116+
"\(.path)\n\(.body)\n" + ("=" * 50) + "\n"
117+
end
118+
' 2>/dev/null || true)"
119+
120+
if [[ -n "${general_reviews}" || -n "${inline_comments}" ]]
121+
then
122+
printf "I submitted the changes to Github Copilot to review, keep in mind that Github Copilot doesn't use a very strong AI model so it may not be accurate.\n"
123+
printf "🤖 GitHub Copilot comments on PR #%s (unresolved only):\n\n" "${pr_num}"
124+
125+
if [[ -n "${general_reviews}" ]]
126+
then
127+
printf "## Copilot review comments\n"
128+
printf "%s\n\n------\n\n" "${general_reviews}"
129+
fi
130+
131+
if [[ -n "${inline_comments}" ]]
132+
then
133+
printf "## Copilot inline comments\n"
134+
printf "%s\n" "${inline_comments}"
135+
fi
136+
137+
printf "⚠️ Be mindful that GitHub Copilot's comments may be inaccurate. Ignore any invalid or out of context comments. Please review them carefully before applying any changes. Discuss recommendations with me if the path forward is unclear.\n"
138+
else
139+
printf "No unresolved Copilot comments found on PR #%s\n" "${pr_num}"
140+
fi
107141
}
108142

109143

4-aliases.rc

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ alias tree="tree -ChF"
8686
alias mtr="sudo mtr"
8787
alias iftop="sudo iftop -i en0"
8888
alias ls='gls --color=auto -AHhF --group-directories-first'
89-
alias updatedb='sudo /usr/libexec/locate.updatedb'
89+
alias updatedb='/Users/samm/bin/updatedb-macos.sh'
90+
alias locate='locate -d ~/.locatedb'
9091
alias netwatch='lsof -i'
9192
alias flushdns='sudo discoveryutil udnsflushcaches'
9293
alias httpserver='sudo python3 -m http.server 80'
@@ -111,7 +112,15 @@ alias kubes-busybox='kubectl run -i --tty loader --image=busybox /bin/sh'
111112
alias k='kubectl'
112113

113114
# VSC
114-
alias code='/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code'
115+
# alias code='/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code'
116+
# TODO: Working around vscode / macOS broken sandbox - temporarily replace this with a function that opens '/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code' if it exists, otherwise it opens '/Applications/Visual\ Studio\ Code 2.app/Contents/Resources/app/bin/code'
117+
function code() {
118+
if [ -f /Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code ]; then
119+
/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code "$@"
120+
else
121+
/Applications/Visual\ Studio\ Code\ 2.app/Contents/Resources/app/bin/code "$@"
122+
fi
123+
}
115124

116125
# Merge two files with diff
117126
alias merge='diff --line-format %L'
@@ -131,6 +140,7 @@ alias dnsbenchmark='dnstrace -n 10 -c 10 --server 192.168.0.1 --recurse microsof
131140
# alias docker='colima'
132141

133142
alias youtube-dl='yt-dlp'
143+
alias yt-dlp='yt-dlp --cookies-from-browser firefox --remote-components ejs:github -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best"'
134144

135145
alias nvm='echo I think you meant FNM'
136146

@@ -194,10 +204,12 @@ alias ender='cd ~/git/sammcj/ender-configs/ && code .'
194204
alias rotate='tweaker3 -vb -x -i'
195205
alias rotate_min_supports='tweaker3 -vb -x -min sur -i'
196206

197-
alias obsidian='cd /Users/samm/Library/Mobile\ Documents/iCloud~md~obsidian/Documents/Main && ls -ltarh'
207+
alias obsidian='cd /Users/samm/Obsidian/Main && ls -ltarh'
208+
alias obs=obsidian
198209

199210
# uv
200211
alias venv='uv venv ; source .venv/bin/activate'
201212

202213
### AWS ###
203214
alias aws-rds-list-instances="aws rds describe-db-instances --region ap-southeast-2 --query \"DBInstances[].{Instance: DBInstanceIdentifier, Class: DBInstanceClass, Endpoint: Endpoint.Address, Status: DBInstanceStatus}\" --output text | sed -r 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g'"
215+

5-exports.rc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,6 @@ export LIBRARY_PATH="/opt/homebrew/lib:$LIBRARY_PATH"
6868
export LD_LIBRARY_PATH="/opt/homebrew/lib:$LD_LIBRARY_PATH"
6969
export DYLD_FALLBACK_LIBRARY_PATH="/opt/homebrew/lib:$DYLD_FALLBACK_LIBRARY_PATH"
7070
export FFMPEG_DIR="/opt/homebrew/opt/ffmpeg"
71+
72+
# Custom user locate path
73+
export LOCATE_PATH="$HOME/.locatedb"

0 commit comments

Comments
 (0)