-
Notifications
You must be signed in to change notification settings - Fork 2
feat(ci): add AI Contribution Report workflow #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| name: AI Contribution Report | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| report: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Count AI-attributed commits | ||
| run: | | ||
| total=$(git log --oneline | wc -l | tr -d ' ') | ||
| cursor=$(git log --format="%B" | grep -i "co-author.*cursor" | wc -l | tr -d ' ') | ||
| claude=$(git log --format="%B" | grep -i "co-authored.*claude" | wc -l | tr -d ' ') | ||
| copilot=$(git log --format="%B" | grep -i "co-author.*copilot" | wc -l | tr -d ' ') | ||
| ai=$((cursor + claude + copilot)) | ||
| human=$((total - ai)) | ||
|
|
||
| echo "## AI Contribution Report" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "| Tool | Commits | Share |" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "|------|---------|-------|" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "| Cursor | $cursor | $(( cursor * 100 / total ))% |" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "| Claude | $claude | $(( claude * 100 / total ))% |" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "| Copilot | $copilot | $(( copilot * 100 / total ))% |" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "| **AI total** | **$ai** | **$(( ai * 100 / total ))%** |" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "| Human | $human | $(( human * 100 / total ))% |" >> "$GITHUB_STEP_SUMMARY" | ||
|
Comment on lines
+29
to
+33
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 nit (other): Integer division truncates each share, so the per-row percentages will not sum to 100% (e.g. three rows at 33% each show 99%). If exactness matters for the summary, compute the human share as 🤖 Generated by Astra |
||
| echo "| **Total** | **$total** | 100% |" >> "$GITHUB_STEP_SUMMARY" | ||
|
Comment on lines
+29
to
+34
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 minor (bug): Every if [ "$total" -eq 0 ]; then total=1; fi(or skip the percentage column when there are no commits). 🤖 Generated by Astra |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 minor (bug):
grep ... | wc -lcounts matching lines, whereastotalcounts commits. Two problems follow:Co-Authored-By: ClaudeandCo-authored-by: Cursor, which happens on hand-offs between tools) is counted once intotalbut once in each ofcursor/claude/copilot. That inflatesaiabove the true count of AI-attributed commits and makeshuman=$((total - ai))potentially negative, which then renders as a negative count and a negative percentage.grep -i "co-author.*cursor"matches on the whole commit body, so a prose mention (e.g. "discussed co-author roles with the Cursor team") is counted as a trailer.To count commits rather than trailer lines, and to anchor on the trailer, consider matching per-commit. For example, count commits whose body contains the trailer:
cursor=$(git log --format="%H %(trailers:key=Co-authored-by,valueonly)" | grep -ic "cursor")or iterate commits and grep each body once, so a commit is attributed at most once per tool.
🤖 Generated by Astra