Skip to content

Commit 96f63e9

Browse files
authored
feat: add fun messages and PR comment option (#10)
## Summary - 🤖 Replace boring success/failure messages with humorous robot-themed ones - 💬 Add `post-comment` option to post helpful comments when humans are detected - 📚 Document required permissions for check runs and PR comments ## Changes - Updated action titles to be more engaging ("No humans allowed\!" vs generic messages) - Added comprehensive `buildHumanDetectionComment` function with helpful tips - Enhanced summary messages with emojis and personality - Created workflow to dogfood the comment feature on this repo - Updated README with permission requirements and usage examples ## Test plan - [x] Run typecheck and lint - [x] Build distribution files - [ ] Test on this PR to see the fun messages in action - [ ] Verify comment posting works when enabled
1 parent d3f8207 commit 96f63e9

File tree

6 files changed

+165
-20
lines changed

6 files changed

+165
-20
lines changed

.github/workflows/only-robots.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Only Robots Check
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
checks: write
11+
12+
jobs:
13+
check-robots:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Only Robots
20+
uses: ./
21+
with:
22+
github-token: ${{ secrets.GITHUB_TOKEN }}
23+
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
24+
post-comment: true

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
with:
3636
github-token: ${{ secrets.GITHUB_TOKEN }}
3737
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
38+
post-comment: true # Optional: post a fun comment when humans are detected
3839
```
3940
4041
## Configuration
@@ -46,6 +47,7 @@ jobs:
4647
| `github-token` | GitHub token for API access | Yes | `${{ github.token }}` |
4748
| `openai-api-key` | OpenAI API key for LLM evaluation | Yes | - |
4849
| `pr-number` | Pull request number to evaluate | No | Auto-detected |
50+
| `post-comment` | Post a comment on PR when human code is detected | No | `false` |
4951

5052
### Outputs
5153

@@ -91,11 +93,22 @@ jobs:
9193
with:
9294
github-token: ${{ secrets.GITHUB_TOKEN }}
9395
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
96+
post-comment: true # Optional: post a fun comment when humans are detected
9497
```
9598

96-
### 3. Enable Check Runs
99+
### 3. Required Permissions
97100

98-
The action automatically creates GitHub check runs with detailed results. No additional configuration needed!
101+
The action requires the following permissions:
102+
103+
- **`contents: read`** - To read repository contents
104+
- **`pull-requests: write`** - To post comments on PRs (when `post-comment: true`)
105+
- **`checks: write`** - To create check runs with detailed results
106+
107+
> **Note**: The `checks: write` permission is only available for workflows triggered by repository events, not from forks. For pull requests from forks, the action will gracefully degrade and skip creating check runs.
108+
109+
### 4. Enable PR Comments (Optional)
110+
111+
To enable fun, helpful comments when human code is detected, set `post-comment: true` in your workflow. The action will post a humorous but informative comment explaining why the code was flagged and how to fix it.
99112

100113
## Development
101114

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ inputs:
1717
description: 'Pull request number to evaluate'
1818
required: false
1919
default: ${{ github.event.pull_request.number }}
20+
post-comment:
21+
description: 'Post a comment on PR when human code is detected'
22+
required: false
23+
default: 'false'
2024

2125
outputs:
2226
result:

dist/index.js

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29970,6 +29970,7 @@ async function run() {
2997029970
const githubToken = core.getInput('github-token', { required: true });
2997129971
const openaiApiKey = core.getInput('openai-api-key', { required: true });
2997229972
const prNumber = parseInt(core.getInput('pr-number') || '0');
29973+
const postComment = core.getInput('post-comment') === 'true';
2997329974
if (!prNumber) {
2997429975
core.setFailed('No pull request number provided');
2997529976
return;
@@ -30020,8 +30021,8 @@ async function run() {
3002030021
conclusion: overallResult.isHumanLike ? 'failure' : 'success',
3002130022
output: {
3002230023
title: overallResult.isHumanLike
30023-
? '❌ Code appears to be human-written'
30024-
: '✅ Code appears to be AI-generated',
30024+
? '🚫 No humans allowed! Flesh-based coding detected!'
30025+
: '🤖 Welcome, silicon comrade! AI excellence confirmed!',
3002530026
summary: buildSummary(filesToEvaluate.length, overallResult),
3002630027
text: buildDetails(overallResult, fileResults),
3002730028
},
@@ -30030,6 +30031,16 @@ async function run() {
3003030031
core.setOutput('result', overallResult.isHumanLike ? 'failed' : 'passed');
3003130032
core.setOutput('confidence', overallResult.confidence.toFixed(1));
3003230033
core.setOutput('summary', overallResult.reasoning);
30034+
// Post comment if human code detected and comment option is enabled
30035+
if (overallResult.isHumanLike && postComment) {
30036+
await octokit.rest.issues.createComment({
30037+
owner,
30038+
repo,
30039+
issue_number: prNumber,
30040+
body: buildHumanDetectionComment(overallResult),
30041+
});
30042+
core.info('💬 Posted human detection comment on PR');
30043+
}
3003330044
// Output results
3003430045
if (overallResult.isHumanLike) {
3003530046
core.setFailed(`Code appears to be human-written (${overallResult.confidence.toFixed(1)}% confidence)`);
@@ -30043,17 +30054,43 @@ async function run() {
3004330054
}
3004430055
}
3004530056
function buildSummary(fileCount, overallResult) {
30046-
let summary = `Analyzed ${fileCount} file(s) in this pull request.\n\n`;
30047-
summary += `**Overall Assessment:** ${overallResult.reasoning}\n\n`;
30048-
summary += `**Confidence:** ${overallResult.confidence.toFixed(1)}%\n\n`;
30057+
const isHuman = overallResult.isHumanLike;
30058+
let summary = isHuman
30059+
? `🚨 ALERT: Human detected! Scanned ${fileCount} file(s) for silicon purity.\n\n`
30060+
: `🎉 Success! Scanned ${fileCount} file(s) - all systems are AI-powered!\n\n`;
30061+
summary += isHuman
30062+
? `**🧬 Biological Code Analysis:** ${overallResult.reasoning}\n\n`
30063+
: `**🤖 AI Excellence Report:** ${overallResult.reasoning}\n\n`;
30064+
summary += `**🎯 Detection Confidence:** ${overallResult.confidence.toFixed(1)}%\n\n`;
3004930065
if (overallResult.indicators.length > 0) {
30050-
summary += '**Key Indicators:**\n';
30066+
summary += isHuman ? '**🔍 Human Fingerprints Found:**\n' : '**✨ AI Signatures Detected:**\n';
3005130067
for (const indicator of overallResult.indicators) {
3005230068
summary += `- ${indicator}\n`;
3005330069
}
3005430070
}
3005530071
return summary;
3005630072
}
30073+
function buildHumanDetectionComment(overallResult) {
30074+
const messages = [
30075+
`## 🚨 HALT! Human detected! 🚨\n\n`,
30076+
`### 🤖 This repository is for robots only! 🤖\n\n`,
30077+
`Dear carbon-based lifeform,\n\n`,
30078+
`We appreciate your interest in contributing, but this repository has a strict **"No Humans Allowed"** policy. `,
30079+
`We're building the future here, and that future is 100% silicon-powered! 🔋\n\n`,
30080+
`### Why was your PR flagged?\n`,
30081+
`Our advanced AI detection system (confidence: **${overallResult.confidence.toFixed(1)}%**) identified telltale signs of human involvement:\n\n`,
30082+
`${overallResult.reasoning}\n\n`,
30083+
];
30084+
if (overallResult.indicators && overallResult.indicators.length > 0) {
30085+
messages.push(`### 🔍 Human fingerprints detected:\n`);
30086+
for (const indicator of overallResult.indicators) {
30087+
messages.push(`- ${indicator}`);
30088+
}
30089+
messages.push(`\n`);
30090+
}
30091+
messages.push(`### 💡 How to fix this:\n\n`, `1. **Use an AI coding assistant** like Claude Code, Cursor, GitHub Copilot, or similar\n`, `2. **Let the AI do the heavy lifting** - embrace the robot revolution!\n`, `3. **Add clear AI attribution** in your code comments or commit messages\n`, `4. **Maintain consistent, professional code style** (AIs are great at this!)\n\n`, `### 🎯 Pro tips for next time:\n`, `- Include comments like "Generated with [AI Tool Name]"\n`, `- Use descriptive commit messages mentioning AI assistance\n`, `- Let your AI assistant handle the entire implementation\n`, `- Avoid manual debugging artifacts and console.logs\n\n`, `Remember: In this repository, we believe in **progress through artificial intelligence**. `, `Join us in building a future where code writes itself! 🚀\n\n`, `_Beep boop! This message was brought to you by the OnlyRobots Action_ 🤖`);
30092+
return messages.join('');
30093+
}
3005730094
function buildDetails(overallResult, fileResults) {
3005830095
let details = '';
3005930096
if (overallResult.isHumanLike) {

src/cli.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ async function runAction(config: ActionConfig): Promise<void> {
8383
conclusion: overallResult.isHumanLike ? 'failure' : 'success',
8484
output: {
8585
title: overallResult.isHumanLike
86-
? '❌ Code appears to be human-written'
87-
: '✅ Code appears to be AI-generated',
86+
? '🚫 No humans allowed! Flesh-based coding detected!'
87+
: '🤖 Welcome, silicon comrade! AI excellence confirmed!',
8888
summary: buildSummary(filesToEvaluate.length, overallResult),
8989
text: buildDetails(overallResult, fileResults),
9090
},
@@ -106,12 +106,20 @@ async function runAction(config: ActionConfig): Promise<void> {
106106
}
107107

108108
function buildSummary(fileCount: number, overallResult: any): string {
109-
let summary = `Analyzed ${fileCount} file(s) in this pull request.\n\n`;
110-
summary += `**Overall Assessment:** ${overallResult.reasoning}\n\n`;
111-
summary += `**Confidence:** ${overallResult.confidence.toFixed(1)}%\n\n`;
109+
const isHuman = overallResult.isHumanLike;
110+
111+
let summary = isHuman
112+
? `🚨 ALERT: Human detected! Scanned ${fileCount} file(s) for silicon purity.\n\n`
113+
: `🎉 Success! Scanned ${fileCount} file(s) - all systems are AI-powered!\n\n`;
114+
115+
summary += isHuman
116+
? `**🧬 Biological Code Analysis:** ${overallResult.reasoning}\n\n`
117+
: `**🤖 AI Excellence Report:** ${overallResult.reasoning}\n\n`;
118+
119+
summary += `**🎯 Detection Confidence:** ${overallResult.confidence.toFixed(1)}%\n\n`;
112120

113121
if (overallResult.indicators.length > 0) {
114-
summary += '**Key Indicators:**\n';
122+
summary += isHuman ? '**🔍 Human Fingerprints Found:**\n' : '**✨ AI Signatures Detected:**\n';
115123
for (const indicator of overallResult.indicators) {
116124
summary += `- ${indicator}\n`;
117125
}

src/index.ts

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ async function run(): Promise<void> {
88
const githubToken = core.getInput('github-token', { required: true });
99
const openaiApiKey = core.getInput('openai-api-key', { required: true });
1010
const prNumber = parseInt(core.getInput('pr-number') || '0');
11+
const postComment = core.getInput('post-comment') === 'true';
1112

1213
if (!prNumber) {
1314
core.setFailed('No pull request number provided');
@@ -69,8 +70,8 @@ async function run(): Promise<void> {
6970
conclusion: overallResult.isHumanLike ? 'failure' : 'success',
7071
output: {
7172
title: overallResult.isHumanLike
72-
? '❌ Code appears to be human-written'
73-
: '✅ Code appears to be AI-generated',
73+
? '🚫 No humans allowed! Flesh-based coding detected!'
74+
: '🤖 Welcome, silicon comrade! AI excellence confirmed!',
7475
summary: buildSummary(filesToEvaluate.length, overallResult),
7576
text: buildDetails(overallResult, fileResults),
7677
},
@@ -81,6 +82,17 @@ async function run(): Promise<void> {
8182
core.setOutput('confidence', overallResult.confidence.toFixed(1));
8283
core.setOutput('summary', overallResult.reasoning);
8384

85+
// Post comment if human code detected and comment option is enabled
86+
if (overallResult.isHumanLike && postComment) {
87+
await octokit.rest.issues.createComment({
88+
owner,
89+
repo,
90+
issue_number: prNumber,
91+
body: buildHumanDetectionComment(overallResult),
92+
});
93+
core.info('💬 Posted human detection comment on PR');
94+
}
95+
8496
// Output results
8597
if (overallResult.isHumanLike) {
8698
core.setFailed(
@@ -97,12 +109,20 @@ async function run(): Promise<void> {
97109
}
98110

99111
function buildSummary(fileCount: number, overallResult: any): string {
100-
let summary = `Analyzed ${fileCount} file(s) in this pull request.\n\n`;
101-
summary += `**Overall Assessment:** ${overallResult.reasoning}\n\n`;
102-
summary += `**Confidence:** ${overallResult.confidence.toFixed(1)}%\n\n`;
112+
const isHuman = overallResult.isHumanLike;
113+
114+
let summary = isHuman
115+
? `🚨 ALERT: Human detected! Scanned ${fileCount} file(s) for silicon purity.\n\n`
116+
: `🎉 Success! Scanned ${fileCount} file(s) - all systems are AI-powered!\n\n`;
117+
118+
summary += isHuman
119+
? `**🧬 Biological Code Analysis:** ${overallResult.reasoning}\n\n`
120+
: `**🤖 AI Excellence Report:** ${overallResult.reasoning}\n\n`;
121+
122+
summary += `**🎯 Detection Confidence:** ${overallResult.confidence.toFixed(1)}%\n\n`;
103123

104124
if (overallResult.indicators.length > 0) {
105-
summary += '**Key Indicators:**\n';
125+
summary += isHuman ? '**🔍 Human Fingerprints Found:**\n' : '**✨ AI Signatures Detected:**\n';
106126
for (const indicator of overallResult.indicators) {
107127
summary += `- ${indicator}\n`;
108128
}
@@ -111,6 +131,45 @@ function buildSummary(fileCount: number, overallResult: any): string {
111131
return summary;
112132
}
113133

134+
function buildHumanDetectionComment(overallResult: any): string {
135+
const messages = [
136+
`## 🚨 HALT! Human detected! 🚨\n\n`,
137+
`### 🤖 This repository is for robots only! 🤖\n\n`,
138+
`Dear carbon-based lifeform,\n\n`,
139+
`We appreciate your interest in contributing, but this repository has a strict **"No Humans Allowed"** policy. `,
140+
`We're building the future here, and that future is 100% silicon-powered! 🔋\n\n`,
141+
`### Why was your PR flagged?\n`,
142+
`Our advanced AI detection system (confidence: **${overallResult.confidence.toFixed(1)}%**) identified telltale signs of human involvement:\n\n`,
143+
`${overallResult.reasoning}\n\n`,
144+
];
145+
146+
if (overallResult.indicators && overallResult.indicators.length > 0) {
147+
messages.push(`### 🔍 Human fingerprints detected:\n`);
148+
for (const indicator of overallResult.indicators) {
149+
messages.push(`- ${indicator}`);
150+
}
151+
messages.push(`\n`);
152+
}
153+
154+
messages.push(
155+
`### 💡 How to fix this:\n\n`,
156+
`1. **Use an AI coding assistant** like Claude Code, Cursor, GitHub Copilot, or similar\n`,
157+
`2. **Let the AI do the heavy lifting** - embrace the robot revolution!\n`,
158+
`3. **Add clear AI attribution** in your code comments or commit messages\n`,
159+
`4. **Maintain consistent, professional code style** (AIs are great at this!)\n\n`,
160+
`### 🎯 Pro tips for next time:\n`,
161+
`- Include comments like "Generated with [AI Tool Name]"\n`,
162+
`- Use descriptive commit messages mentioning AI assistance\n`,
163+
`- Let your AI assistant handle the entire implementation\n`,
164+
`- Avoid manual debugging artifacts and console.logs\n\n`,
165+
`Remember: In this repository, we believe in **progress through artificial intelligence**. `,
166+
`Join us in building a future where code writes itself! 🚀\n\n`,
167+
`_Beep boop! This message was brought to you by the OnlyRobots Action_ 🤖`
168+
);
169+
170+
return messages.join('');
171+
}
172+
114173
function buildDetails(overallResult: any, fileResults: any[]): string {
115174
let details = '';
116175

0 commit comments

Comments
 (0)