Description
Add AI Memory system that transforms scraped documentation into queryable JSON tree structure.
Problem
Scraped docs are 50K-200K tokens. Sending entire docs to LLMs is expensive (~$0.03/query) and slow.
Solution
Transform docs into hierarchical JSON with indexes and embeddings. Query locally to find relevant sections (3-5K tokens), send only those to LLM. 95%+ token savings (~$0.001/query).
Implementation
- Hierarchical tree structure (organized by headings)
- Multiple query types: path, keyword, semantic, hybrid
- Local embeddings (no API costs)
- Token counting
- JSON storage
New CLI flags
\\�ash
webpull --ai-memory # Generate AI memory JSON
webpull --ai-memory-out
# Custom output directory
\\
Use cases
- Documentation chatbots
- CLI tools with doc search
- Offline documentation query
- RAG learning/prototyping
Files
- \src/ai-memory/\ - Core system (17 files)
- \examples/chatbot.ts\ - Example implementation
- \AI-MEMORY-README.md\ - Documentation
Testing
Tested with Bun.sh docs (428 nodes, 82K tokens) and Next.js docs (263 nodes, 47K tokens).
Dependencies
- @xenova/transformers\ (v2.17.2) - Local embeddings
- @google/generative-ai\ (v0.21.0) - Example only (optional)
Breaking changes
None. Purely additive feature.
Description
Add AI Memory system that transforms scraped documentation into queryable JSON tree structure.
Problem
Scraped docs are 50K-200K tokens. Sending entire docs to LLMs is expensive (~$0.03/query) and slow.
Solution
Transform docs into hierarchical JSON with indexes and embeddings. Query locally to find relevant sections (3-5K tokens), send only those to LLM. 95%+ token savings (~$0.001/query).
Implementation
New CLI flags
\\�ash
# Custom output directorywebpull --ai-memory # Generate AI memory JSON
webpull --ai-memory-out
\\
Use cases
Files
Testing
Tested with Bun.sh docs (428 nodes, 82K tokens) and Next.js docs (263 nodes, 47K tokens).
Dependencies
Breaking changes
None. Purely additive feature.