-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathcomment-responder.js
More file actions
134 lines (126 loc) · 5.3 KB
/
Copy pathcomment-responder.js
File metadata and controls
134 lines (126 loc) · 5.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/**
* Auto-response generator for common learning room requests
* Triggered by issue comments with specific keywords
* Kept pure for testability
*/
function getAutoResponse(commentBody, author) {
const comment = (commentBody || '').toLowerCase();
const safeAuthor = author || 'friend';
// Help request
if (comment.includes('@bot help') || comment.includes('need help') || comment.includes('i\'m stuck')) {
return [
`Hi @${safeAuthor}! I am Gandalf, your workshop agent, here to bring a little magic to the interaction experience and keep it fun while you learn.`,
'',
'**Here are some helpful resources:**',
'',
'**Guides:**',
'- [Setup Guide](../docs/setup-guide.md)',
'- [Keyboard Shortcuts](../docs/keyboard-shortcuts.md)',
'- [Challenge Hub](../docs/CHALLENGES.md)',
'',
'**Common Questions:**',
'- **"How do I update my PR?"** Just make changes on your branch and push again.',
'- **"Why is the bot asking for X?"** Check the learning resources for explanations.',
'- **"I disagree with the bot"** No problem! Mention @facilitator and explain your reasoning.',
'',
'**Still stuck?** Mention `@facilitator` in a comment and they will help you.',
'',
'---',
'*Gandalf, Learning Room Bot*'
].join('\n');
}
// Merge conflict help
if (comment.includes('merge conflict') || comment.includes('conflict')) {
return [
`Hi @${safeAuthor}! Merge conflicts can be tricky, but this is a normal part of collaborative development.`,
'',
'**Quick steps to fix your conflict:**',
'',
'1. Click the **"Resolve conflicts"** button on your PR',
'2. GitHub will show you both versions side-by-side',
'3. **Delete the lines you don\'t want** (including the `<<<<<<<`, `=======`, `>>>>>>>` markers)',
'4. Keep only the version you want',
'5. Click **"Mark as resolved"**',
'6. **Commit the merge**',
'',
'**Need detailed steps?** See [Chapter 07: Merge Conflicts](https://github.com/Community-Access/git-going-with-github/blob/main/docs/07-merge-conflicts.md) in the course guide.',
'',
'**Screen reader tip:** If the web editor is hard to use, try pressing `.` on your PR page to open github.dev editor.',
'',
'---',
'*Gandalf, Learning Room Bot*'
].join('\n');
}
// Request review help
if ((comment.includes('how') && comment.includes('request review')) ||
comment.includes('request a review') ||
comment.includes('assign reviewer')) {
return [
`Hi @${safeAuthor}! To request a review, use the reviewer controls on your pull request. Here is how:`,
'',
'**In the GitHub UI:**',
'1. On your PR page, find the **"Reviewers"** section (right sidebar)',
'2. Click the **gear icon** ⚙️ next to "Reviewers"',
'3. Start typing a facilitator or peer username',
'4. Select them from the dropdown',
'5. They\'ll be notified automatically!',
'',
'**For screen reader users:**',
'Navigate to the complementary landmark (sidebar) and find the Reviewers heading. The gear icon activates the reviewer selector.',
'',
'**Pro tip:** Add a comment mentioning your reviewer so they see your message in their feed!',
'',
'---',
'*Gandalf, Learning Room Bot*'
].join('\n');
}
// Challenge/assignment help
if (comment.includes('what\'s next') || comment.includes('next challenge') || comment.includes('what should i work on')) {
return [
`Hi @${safeAuthor}! Great momentum.`,
'',
'**Here\'s where to find your next challenge:**',
'',
'1. Check the [Challenge Hub](./docs/CHALLENGES.md) in this repo',
'2. Look for issues labeled **"challenge"** in the Issues tab',
'3. Read the issue description to understand what you\'ll learn',
'4. Comment **"I\'d like to work on this challenge!"** to claim it',
'',
'**Challenge overview:**',
'- Challenges 01-09 are Day 1 (browser-based GitHub skills)',
'- Challenges 10-16 are Day 2 (VS Code, Git, Copilot, agents)',
'- Challenges A-E are bonus (optional, for extra depth)',
'',
'---',
'*Gandalf, Learning Room Bot*'
].join('\n');
}
// Claim challenge request
if (comment.includes('like to work on') || comment.includes('claim') || comment.includes('assign me')) {
return [
`Hi @${safeAuthor}! Excellent. Let us get you started.`,
'',
'**Here\'s what to do next:**',
'',
'1. **Create a new branch** for this work',
' - Use naming like: `fix/yourname-issue123`',
'2. **Make your edits** according to the challenge description',
'3. **Test your changes** (read through what you changed)',
'4. **Commit with a clear message** explaining what you fixed',
'5. **Push to GitHub**',
'6. **Open a PR** linking back to this issue with `Closes #ISSUE_NUMBER`',
'',
'[→ Full PR Guide](https://github.com/Community-Access/git-going-with-github/blob/main/docs/06-working-with-pull-requests.md)',
'',
'**Questions while you work?** Ask in this issue - no question is too small!',
'',
'---',
'*Gandalf, Learning Room Bot*'
].join('\n');
}
// No matching request
return null;
}
module.exports = {
getAutoResponse
};