@bernierllc/ai-content-reviewer
v1.0.7
Published
AI-powered content review service for quality, tone, grammar, SEO, and readability analysis
Readme
@bernierllc/ai-content-reviewer
AI-powered content review service for quality, tone, grammar, SEO, and readability analysis.
Installation
npm install @bernierllc/ai-content-reviewerFeatures
- Comprehensive Review: Full content analysis covering grammar, tone, readability, SEO, and more
- Grammar Analysis: Deep grammar, spelling, punctuation, and style checking
- Readability Analysis: Flesch-Kincaid grade level and reading ease scores
- Tone Analysis: Detect primary tone, secondary tones, and consistency
- SEO Analysis: Keyword density, heading structure, and optimization suggestions
- Quick Check: Fast pass/fail quality assessment
- Batch Review: Review multiple pieces of content in parallel
- Analytics: Track review statistics and trends
Usage
Basic Setup
import { AIContentReviewer } from '@bernierllc/ai-content-reviewer';
import { OpenAIProvider } from '@bernierllc/ai-provider-openai';
const provider = new OpenAIProvider({
providerName: 'openai',
apiKey: process.env.OPENAI_API_KEY!,
});
const reviewer = new AIContentReviewer({
provider,
enableAnalytics: true,
});Comprehensive Review
const result = await reviewer.review(
'Your content to review goes here...',
{
reviewTypes: ['quality', 'grammar', 'tone', 'readability'],
targetAudience: 'software developers',
expectedTone: 'professional',
includeSuggestions: true,
}
);
console.log(`Overall Score: ${result.overallScore}/100`);
console.log(`Passes Threshold: ${result.passesThreshold}`);
console.log(`Issues Found: ${result.issues.length}`);
console.log(`Summary: ${result.summary}`);
// Access detailed scores
console.log('Scores:', result.scores);
// { grammar: 85, clarity: 90, readability: 78, tone: 92, overall: 86 }
// Review issues
result.issues.forEach(issue => {
console.log(`[${issue.severity}] ${issue.category}: ${issue.description}`);
if (issue.suggestedFix) {
console.log(` Fix: ${issue.suggestedFix}`);
}
});Grammar Analysis
const grammar = await reviewer.analyzeGrammar(content);
console.log(`Grammar Score: ${grammar.score}/100`);
console.log('Error Counts:', grammar.errorCounts);
// { grammar: 2, spelling: 1, punctuation: 0, style: 3 }
grammar.issues.forEach(issue => {
console.log(`${issue.originalText} → ${issue.suggestedFix}`);
});Readability Analysis
const readability = await reviewer.analyzeReadability(content);
console.log(`Grade Level: ${readability.gradeLevel}`);
console.log(`Reading Ease: ${readability.readingEase}/100`);
console.log(`Difficulty: ${readability.difficultyLevel}`);
console.log(`Reading Time: ${readability.readingTimeMinutes} minutes`);
console.log(`Word Count: ${readability.wordCount}`);
console.log(`Complex Words: ${readability.complexWordCount}`);Tone Analysis
const tone = await reviewer.analyzeTone(content, 'professional');
console.log(`Primary Tone: ${tone.primaryTone}`);
console.log(`Secondary Tones: ${tone.secondaryTones.join(', ')}`);
console.log(`Consistency: ${tone.consistencyScore}/100`);
console.log(`Matches Expected: ${tone.matchesExpected}`);SEO Analysis
const seo = await reviewer.analyzeSEO(content, ['typescript', 'programming']);
console.log(`SEO Score: ${seo.score}/100`);
// Keyword analysis
seo.keywordAnalysis?.forEach(kw => {
console.log(`${kw.keyword}: ${kw.count} occurrences (${kw.density}%)`);
console.log(` In title: ${kw.inTitle}, In first paragraph: ${kw.inFirstParagraph}`);
});
// Heading structure
console.log('Headings:', seo.headingAnalysis);
// { h1Count: 1, h2Count: 3, h3Count: 5, hasProperHierarchy: true }
// SEO issues
seo.issues.forEach(issue => {
console.log(`[${issue.severity}] ${issue.description}`);
});Quick Check
const check = await reviewer.quickCheck(content, 75); // 75 = minimum score
console.log(`Passed: ${check.passed}`);
console.log(`Score: ${check.score}/100`);
console.log(`Summary: ${check.summary}`);Batch Review
const batchResults = await reviewer.batchReview([
{ id: 'blog-1', content: 'First blog post content...', options: { reviewTypes: ['quality'] } },
{ id: 'blog-2', content: 'Second blog post content...', options: { reviewTypes: ['grammar'] } },
{ id: 'email-1', content: 'Email content...', options: { contentType: 'email' } },
]);
console.log(`Reviewed: ${batchResults.totalReviewed}`);
console.log(`Passed: ${batchResults.successCount}`);
console.log(`Average Score: ${batchResults.averageScore}`);
batchResults.results.forEach(r => {
console.log(`${r.id}: ${r.result.overallScore}/100`);
});Analytics
const analytics = reviewer.getAnalytics({
start: new Date('2025-01-01'),
end: new Date(),
});
console.log(`Total Reviews: ${analytics.totalReviews}`);
console.log(`Average Score: ${analytics.averageScore}`);
console.log(`Pass Rate: ${analytics.passRate}%`);
console.log(`Estimated Cost: $${analytics.totalCost.toFixed(4)}`);API Reference
AIContentReviewerConfig
| Property | Type | Description | |----------|------|-------------| | provider | AIProviderClient | AI provider instance for review | | fallbackProvider | AIProviderClient | Optional fallback provider | | defaultOptions | ReviewOptions | Default options for all reviews | | enableAnalytics | boolean | Enable analytics tracking | | maxRetries | number | Maximum retries for failed reviews | | defaultTemperature | number | Default temperature (0-1) |
ReviewOptions
| Property | Type | Description | |----------|------|-------------| | reviewTypes | ReviewType[] | Types of review to perform | | targetAudience | string | Target audience description | | expectedTone | string | Expected content tone | | brandGuidelines | string | Brand voice guidelines | | seoKeywords | string[] | SEO keywords to check | | minReadabilityScore | number | Minimum passing score (0-100) | | contentType | string | Type of content being reviewed | | language | string | Content language | | includeSuggestions | boolean | Include improvement suggestions | | maxIssues | number | Maximum issues to report |
Review Types
- quality: Overall content quality assessment
- grammar: Grammar, spelling, and punctuation
- tone: Voice and tone analysis
- seo: Search engine optimization
- readability: Reading level and clarity
- accessibility: Accessibility concerns
- factual: Factual accuracy (limited)
- plagiarism: Originality check (limited)
- brand: Brand voice alignment
- comprehensive: All review types combined
Issue Severities
- critical: Must fix before publishing
- major: Should fix, significantly impacts quality
- minor: Nice to fix, minor impact
- suggestion: Optional improvement
Security
API Key Management
- API keys: Store in environment variables (never hardcode)
- Key rotation: Support dynamic key updates through configuration
- Fallback provider: Use fallback provider if primary fails (resilience)
Content Privacy
- No data storage: Content is only sent to AI providers, not stored locally
- Provider selection: Choose AI providers based on your data privacy requirements
- Audit logging: Enable analytics to track review operations for compliance
Input Validation
- Content sanitization: All user inputs are validated before processing
- Length limits: Configurable content length limits prevent abuse
- Rate limiting: Implement rate limiting at application level (not package level)
Dependencies
- Security audits: Regular audits via
npm audit - Updates: All dependencies kept up-to-date
- Vulnerability scanning: No known high/critical vulnerabilities
- Supply chain security: All dependencies from trusted npm registry sources
Best Practices
- Environment isolation: Run in isolated environments for sensitive content
- Access control: Implement application-level access controls for review features
- Logging: Log review operations without logging sensitive content
- Error handling: Errors never expose API keys or sensitive configuration
Integration Status
Logger Integration
Status: Planned for v1.1.0
This package will integrate @bernierllc/logger for structured logging:
- Review operation logging (start, completion, errors)
- Analytics event tracking
- Performance metrics logging
- Error and warning logging with context
Current implementation uses console logging, which will be migrated to the logger integration pattern using detectLogger() for optional availability.
NeverHub Integration
Status: Planned for v1.2.0
This package will integrate @bernierllc/neverhub-adapter for:
- Service discovery for AI provider resolution
- Event publishing for review completion events
- Health monitoring and metrics reporting
- Dynamic configuration updates
Integration will follow the standard NeverHub pattern using detectNeverHub() for graceful degradation when NeverHub is not available.
Docs-Suite
Status: Ready (TypeDoc format)
Package includes comprehensive TypeDoc comments for automatic documentation generation.
License
Copyright (c) 2025 Bernier LLC. All rights reserved.
