-
Notifications
You must be signed in to change notification settings - Fork 0
fix: consolidate actionable review feedback from PRs #4, #6, #13, #26 #42
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
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 | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,11 @@ name: PR Checks | |||||||
| on: | ||||||||
| pull_request: | ||||||||
| types: [opened, reopened, synchronize, edited] | ||||||||
|
|
||||||||
| permissions: | ||||||||
| contents: read | ||||||||
| pull-requests: write | ||||||||
|
|
||||||||
|
Comment on lines
+8
to
+9
|
||||||||
| pull-requests: write | |
| pull-requests: read | |
| issues: write |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,6 +11,7 @@ export class AutonomousAgent { | |||||||||||||||||||||||||||||||||
| private grokService: GrokService; | ||||||||||||||||||||||||||||||||||
| private config: AgentConfig; | ||||||||||||||||||||||||||||||||||
| private processedMentions: Set<string> = new Set(); | ||||||||||||||||||||||||||||||||||
| private static readonly MAX_PROCESSED_MENTIONS = 10000; | ||||||||||||||||||||||||||||||||||
| private isRunning: boolean = false; | ||||||||||||||||||||||||||||||||||
| private pollingIntervalId: NodeJS.Timeout | null = null; | ||||||||||||||||||||||||||||||||||
| private isProcessing: boolean = false; | ||||||||||||||||||||||||||||||||||
|
|
@@ -90,10 +91,19 @@ export class AutonomousAgent { | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| console.log(`\n📬 [${new Date().toLocaleTimeString()}] Found ${newMentions.length} new mention(s)!\n`); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // Process each mention | ||||||||||||||||||||||||||||||||||
| for (const mention of newMentions) { | ||||||||||||||||||||||||||||||||||
| await this.processMention(mention); | ||||||||||||||||||||||||||||||||||
| this.processedMentions.add(mention.post.id); | ||||||||||||||||||||||||||||||||||
| // Process mentions oldest-first (API returns newest first) to maintain | ||||||||||||||||||||||||||||||||||
| // chronological insertion order in the Set for proper pruning behavior | ||||||||||||||||||||||||||||||||||
| for (let i = newMentions.length - 1; i >= 0; i--) { | ||||||||||||||||||||||||||||||||||
| await this.processMention(newMentions[i]); | ||||||||||||||||||||||||||||||||||
| this.processedMentions.add(newMentions[i].post.id); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // Prune oldest entries (from beginning of Set) to prevent unbounded memory growth | ||||||||||||||||||||||||||||||||||
| // Sets maintain insertion order, so slice(0, excess) removes oldest entries | ||||||||||||||||||||||||||||||||||
| if (this.processedMentions.size > AutonomousAgent.MAX_PROCESSED_MENTIONS) { | ||||||||||||||||||||||||||||||||||
| const excess = this.processedMentions.size - AutonomousAgent.MAX_PROCESSED_MENTIONS; | ||||||||||||||||||||||||||||||||||
| const toDelete = Array.from(this.processedMentions).slice(0, excess); | ||||||||||||||||||||||||||||||||||
| toDelete.forEach(id => this.processedMentions.delete(id)); | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+102
to
+106
|
||||||||||||||||||||||||||||||||||
| // Sets maintain insertion order, so slice(0, excess) removes oldest entries | |
| if (this.processedMentions.size > AutonomousAgent.MAX_PROCESSED_MENTIONS) { | |
| const excess = this.processedMentions.size - AutonomousAgent.MAX_PROCESSED_MENTIONS; | |
| const toDelete = Array.from(this.processedMentions).slice(0, excess); | |
| toDelete.forEach(id => this.processedMentions.delete(id)); | |
| // Sets maintain insertion order, so we remove the first `excess` entries via the iterator | |
| if (this.processedMentions.size > AutonomousAgent.MAX_PROCESSED_MENTIONS) { | |
| const excess = this.processedMentions.size - AutonomousAgent.MAX_PROCESSED_MENTIONS; | |
| let removed = 0; | |
| for (const id of this.processedMentions) { | |
| if (removed >= excess) { | |
| break; | |
| } | |
| this.processedMentions.delete(id); | |
| removed += 1; | |
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,14 @@ | |
| */ | ||
| import { XThread, GrokAnalysis, AgentAction } from '../types/index.js'; | ||
|
|
||
| interface GrokApiResponse { | ||
| choices: Array<{ | ||
| message?: { | ||
| content?: string; | ||
| }; | ||
| }>; | ||
| } | ||
|
|
||
| export class GrokService { | ||
| private apiKey: string; | ||
| private simulationMode: boolean = false; | ||
|
|
@@ -59,7 +67,7 @@ export class GrokService { | |
| throw new Error(`Grok API error: ${response.status}`); | ||
| } | ||
|
|
||
| const data: any = await response.json(); | ||
| const data = await response.json() as GrokApiResponse; | ||
| const analysisText = data.choices[0]?.message?.content || ''; | ||
|
|
||
|
Comment on lines
+70
to
72
|
||
| // Use the mention post ID so replies target the specific post where the agent was mentioned | ||
|
|
||
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.
This workflow uses
github.rest.issues.addLabels/listLabelsForRepo, which requireissuesscope. The current permissions block omitsissues: write, so labeling can fail with insufficient permissions. Update permissions to includeissues: write(andpull-requests: readis sufficient forpulls.listFiles).