{"id":29082406,"url":"https://github.com/benbalter/ai-community-moderator","last_synced_at":"2026-02-18T07:31:41.478Z","repository":{"id":300416822,"uuid":"1006110168","full_name":"benbalter/ai-community-moderator","owner":"benbalter","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-21T14:42:13.000Z","size":630,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-21T15:33:27.408Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benbalter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"patreon":"benbalter"}},"created_at":"2025-06-21T14:13:58.000Z","updated_at":"2025-06-21T14:25:36.000Z","dependencies_parsed_at":"2025-06-21T15:43:42.540Z","dependency_job_id":null,"html_url":"https://github.com/benbalter/ai-community-moderator","commit_stats":null,"previous_names":["benbalter/ai-community-moderator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/benbalter/ai-community-moderator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benbalter%2Fai-community-moderator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benbalter%2Fai-community-moderator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benbalter%2Fai-community-moderator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benbalter%2Fai-community-moderator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benbalter","download_url":"https://codeload.github.com/benbalter/ai-community-moderator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benbalter%2Fai-community-moderator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262326918,"owners_count":23294156,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-27T20:30:36.305Z","updated_at":"2025-10-01T15:59:09.887Z","avatar_url":"https://github.com/benbalter.png","language":null,"funding_links":["https://patreon.com/benbalter"],"categories":["Categories"],"sub_categories":["Continuous Moderation"],"readme":"# AI Community Moderator\n\nAn AI-powered GitHub Action that helps moderate community interactions by enforcing contributing guidelines and codes of conduct.\n\n## Table of Contents\n\n- [Features](#features)\n- [Getting Started](#getting-started)\n- [How it Works](#how-it-works)\n- [Configuration](#configuration)\n- [Examples](#examples)\n- [Moderation Actions](#moderation-actions)\n- [Permissions](#permissions)\n- [Community Health Files](#community-health-files)\n- [Inputs and Outputs](#inputs-and-outputs)\n- [Troubleshooting](#troubleshooting)\n- [FAQ](#faq)\n- [Security Considerations](#security-considerations)\n- [Limitations](#limitations)\n- [Development](#development)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Features\n\n- **Automated Moderation**: Uses GitHub Models with OpenAI GPT-4.1 to analyze issues, pull requests, discussions, and comments\n- **Context-Aware**: Leverages your repository's contributing guidelines and code of conduct\n- **Multiple Actions**: Can post helpful comments, hide inappropriate content, or lock discussions\n- **Configurable**: Adjustable severity thresholds and moderation actions\n- **Polite but Firm**: Maintains a helpful tone while enforcing community standards\n\n## Getting Started\n\n### Prerequisites\n\nBefore using the AI Community Moderator, ensure you have:\n\n1. **GitHub Models Access**: Your repository must have access to GitHub Models\n2. **Proper Permissions**: Your GitHub token needs the required permissions (see [Permissions](#permissions))\n3. **Community Guidelines**: While optional, having community health files enhances moderation accuracy\n\n### Quick Setup\n\n1. **Create a workflow file** in your repository at `.github/workflows/moderate.yml`:\n\n   ```yaml\n   name: AI Community Moderator\n\n   on:\n     issues:\n       types: [opened]\n     pull_request:\n       types: [opened]\n     issue_comment:\n       types: [created]\n     pull_request_review_comment:\n       types: [created]\n     discussion:\n       types: [created]\n     discussion_comment:\n       types: [created]\n\n   jobs:\n     moderate:\n       runs-on: ubuntu-latest\n       permissions:\n         contents: read\n         issues: write\n         pull-requests: write\n         discussions: write\n         models: read\n       steps:\n         - uses: benbalter/ai-community-moderator@v1\n           with:\n             github-token: ${{ secrets.GITHUB_TOKEN }}\n   ```\n\n2. **Commit and push** the workflow file to your repository\n\n3. **Test the setup** by creating a test issue or comment\n\n4. **Monitor the action** in your repository's Actions tab\n\n### Basic Configuration\n\nThe action works out of the box with default settings, but you can customize its behavior:\n\n```yaml\n- uses: benbalter/ai-community-moderator@v1\n  with:\n    github-token: ${{ secrets.GITHUB_TOKEN }}\n    severity-threshold: 5 # Adjust sensitivity (1-10)\n    model: openai/gpt-4.1 # Choose AI model\n```\n\n## How it Works\n\nThe AI Community Moderator follows this process for each community interaction:\n\n1. **Event Trigger**: Responds to issues, pull requests, comments, and discussions\n2. **Context Gathering**: Collects relevant information including:\n   - The content being moderated\n   - Repository community health files (CODE_OF_CONDUCT.md, CONTRIBUTING.md, etc.)\n   - Recent conversation history for context\n3. **AI Analysis**: Uses GitHub Models to analyze content against community standards\n4. **Decision Making**: Determines severity (1-10 scale) and appropriate action\n5. **Action Execution**: Takes appropriate moderation action based on severity threshold\n6. **Logging**: Records decisions and actions for transparency\n\n### AI Decision Process\n\nThe AI evaluates content based on:\n\n- **Community Guidelines**: Your repository's contributing guidelines and code of conduct\n- **Context**: Conversation history and interaction patterns\n- **Tone and Intent**: Whether content is constructive or harmful\n- **Policy Violations**: Spam, harassment, off-topic content, etc.\n\n## Usage\n\n## Configuration\n\n### Severity Threshold\n\nThe `severity-threshold` input controls when actions are taken. The AI rates content on a scale of 1-10:\n\n- **1-3**: Minor issues, usually no action taken\n- **4-6**: Moderate issues, may warrant educational comments\n- **7-8**: Significant issues, may require hiding content or suggestions\n- **9-10**: Severe violations, may require locking or limiting interactions\n\n**Examples:**\n\n- `severity-threshold: 3` = Strict moderation (takes action on minor issues)\n- `severity-threshold: 5` = Balanced moderation (default)\n- `severity-threshold: 8` = Lenient moderation (only acts on severe issues)\n\n### GitHub Models Configuration\n\nThis action uses GitHub Models for AI inference with automatic authentication:\n\n**Requirements:**\n\n1. Repository must have access to GitHub Models\n2. Workflow must include `models: read` permission\n3. Uses GitHub token for authentication with `https://models.github.ai/inference`\n\n**Supported Models:**\n\n- `openai/gpt-4.1` (default) - Most capable, slower\n- `openai/gpt-3.5-turbo` - Faster, less capable\n- Other OpenAI-compatible models supported by GitHub Models\n\n### Advanced Configuration\n\n```yaml\n- uses: benbalter/ai-community-moderator@v1\n  with:\n    github-token: ${{ secrets.GITHUB_TOKEN }}\n    severity-threshold: 6\n    model: openai/gpt-4.1\n    openai-base-url: https://models.github.ai/inference\n```\n\n## Examples\n\n### Basic Setup\n\nPerfect for most repositories with standard moderation needs:\n\n```yaml\n- uses: benbalter/ai-community-moderator@v1\n  with:\n    github-token: ${{ secrets.GITHUB_TOKEN }}\n```\n\n### Strict Moderation\n\nFor repositories requiring tight community standards (e.g., educational, corporate):\n\n```yaml\n- uses: benbalter/ai-community-moderator@v1\n  with:\n    github-token: ${{ secrets.GITHUB_TOKEN }}\n    severity-threshold: 3\n```\n\nThis configuration will:\n\n- Take action on minor infractions\n- Provide more educational guidance\n- Maintain stricter community standards\n\n### Lenient Moderation\n\nFor open-source projects with more relaxed community standards:\n\n```yaml\n- uses: benbalter/ai-community-moderator@v1\n  with:\n    github-token: ${{ secrets.GITHUB_TOKEN }}\n    severity-threshold: 8\n```\n\nThis configuration will:\n\n- Only act on severe violations\n- Allow more casual discussion\n- Focus on obvious policy violations\n\n### High-Traffic Repository\n\nFor repositories with many contributors and interactions:\n\n```yaml\nname: AI Community Moderator\n\non:\n  issues:\n    types: [opened, edited]\n  pull_request:\n    types: [opened, edited]\n  issue_comment:\n    types: [created, edited]\n  pull_request_review_comment:\n    types: [created, edited]\n  discussion:\n    types: [created, edited]\n  discussion_comment:\n    types: [created, edited]\n\njobs:\n  moderate:\n    runs-on: ubuntu-latest\n    permissions:\n      contents: read\n      issues: write\n      pull-requests: write\n      discussions: write\n      models: read\n    steps:\n      - uses: benbalter/ai-community-moderator@v1\n        with:\n          github-token: ${{ secrets.GITHUB_TOKEN }}\n          severity-threshold: 5\n          model: openai/gpt-4.1\n```\n\n## Moderation Actions\n\nThe AI can take several types of actions based on the content analysis:\n\n### 1. **Comment**\n\n- **When**: Educational opportunities or minor guideline clarifications needed\n- **Action**: Posts a helpful, educational comment explaining community standards\n- **Example**: \"Thanks for your contribution! To help maintain our community standards, please consider...\"\n\n### 2. **Suggest**\n\n- **When**: Content needs improvement but shows good intent\n- **Action**: Provides constructive suggestions for improvement\n- **Example**: Suggesting better formatting, clearer communication, or additional context\n\n### 3. **Hide**\n\n- **When**: Content violates community standards significantly\n- **Action**: Hides inappropriate comments from public view\n- **Note**: Requires repository admin permissions\n\n### 4. **Lock**\n\n- **When**: Discussions become unproductive or heated\n- **Action**: Locks issues, PRs, or discussions to prevent further comments\n- **Note**: Can be unlocked manually by maintainers\n\n### 5. **None**\n\n- **When**: Content meets community standards\n- **Action**: No action taken, normal processing continues\n\n## Permissions\n\nThe action requires the following GitHub permissions:\n\n```yaml\npermissions:\n  contents: read # To read community health files\n  issues: write # To comment on and lock issues\n  pull-requests: write # To comment on and lock PRs\n  discussions: write # To moderate discussions (if used)\n  models: read # To access GitHub Models for AI inference\n```\n\n### Permission Details\n\n- **`contents: read`**: Allows reading repository files like CONTRIBUTING.md and CODE_OF_CONDUCT.md\n- **`issues: write`**: Enables commenting on and locking issues\n- **`pull-requests: write`**: Enables commenting on and locking pull requests\n- **`discussions: write`**: Required only if moderating GitHub Discussions\n- **`models: read`**: Essential for accessing GitHub Models AI service\n\n## Community Health Files\n\nThe action automatically detects and uses community health files to provide context for moderation decisions:\n\n### Automatically Detected Files\n\n- **`.github/CONTRIBUTING.md`** or **`CONTRIBUTING.md`** - Contribution guidelines\n- **`.github/CODE_OF_CONDUCT.md`** or **`CODE_OF_CONDUCT.md`** - Community standards\n- **`.github/ISSUE_TEMPLATE.md`** - Issue submission guidelines\n\n### How They're Used\n\n- **Context Enhancement**: Files provide specific guidelines for the AI to reference\n- **Consistent Enforcement**: Ensures moderation aligns with your documented standards\n- **Educational Comments**: AI can reference specific sections when providing guidance\n\n### Best Practices\n\n1. **Keep files up-to-date**: Regular review ensures accurate moderation\n2. **Be specific**: Clear guidelines help the AI make better decisions\n3. **Include examples**: Concrete examples improve AI understanding\n\n## Inputs and Outputs\n\n### Inputs\n\n| Input                | Description                                                  | Required | Default                              |\n| -------------------- | ------------------------------------------------------------ | -------- | ------------------------------------ |\n| `github-token`       | GitHub token for API access and GitHub Models authentication | Yes      | `${{ github.token }}`                |\n| `openai-base-url`    | GitHub Models base URL                                       | No       | `https://models.github.ai/inference` |\n| `model`              | AI model to use for moderation                               | No       | `openai/gpt-4.1`                     |\n| `severity-threshold` | Severity threshold for taking action (1-10)                  | No       | `5`                                  |\n\n### Outputs\n\n| Output         | Description                      | Example                                                                      |\n| -------------- | -------------------------------- | ---------------------------------------------------------------------------- |\n| `action-taken` | Type of moderation action taken  | `comment`, `hide`, `lock`, `suggest`, `none`                                 |\n| `reason`       | Reason for the moderation action | `\"Content violates community guidelines regarding respectful communication\"` |\n\n### Using Outputs\n\n```yaml\n- uses: benbalter/ai-community-moderator@v1\n  id: moderate\n  with:\n    github-token: ${{ secrets.GITHUB_TOKEN }}\n\n- name: Log moderation result\n  run: |\n    echo \"Action taken: ${{ steps.moderate.outputs.action-taken }}\"\n    echo \"Reason: ${{ steps.moderate.outputs.reason }}\"\n```\n\n## Troubleshooting\n\n### Common Issues\n\n#### \"GitHub Models access denied\"\n\n**Problem**: Action fails with authentication or access errors\n**Solutions**:\n\n1. Verify `models: read` permission is included in workflow\n2. Ensure repository has GitHub Models access\n3. Check that `github-token` input is correctly set\n4. Verify token has necessary scopes\n\n#### \"No action taken on obvious violations\"\n\n**Problem**: AI doesn't moderate content that should be flagged\n**Solutions**:\n\n1. Lower the `severity-threshold` (try 3-4 instead of 5)\n2. Add or update community health files for better context\n3. Check if content type is supported (issues, PRs, comments, discussions)\n\n#### \"Too many false positives\"\n\n**Problem**: AI flags appropriate content as violations\n**Solutions**:\n\n1. Increase the `severity-threshold` (try 7-8 instead of 5)\n2. Review and refine community health files\n3. Consider using a different model\n\n#### Action timeout or slow response\n\n**Problem**: Action takes too long or times out\n**Solutions**:\n\n1. Switch to a faster model like `openai/gpt-3.5-turbo`\n2. Check GitHub Models service status\n3. Reduce context by limiting community health file size\n\n### Debug Mode\n\nEnable debug logging by adding this to your workflow:\n\n```yaml\n- uses: benbalter/ai-community-moderator@v1\n  with:\n    github-token: ${{ secrets.GITHUB_TOKEN }}\n  env:\n    ACTIONS_STEP_DEBUG: true\n```\n\n### Getting Help\n\n1. Check the [Actions tab](../../actions) for detailed logs\n2. Review this troubleshooting section\n3. Open an issue with:\n   - Workflow configuration\n   - Error messages\n   - Expected vs actual behavior\n\n## FAQ\n\n### General Questions\n\n**Q: How much does it cost to use this action?**\nA: The action itself is free, but GitHub Models usage may have costs depending on your GitHub plan and usage volume. Check GitHub's pricing for GitHub Models.\n\n**Q: What languages does the AI support?**\nA: The AI can moderate content in multiple languages, but it's most effective with English. Non-English content may have reduced accuracy.\n\n**Q: Can I use this with private repositories?**\nA: Yes, the action works with private repositories as long as they have GitHub Models access.\n\n### Technical Questions\n\n**Q: Which events trigger the action?**\nA: By default: `issues.opened`, `pull_request.opened`, `issue_comment.created`, `pull_request_review_comment.created`, `discussion.created`, `discussion_comment.created`. You can customize this in your workflow.\n\n**Q: Can I customize the AI prompts?**\nA: Not directly through configuration. The prompts are designed to work with community health files for customization.\n\n**Q: How does the AI understand my community standards?**\nA: It reads your CODE_OF_CONDUCT.md, CONTRIBUTING.md, and other community health files to understand your specific guidelines.\n\n**Q: Can I review actions before they're taken?**\nA: Not automatically, but you can monitor the Actions tab and manually review/reverse any actions if needed.\n\n### Privacy Questions\n\n**Q: What data is sent to the AI service?**\nA: Only the content being moderated and relevant community health files. No sensitive repository data or user information is shared unnecessarily.\n\n**Q: Is content stored by the AI service?**\nA: This depends on GitHub Models' data retention policy. Check GitHub's privacy policy for details.\n\n**Q: Can I run this without external AI services?**\nA: No, the action requires GitHub Models for AI inference capabilities.\n\n## Security Considerations\n\n### Data Privacy\n\n- **Content Analysis**: Only public content and community health files are analyzed\n- **No Sensitive Data**: Private repository contents, secrets, and personal information are not accessed\n- **GitHub Models**: Content is processed through GitHub's managed AI service with their privacy protections\n\n### Access Control\n\n- **Minimal Permissions**: Action requests only necessary permissions for operation\n- **GitHub Token**: Uses your repository's GitHub token, not external API keys\n- **Scope Limitation**: Cannot access resources outside the configured permissions\n\n### Action Security\n\n- **Source Code**: Open source and auditable\n- **Dependency Management**: Regular security updates for dependencies\n- **Signed Releases**: Future releases will be signed for integrity verification\n\n### Best Practices\n\n1. **Review Permissions**: Only grant necessary permissions to the workflow\n2. **Monitor Actions**: Regularly review action logs and decisions\n3. **Community Health**: Keep community guidelines up to date and specific\n4. **Incident Response**: Have a plan for handling false positives or negatives\n\n### Reporting Security Issues\n\nIf you discover a security vulnerability, please report it responsibly:\n\n1. **Don't** open a public issue\n2. **Do** email security concerns to the maintainer\n3. **Include** detailed reproduction steps and potential impact\n\n## Limitations\n\n### Technical Limitations\n\n- **Rate Limits**: Subject to GitHub API and GitHub Models rate limits\n- **Processing Time**: AI analysis adds latency to comment posting\n- **Language Support**: Most effective with English content\n- **Context Size**: Limited by AI model context window (~8K tokens)\n\n### Moderation Limitations\n\n- **Not Perfect**: AI may miss subtle violations or flag appropriate content\n- **Context Dependent**: Effectiveness depends on quality of community health files\n- **Cultural Nuance**: May not understand all cultural contexts or humor\n- **Evolving Standards**: Community standards may change faster than AI understanding\n\n### Functional Limitations\n\n- **Retroactive Moderation**: Only processes new content, not existing content\n- **Edit Detection**: Limited support for content edits (depends on workflow triggers)\n- **Complex Violations**: May struggle with complex, multi-message violations\n- **Appeals Process**: No built-in appeals or review process\n\n### Scope Limitations\n\n- **Repository Only**: Cannot moderate across multiple repositories\n- **Public Content**: Primarily designed for public community interactions\n- **GitHub Features**: Limited to GitHub's supported interaction types\n\n### Recommendations\n\n1. **Human Oversight**: Always maintain human moderator involvement\n2. **Regular Review**: Periodically review AI decisions and adjust thresholds\n3. **Clear Guidelines**: Maintain clear, specific community health documents\n4. **Feedback Loop**: Encourage community feedback on moderation decisions\n\n## Development\n\n### Building\n\n```bash\nnpm install\nnpm run build\n```\n\n### Testing\n\n```bash\nnpm test\n```\n\n### Linting\n\nCode style is enforced using ESLint:\n\n```bash\nnpm run lint          # Check for linting issues\nnpm run lint:fix      # Automatically fix issues\n```\n\n### Packaging\n\n```bash\nnpm run package\n```\n\n## Contributing\n\nWe welcome contributions to improve the AI Community Moderator! Here are ways you can help:\n\n### Quick Links\n\n- [Contributing Guidelines](.github/CONTRIBUTING.md) - Detailed contribution instructions\n- [Issue Tracker](../../issues) - Report bugs or suggest features\n- [Discussions](../../discussions) - Ask questions or discuss ideas\n\n### Getting Started\n\n1. **Fork** the repository\n2. **Clone** your fork locally\n3. **Install** dependencies: `npm install`\n4. **Build** the project: `npm run build`\n5. **Test** your changes: `npm test`\n\n### Development Workflow\n\n1. Create a feature branch from `main`\n2. Make your changes with tests\n3. Run the full test suite: `npm run all`\n4. Submit a pull request with clear description\n\n### Areas for Contribution\n\n- **Documentation**: Improve clarity, add examples, fix typos\n- **Testing**: Add test cases, improve coverage\n- **Features**: New moderation actions, better AI prompts\n- **Bug Fixes**: Address issues from the issue tracker\n\n## License\n\nMIT License - see [LICENSE](LICENSE) file for details.\n\nThis project is open source and welcomes contributions from the community.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenbalter%2Fai-community-moderator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenbalter%2Fai-community-moderator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenbalter%2Fai-community-moderator/lists"}