Skip to content

Commit f9eec13

Browse files
authored
Merge pull request #22 from lirantal/feat/package-health-reviewer
feat: package health reviewer based on Snyk Advisor
2 parents 49e900c + e8746fc commit f9eec13

File tree

11 files changed

+2892
-0
lines changed

11 files changed

+2892
-0
lines changed
Lines changed: 301 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,301 @@
1+
# Package Health Reviewer Agent
2+
3+
🔍 **Automated package health assessment using Snyk Advisor data**
4+
5+
Analyze the security, maintenance, and community health of software packages to make informed dependency decisions. This agent fetches real-time data from Snyk Advisor and provides actionable health assessments.
6+
7+
## Features
8+
9+
- **🛡️ Security Analysis**: Identifies vulnerabilities and security risks
10+
- **📊 Popularity Metrics**: Analyzes download statistics and community adoption
11+
- **🔧 Maintenance Assessment**: Evaluates update frequency and maintainer responsiveness
12+
- **👥 Community Health**: Reviews GitHub activity and documentation quality
13+
- **🎯 Smart Scoring**: Returns clear health ratings: "healthy", "sustainable", or "risky"
14+
- **🤖 Bot-Resistant**: Uses Playwright MCP server for reliable web automation
15+
- **📋 Detailed Reports**: Comprehensive metrics and actionable recommendations
16+
- **🚫 No File Creation**: Returns JSON directly without creating files on disk
17+
18+
## Quick Start
19+
20+
```bash
21+
# Analyze a popular package
22+
qodo --agent-file=agent.toml -y --set package_name="express"
23+
24+
# Check a potentially risky package
25+
qodo --agent-file=agent.toml -y --set package_name="request"
26+
27+
# Get minimal output without detailed metrics
28+
qodo --agent-file=agent.toml -y \
29+
--set package_name="lodash" \
30+
--set include_details=false
31+
```
32+
33+
## Configuration
34+
35+
### Arguments
36+
37+
| Argument | Type | Required | Default | Description |
38+
|----------|------|----------|---------|-------------|
39+
| `package_name` | string || - | Name of the package to analyze (e.g., 'express', 'lodash') |
40+
| `package_registry` | string || `npm` | Package registry to analyze (currently supports: npm) |
41+
| `include_details` | boolean || `true` | Include detailed metrics in the output |
42+
43+
### Example Configurations
44+
45+
```bash
46+
# Basic package analysis
47+
qodo --agent-file=agent.toml -y --set package_name="react"
48+
49+
# Analyze with minimal output
50+
qodo --agent-file=agent.toml -y \
51+
--set package_name="vue" \
52+
--set include_details=false
53+
54+
# Future: Other registries (when supported)
55+
qodo --agent-file=agent.toml -y \
56+
--set package_name="requests" \
57+
--set package_registry="pypi"
58+
```
59+
60+
## Health Score Criteria
61+
62+
### 🟢 Healthy (Score: 90-100)
63+
- **Security**: No critical/high vulnerabilities
64+
- **Popularity**: High download count (>100k weekly)
65+
- **Maintenance**: Recent updates (within 6 months)
66+
- **Community**: Active GitHub repository, good documentation
67+
- **Quality**: High Snyk score, good practices
68+
69+
### 🟡 Sustainable (Score: 60-89)
70+
- **Security**: Some medium vulnerabilities, no critical issues
71+
- **Popularity**: Moderate usage (10k-100k weekly downloads)
72+
- **Maintenance**: Updates within 12 months
73+
- **Community**: Decent GitHub activity
74+
- **Quality**: Acceptable Snyk score
75+
76+
### 🔴 Risky (Score: 0-59)
77+
- **Security**: Critical/high vulnerabilities present
78+
- **Popularity**: Low usage (<10k weekly) or declining
79+
- **Maintenance**: No recent updates (>12 months)
80+
- **Community**: Inactive repository
81+
- **Quality**: Low Snyk score, deprecated status
82+
83+
## Output Schema
84+
85+
The agent returns structured JSON with the following fields:
86+
87+
### Required Fields
88+
```json
89+
{
90+
"health_score": "healthy|sustainable|risky",
91+
"package_name": "express",
92+
"registry": "npm",
93+
"overall_score": 95,
94+
"assessment_date": "2024-01-15T10:30:00Z",
95+
"analysis_summary": "Express is a healthy package with excellent security posture..."
96+
}
97+
```
98+
99+
### Detailed Fields (when include_details=true)
100+
```json
101+
{
102+
"security_metrics": {
103+
"critical": 0,
104+
"high": 0,
105+
"medium": 1,
106+
"low": 2,
107+
"total_vulnerabilities": 3
108+
},
109+
"popularity_metrics": {
110+
"weekly_downloads": "2M+",
111+
"github_stars": 58000,
112+
"dependents": 15000
113+
},
114+
"maintenance_metrics": {
115+
"last_update": "2024-01-10",
116+
"update_frequency": "regular",
117+
"maintainer_response": "excellent"
118+
},
119+
"recommendations": [
120+
"Safe to use in production environments",
121+
"Keep updated to latest version"
122+
],
123+
"alternatives": [],
124+
"snyk_url": "https://snyk.io/advisor/npm-package/express"
125+
}
126+
```
127+
128+
## Prerequisites
129+
130+
### System Requirements
131+
- Node.js 18+ and npm
132+
- Playwright MCP server (automatically installed)
133+
134+
### Installation
135+
The Playwright MCP server is automatically configured and installed when you run the agent. No manual installation is required.
136+
137+
```bash
138+
# The agent will automatically install the Playwright MCP server:
139+
# npx @playwright/mcp@latest
140+
```
141+
142+
## Examples
143+
144+
### Test with Known Packages
145+
146+
```bash
147+
# Test with a healthy package (Express)
148+
qodo --agent-file=agent.toml -y --set package_name="express"
149+
# Expected: "healthy" score with high metrics
150+
151+
# Test with a risky package (Request - deprecated)
152+
qodo --agent-file=agent.toml -y --set package_name="request"
153+
# Expected: "risky" score with deprecation warnings
154+
155+
# Test with a sustainable package
156+
qodo --agent-file=agent.toml -y --set package_name="moment"
157+
# Expected: "sustainable" score (popular but has maintenance concerns)
158+
```
159+
160+
### CI/CD Integration
161+
162+
```yaml
163+
# GitHub Actions example
164+
name: Package Health Check
165+
on: [pull_request]
166+
167+
jobs:
168+
health-check:
169+
runs-on: ubuntu-latest
170+
steps:
171+
- uses: actions/checkout@v4
172+
- name: Setup Node.js
173+
uses: actions/setup-node@v4
174+
with:
175+
node-version: '18'
176+
- name: Install Playwright
177+
run: |
178+
npm install playwright
179+
npx playwright install chromium
180+
- name: Check package health
181+
run: |
182+
qodo --agent-file=agents/package-health-reviewer/agent.toml -y \
183+
--set package_name="${{ matrix.package }}" \
184+
--ci
185+
env:
186+
PACKAGE_NAME: ${{ matrix.package }}
187+
strategy:
188+
matrix:
189+
package: [express, lodash, axios]
190+
```
191+
192+
## Troubleshooting
193+
194+
### Common Issues
195+
196+
**Issue**: `Could not initialize the server playwright`
197+
```bash
198+
# The Playwright MCP server should install automatically
199+
# If you encounter issues, you can manually install it:
200+
npx @playwright/mcp@latest --help
201+
202+
# Or check if Node.js is available:
203+
node --version
204+
npm --version
205+
```
206+
207+
**Issue**: `Browser launch failed`
208+
```bash
209+
# The Playwright MCP server handles browser installation automatically
210+
# If you encounter issues, the agent can use the browser_install tool
211+
# to install required browsers
212+
213+
# For system dependencies (Ubuntu/Debian):
214+
sudo apt-get update
215+
sudo apt-get install -y \
216+
libnss3 \
217+
libatk-bridge2.0-0 \
218+
libdrm2 \
219+
libxkbcommon0 \
220+
libxcomposite1 \
221+
libxdamage1 \
222+
libxrandr2 \
223+
libgbm1 \
224+
libxss1 \
225+
libasound2
226+
```
227+
228+
**Issue**: `Package not found on Snyk Advisor`
229+
- Verify the package name is correct
230+
- Check if the package exists on npm registry
231+
- Some packages may not be indexed by Snyk yet
232+
- Try alternative package names or spellings
233+
234+
**Issue**: `Rate limiting or blocked requests`
235+
- The agent uses Playwright with realistic browser headers
236+
- If issues persist, try running with delays between requests
237+
- Check your network connection and proxy settings
238+
239+
### Debug Mode
240+
241+
For verbose output and debugging:
242+
243+
```bash
244+
# Run in interactive mode for debugging
245+
qodo chat agent.toml
246+
247+
# Then ask: "Please analyze the package 'express' with verbose logging"
248+
```
249+
250+
## Supported Registries
251+
252+
| Registry | Status | Package URL Format |
253+
|----------|--------|-------------------|
254+
| npm | ✅ Supported | `https://snyk.io/advisor/npm-package/{name}` |
255+
| PyPI | 🚧 Planned | `https://snyk.io/advisor/pypi-package/{name}` |
256+
| Maven | 🚧 Planned | `https://snyk.io/advisor/maven-package/{group}/{artifact}` |
257+
| RubyGems | 🚧 Planned | `https://snyk.io/advisor/rubygems-package/{name}` |
258+
259+
## Limitations
260+
261+
- Currently supports npm packages only
262+
- Requires internet connection to fetch Snyk Advisor data
263+
- Analysis accuracy depends on Snyk's data freshness
264+
- Some packages may not be indexed by Snyk Advisor
265+
- Rate limiting may apply for bulk analysis
266+
267+
## Contributing
268+
269+
1. Fork the repository
270+
2. Create a feature branch (`git checkout -b feature/new-registry`)
271+
3. Make your changes
272+
4. Test with the provided examples
273+
5. Submit a pull request
274+
275+
### Adding New Registry Support
276+
277+
To add support for a new package registry:
278+
279+
1. Update the `package_registry` argument options
280+
2. Modify the URL construction logic in the instructions
281+
3. Add registry-specific parsing logic
282+
4. Update documentation and examples
283+
5. Add test cases for the new registry
284+
285+
## License
286+
287+
This project is licensed under the MIT License - see the LICENSE file for details.
288+
289+
## Support
290+
291+
- 📚 [Qodo Documentation](https://docs.qodo.ai/)
292+
- 💬 [Discord Community](https://discord.gg/qodo)
293+
- 🐛 [Report Issues](https://github.com/qodo-ai/agents/issues)
294+
- 🔍 [Snyk Advisor](https://snyk.io/advisor/) - Data source for package analysis
295+
296+
## Related Tools
297+
298+
- [Snyk CLI](https://docs.snyk.io/snyk-cli) - Direct security scanning
299+
- [npm audit](https://docs.npmjs.com/cli/v8/commands/npm-audit) - Built-in npm security audit
300+
- [Dependabot](https://github.com/dependabot) - Automated dependency updates
301+
- [Socket Security](https://socket.dev/) - Alternative package security analysis

0 commit comments

Comments
 (0)