0.1.0 • Published 10 months ago
@guardian-ai/sdk v0.1.0
🛡️ Guardian AI SDK
🤖 Autonomous AI-powered security analysis for your repositories and smart contracts 🔒
🚀 Installation • ⚡ Quick Start • ✨ Features • 📚 Documentation • 💡 Examples • 🤝 Contributing
⚡ Quick Start
📦 Installation
# Using npm
npm install @guardian-ai/sdk
# Using yarn
yarn add @guardian-ai/sdk
# Using pnpm
pnpm add @guardian-ai/sdk🎯 Basic Usage
import { GuardianAI } from '@guardian-ai/sdk';
// Initialize the Guardian AI
const guardian = new GuardianAI({
apiKey: process.env.ANTHROPIC_API_KEY,
});
// Analyze a repository
const analysis = await guardian.analyzeRepository('https://github.com/user/repo');
console.log(analysis);⚛️ React Integration
import { useGuardianAI } from '@guardian-ai/sdk';
function SecurityAnalyzer() {
const guardian = useGuardianAI({
apiKey: process.env.ANTHROPIC_API_KEY,
});
const handleAnalysis = async () => {
const result = await guardian.analyzeRepository('https://github.com/user/repo');
console.log(result);
};
return <button onClick={handleAnalysis}>Analyze Repository</button>;
}🌟 Features
🔍 Deep Security Analysis
- 🎯 Comprehensive repository scanning
- ⚠️ Vulnerability detection and classification
- 📦 Dependency security audit
🔐 Smart Contract Security
- 🤖 Automated vulnerability detection
- ✅ Best practices validation
- ⚡ Gas optimization suggestions
💻 Developer Experience
- 📘 TypeScript support
- ⚛️ React hooks for easy integration
- 📚 Comprehensive documentation
- 🔄 Modern ESM and CommonJS support
📚 Documentation
🛡️ GuardianAI Class
The main class for interacting with the Guardian AI SDK.
⚙️ Constructor Options
interface SecurityAnalysisOptions {
apiKey: string; // Your Anthropic API key
model?: string; // AI model to use (default: 'claude-3-haiku-20240307')
maxTokens?: number; // Maximum tokens for analysis (default: 4096)
}🔧 Methods
| Method | Description | Parameters | Return Type |
|---|---|---|---|
analyzeRepository | Performs security analysis on a GitHub repository | repoUrl: string | Promise<SecurityAnalysisResult> |
📝 Types
interface SecurityThreat {
level: 'high' | 'medium' | 'low';
description: string;
impact: string;
remediation: string;
}
interface SecurityAnalysisResult {
score: number; // Overall security score (0-100)
threats: SecurityThreat[]; // List of identified threats
recommendations: string[]; // Security recommendations
}💡 Examples
🔍 Basic Security Analysis
const guardian = new GuardianAI({
apiKey: process.env.ANTHROPIC_API_KEY,
});
// Analyze a specific repository
const analysis = await guardian.analyzeRepository(
'https://github.com/example/defi-protocol'
);
// Handle the results
console.log(`Security Score: ${analysis.score}`);
analysis.threats.forEach(threat => {
console.log(`${threat.level.toUpperCase()}: ${threat.description}`);
});⚛️ React Component with Loading State
function SecurityScanner() {
const [loading, setLoading] = useState(false);
const [results, setResults] = useState(null);
const guardian = useGuardianAI({
apiKey: process.env.ANTHROPIC_API_KEY,
});
const handleScan = async (repoUrl) => {
try {
setLoading(true);
const analysis = await guardian.analyzeRepository(repoUrl);
setResults(analysis);
} catch (error) {
console.error('Analysis failed:', error);
} finally {
setLoading(false);
}
};
return (
<div>
{loading ? (
<div>Analyzing repository...</div>
) : results ? (
<div>
<h2>Security Score: {results.score}</h2>
{/* Display other results */}
</div>
) : null}
</div>
);
}🤝 Contributing
We welcome contributions! Please feel free to submit a Pull Request. 🎉
- 🍴 Fork the repository
- 🌿 Create your feature branch (
git checkout -b feature/amazing-feature) - ✍️ Commit your changes (
git commit -m 'Add some amazing feature') - 🚀 Push to the branch (
git push origin feature/amazing-feature) - 🎯 Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
0.1.0
10 months ago