@@ -86,6 +86,45 @@ generate_log_l_commands () {
8686 echo " $commands "
8787}
8888
89+ # Run copilot with standard tool permissions
90+ # Usage: run_copilot <prompt> [extra-tools...]
91+ # Outputs to stdout, also tees to stderr for logging
92+ # Returns copilot's exit code
93+ run_copilot () {
94+ local prompt=$1
95+ shift
96+
97+ local tools=(
98+ --allow-tool ' view'
99+ --allow-tool ' write'
100+ --allow-tool ' shell(git show)'
101+ --allow-tool ' shell(git diff)'
102+ --allow-tool ' shell(git log)'
103+ --allow-tool ' shell(git range-diff)'
104+ --allow-tool ' shell(git add)'
105+ --allow-tool ' shell(git grep)'
106+ --allow-tool ' shell(git rev-list)'
107+ --allow-tool ' shell(git checkout)'
108+ --allow-tool ' shell(grep)'
109+ --allow-tool ' shell(head)'
110+ --allow-tool ' shell(tail)'
111+ --allow-tool ' shell(sed)'
112+ --allow-tool ' shell(cat)'
113+ --allow-tool ' shell(awk)'
114+ )
115+
116+ # Add any extra tools passed as arguments
117+ local extra
118+ for extra in " $@ " ; do
119+ tools+=(--allow-tool " $extra " )
120+ done
121+
122+ copilot -p " $prompt " \
123+ ${COPILOT_MODEL: +--model " $COPILOT_MODEL " } \
124+ " ${tools[@]} " \
125+ 2>&1 | tee /dev/stderr
126+ }
127+
89128# Function to resolve a single conflict with AI
90129# Usage: resolve_conflict_with_ai [<tried-correspondences>]
91130resolve_conflict_with_ai () {
@@ -138,25 +177,7 @@ Decision rules:
138177Your FINAL line must be exactly: skip <oid>, continue, or fail"
139178
140179 echo " Invoking AI for conflict resolution..."
141- local ai_output=$( copilot -p " $prompt " \
142- ${COPILOT_MODEL: +--model " $COPILOT_MODEL " } \
143- --allow-tool ' view' \
144- --allow-tool ' edit' \
145- --allow-tool ' shell(git show)' \
146- --allow-tool ' shell(git diff)' \
147- --allow-tool ' shell(git log)' \
148- --allow-tool ' shell(git range-diff)' \
149- --allow-tool ' shell(git add)' \
150- --allow-tool ' shell(git grep)' \
151- --allow-tool ' shell(git rev-list)' \
152- --allow-tool ' shell(git checkout)' \
153- --allow-tool ' shell(grep)' \
154- --allow-tool ' shell(head)' \
155- --allow-tool ' shell(tail)' \
156- --allow-tool ' shell(sed)' \
157- --allow-tool ' shell(cat)' \
158- --allow-tool ' shell(awk)' \
159- 2>&1 | tee /dev/stderr)
180+ local ai_output=$( run_copilot " $prompt " )
160181 local ai_exit_code=$?
161182
162183 # Log the AI output in a collapsible group
@@ -227,7 +248,7 @@ SKIP_EOF
227248 continue)
228249 echo " ::notice::Resolved conflict surgically: $rebase_head_oneline "
229250 CONFLICTS_RESOLVED=$(( CONFLICTS_RESOLVED + 1 ))
230- git rebase --continue
251+ GIT_EDITOR=: git rebase --continue
231252
232253 # Verify build after surgical resolution
233254 echo " ::group::Verifying build"
@@ -250,15 +271,7 @@ $(tail -15 make.log)
250271Output 'continue' when fixed, or 'fail' if you cannot fix it.
251272Your FINAL line must be exactly: continue or fail"
252273
253- local retry_output=$( copilot -p " $retry_prompt " \
254- ${COPILOT_MODEL: +--model " $COPILOT_MODEL " } \
255- --allow-tool ' view' \
256- --allow-tool ' edit' \
257- --allow-tool ' shell(git show)' \
258- --allow-tool ' shell(git diff)' \
259- --allow-tool ' shell(git add)' \
260- --allow-tool ' shell(git commit --amend)' \
261- 2>&1 | tee /dev/stderr)
274+ local retry_output=$( run_copilot " $retry_prompt " ' shell(git commit --amend)' )
262275 local retry_exit_code=$?
263276
264277 echo " ::group::AI Retry Output"
@@ -384,7 +397,7 @@ Used resolution from: $(git show --no-patch --format=reference "$corresponding_o
384397
385398RESOLVED_EOF
386399 CONFLICTS_RESOLVED=$(( CONFLICTS_RESOLVED + 1 ))
387- git rebase --continue
400+ GIT_EDITOR=: git rebase --continue
388401 continue 2
389402 fi
390403 done
@@ -564,7 +577,10 @@ echo "Rebase completed: $(git rev-parse --short HEAD)"
564577cat " $REPORT_FILE "
565578echo " To push: git push --force origin $( git rev-parse HEAD) :$SHEARS_BRANCH "
566579
567- # For GitHub Actions: output report path
580+ # For GitHub Actions: output report path and write to job summary
568581if test -n " $GITHUB_OUTPUT " ; then
569582 echo " report=$REPORT_FILE " >> " $GITHUB_OUTPUT "
570583fi
584+ if test -n " $GITHUB_STEP_SUMMARY " ; then
585+ cat " $REPORT_FILE " >> " $GITHUB_STEP_SUMMARY "
586+ fi
0 commit comments