Looking at the original requirements, I can identify several suboptimal aspects and suggest improvements:
Issues with Original Requirements
Suboptimal aspects:
- Git commits for every content change creates noisy history and doesn't scale
- Multiple output formats per target adds complexity without clear benefit
- Serverless platforms have execution time/memory limits unsuitable for large crawls
- Direct GitHub repo commits bypass proper review processes
- No consideration for rate limiting, robots.txt, or ethical crawling
- Missing error recovery and partial failure handling
- No content deduplication or change detection strategy
Improved Requirements
Here's a rewritten prompt addressing these issues:
Build a production-ready web content extraction tool using Bun with the following specifications:
Core Architecture
Create a TypeScript-based tool optimized for different execution contexts:
- Local/CI: Full-featured crawling with persistent storage
- Serverless: Single-page extraction with external storage integration
- Scheduled: Incremental updates with intelligent change detection
Configuration System
Design a hierarchical config supporting:
interface ExtractionConfig {
sites: Array<{
name: string;
baseUrl: string;
discovery: 'sitemap' | 'crawl' | 'list';
pages?: string[]; // explicit page list
rules: {
include?: string[]; // URL patterns
exclude?: string[]; // URL patterns
maxDepth?: number;
respectRobots?: boolean;
};
extraction: {
content: ContentSelector[];
metadata: MetadataSelector[];
assets?: AssetRule[]; // favicon, images, etc.
};
output: {
format: 'json' | 'markdown'; // simplified to two useful formats
structure: 'flat' | 'hierarchical';
filename?: string; // template support
};
}>;
global: {
rateLimit: number; // requests per second
userAgent: string;
timeout: number;
retries: number;
storage: StorageConfig;
};
}
Content Processing
Implement a pipeline approach:
- Discovery: Find pages via sitemap, crawling, or explicit lists
- Extraction: Pull content using CSS selectors, XPath, or custom functions
- Transformation: Clean, normalize, and format extracted data
- Deduplication: Detect and handle duplicate content intelligently
- Change Detection: Compare against previous runs using content hashes
Storage Strategy
Replace direct git commits with better approaches:
- Local: File system with optional git integration via hooks
- Cloud: S3/R2 compatible storage with versioning
- Database: Optional structured storage for metadata and search
- Change Tracking: Separate change log instead of commit-per-change
Platform Optimization
Structure for appropriate use cases:
- GitHub Actions: Scheduled full-site extractions with artifact storage
- Cloudflare Workers: On-demand single-page extraction with KV/R2 storage
- Local: Development, testing, and ad-hoc extractions
Enhanced Features
- Ethical Crawling: Robots.txt respect, rate limiting, proper user agents
- Resilience: Graceful failure handling, partial success reporting, resume capability
- Monitoring: Structured logging, metrics, health checks
- Content Intelligence: Automatic content type detection, language identification
- Incremental Processing: Only process changed pages, smart cache invalidation
Output Management
- Generate consistent, searchable file structures
- Support content versioning without repository pollution
- Provide change summaries and statistics
- Enable easy integration with static site generators or CMSs
Technical Requirements
- Leverage Bun's performance for concurrent processing
- Implement proper backpressure and memory management
- Use streaming for large content processing
- Design modular architecture for easy extension
- Include comprehensive testing and validation
Build this as a maintainable tool that scales from single-page extraction to enterprise content migration, with clear separation of concerns and platform-appropriate optimizations.
This improved prompt addresses scalability, maintainability, and real-world usage patterns while removing unnecessary complexity and adding essential production features.