1- # AI Spam Guard 🛡️
1+ # AI Spam Guard
22
33An AI-powered GitHub Action that automatically detects and moderates spam in
44issues and comments using GitHub Models language models.
55
6- ## ✨ Recent Updates
7-
8- ** v2.0.0 - Major Refactoring**
9-
10- - 🔄 ** Migrated from OpenAI SDK to GitHub Models** for better integration with
11- GitHub ecosystem
12- - 🧩 ** Modular Architecture** : Extracted functionality into separate, testable
13- modules
14- - 🎯 ** Built-in Prompts** : No longer requires external prompt directory
15- configuration
16- - 🛠️ ** Improved Error Handling** : Better error messages and graceful failures
17- - 📦 ** TypeScript Improvements** : Better type safety and code organization
18-
19- ## Features
20-
21- - ** 🤖 GitHub Models Integration** : Uses GitHub's hosted AI models for accurate
22- spam and AI-generated content detection
23- - ** 🎯 Dual Detection** : Separate detection for generic spam and AI-generated
24- content
25- - ** 🏷️ Automatic Labeling** : Labels issues and comments with configurable labels
26- - ** 👻 Comment Minimization** : Automatically hides spam comments to reduce noise
27- - ** 📁 Modular Design** : Clean, maintainable code structure with separate
28- services
29- - ** 🧪 Comprehensive Testing** : Full test coverage for all modules
30-
31- ## Architecture
32-
33- The action is now organized into several focused modules:
34-
35- - ** ` PromptService ` ** : Handles loading YAML prompts and GitHub Models API
36- interactions
37- - ** ` GitHubService ` ** : Manages GitHub API operations (labeling, comment
38- minimization)
39- - ** ` ContentExtractor ` ** : Extracts content and metadata from GitHub webhook
40- events
41- - ** ` index.ts ` ** : Main orchestrator that coordinates all services
42-
436## Usage
447
458### Basic Setup
6629 models : read
6730 steps :
6831 - uses : actions/checkout@v4
69- - uses : your-org /ai-spam-guard@v2
32+ - uses : github /ai-spam-guard
7033 with :
7134 token : ${{ secrets.GITHUB_TOKEN }}
7235 spam-label : ' spam'
8649The action no longer requires external API keys - it uses the built-in GitHub
8750token with `models : read` permission to access GitHub Models.
8851
89- # # How It Works
90-
91- 1. **Event Trigger** : Action triggers on new issues, comments, or PR reviews
92- 2. **Content Extraction** : Extracts text content from the GitHub event
93- 3. **AI Analysis** : Sends content to GitHub Models with specialized prompts for
94- spam and AI detection
95- 4. **Action Taking** : Based on results, labels the issue/PR and/or minimizes
96- comments
97- 5. **Logging** : Provides detailed logs of detection results and actions taken
98-
9952# # Detection Prompts
10053
10154The action uses built-in YAML prompts located in the `prompts/` directory :
@@ -106,9 +59,12 @@ The action uses built-in YAML prompts located in the `prompts/` directory:
10659- **`bot-detection.prompt.yml`**: Identifies automated bot behavior
10760- **`link-spam-detection.prompt.yml`**: Focuses on suspicious links and URLs
10861
109- # # Development
62+ You can iterate on or tweak these prompts via the
63+ [Models tab](https://github.com/github/ai-spam-guard/models) on this repository.
64+ If you want to push an update to this prompt, please also include updated test
65+ data so we can see the effect of the prompt update.
11066
111- # ## Local Development
67+ # # Development
11268
11369` ` ` bash
11470# Install dependencies
@@ -135,18 +91,3 @@ npm run test
13591# Run tests in watch mode
13692npm run test:watch
13793` ` `
138-
139- # ## Module Structure
140-
141- ```
142- src/
143- ├── index.ts # Main orchestrator
144- ├── prompt-service.ts # GitHub Models integration & prompt handling
145- ├── github-service.ts # GitHub API operations
146- └── content-extractor.ts # Event content extraction
147-
148- __ tests__ /
149- ├── prompt-service.test.ts
150- ├── github-service.test.ts
151- └── content-extractor.test.ts
152- ```
0 commit comments