Chrome/Edge extension analyzing text on GitHub and Azure DevOps to suggest inclusive language in code reviews using ONNX ML and rule-based suggestions
This skill has safety concerns that you should review before use. Some patterns were detected that may pose a risk.Safety score: 60/100.
KillerSkills scans all public content for safety. Use caution before installing or executing flagged content.
A Chrome/Edge browser extension that analyzes text in real-time on GitHub and Azure DevOps to suggest more inclusive language in code reviews. Uses both rule-based suggestions and a custom ONNX ML model for sentiment analysis, with optional OpenAI integration for enhanced suggestions.
The extension operates through a multi-layer processing pipeline:
1. **Content Scripts** inject into GitHub and Azure DevOps pages and capture text input
2. **Background Service Worker** orchestrates validation using imported modules
3. **Rule-Based Suggestions** check text against a curated dictionary of inclusive language replacements
4. **ONNX ML Model** runs sentiment analysis entirely in-browser (no server calls)
5. **Optional OpenAI Integration** provides enhanced rewrite suggestions via Azure endpoint
**Packed Modules** (`src-packed/`)
**Extension Code** (`src/`)
**ML Model** (`assets/model.onnx`)
1. Install dependencies:
```bash
npm install
```
2. Create `src-packed/secrets.js` for API keys:
```javascript
// For local development without OpenAI, use empty strings
export const OPENAI_KEY = "";
export const OPENAI_ENDPOINT = "";
export const APP_INSIGHTS_KEY = "";
```
3. Build the extension:
```bash
npx xt-build
```
4. Install in browser:
- Navigate to `edge://extensions/` or `chrome://extensions/`
- Enable "Developer Mode"
- Drag `release.zip` into the extensions page
Edit `src-packed/suggestions.js` to add new replacement patterns:
```javascript
const allReplacements = {
// Socially charged terms
"blacklist": ["denylist", "exclusion list", "block list"],
"whitelist": ["allowlist", "inclusion list", "safe list"],
// Gendered terms
"guys": ["folks", "friends", "people", "everyone"],
"man-hours": ["person-hours", "work-hours", "engineering time"],
// Ableist terms
"sanity check": ["confidence check", "coherence check", "rationality check"],
"cripple": ["impair", "disable", "hinder"],
// Add your new terms here:
"your-term": ["alternative1", "alternative2", "alternative3"]
};
```
**Categories:**
Create corresponding tests in `test/suggestions.js`:
```javascript
it(`Replace "your-term"`, async function() {
const text = 'This sentence contains your-term in it.';
const matches = [];
await getMatches(ort, text, matches);
expect(matches.length).equal(1);
expect(matches[0].shortMessage).equal('Avoid "your-term"');
expect(matches[0].replacements).deep.equal([
{value: 'alternative1'},
{value: 'alternative2'},
{value: 'alternative3'}
]);
});
```
```bash
npx xt-test # Run tests to verify
npx xt-build # Build updated extension
```
1. Reload the extension in your browser
2. Navigate to GitHub or Azure DevOps
3. Start typing in a comment or review text area
4. Verify that your new suggestion appears when the term is used
```bash
cp assets/model.onnx assets/model.onnx.backup
cp /path/to/your/new-model.onnx assets/model.onnx
```
Edit `src-packed/textAnalytics.js` if your model has different:
```javascript
// Example: Adjusting sentiment threshold
const sentimentScore = results.sentiment_scores[0];
const isNegative = sentimentScore > 0.6; // Adjust threshold here
```
Create test cases in `test/textAnalytics.js`:
```javascript
it('New model correctly identifies negative sentiment', async function() {
const text = 'This is an extremely harsh and critical review.';
const score = await analyzeSentiment(ort, text);
expect(score).to.be.above(0.6);
});
it('New model correctly identifies positive sentiment', async function() {
const text = 'This is excellent work, well done!';
const score = await analyzeSentiment(ort, text);
expect(score).to.be.below(0.6);
});
```
```bash
npx xt-test # Run all tests
```
Test with diverse inputs:
Monitor model performance:
1. Navigate to target page (GitHub/Azure DevOps)
2. Open browser DevTools (F12)
3. Console logs from content scripts appear in page context
4. Use "Sources" tab to set breakpoints in injected scripts
1. Navigate to `edge://extensions/` or `chrome://extensions/`
2. Find your extension
3. Click "service worker" link
4. DevTools opens with access to background script logs
1. Set breakpoints in test files or packed modules
2. Run tests via VS Code debugger:
- Open Debug panel
- Select "Mocha Tests" configuration
- Press F5
**ONNX model not loading:**
**Suggestions not appearing:**
**OpenAI integration failing:**
This extension complements GitHub Copilot by:
1. **Post-generation review** - Analyzes code review comments after Copilot generates them
2. **Real-time feedback** - Provides immediate suggestions as you type reviews
3. **Team consistency** - Enforces inclusive language standards across all review authors
4. **Educational tool** - Teaches developers about inclusive terminology
1. Copilot suggests code or review comments
2. Developer types or accepts suggestions
3. Extension analyzes text in real-time
4. Inclusive language alternatives appear as inline suggestions
5. Developer can accept suggestions with one click
```bash
npx xt-build
```
This creates `release.zip` containing:
1. Open `edge://extensions/` or `chrome://extensions/`
2. Enable "Developer Mode" toggle
3. Drag `release.zip` onto the page
4. Extension auto-installs
For Chrome Web Store or Edge Add-ons:
1. Prepare store assets (screenshots, descriptions)
2. Submit `release.zip` via developer dashboard
3. Complete store-specific review process
**Runtime Requirements:**
**Dependencies:**
**Limitations:**
Built on LanguageTool foundation (see LICENSE file in repository). Extension code uses Manifest V3 architecture with custom ONNX integration.
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/inclusive-code-review-language-analyzer/raw