vasperamemory-sdk
v0.2.2
Published
VasperaMemory TypeScript/JavaScript SDK - Universal AI memory layer
Maintainers
Readme
VasperaMemory TypeScript SDK
Add persistent AI memory to your applications. Your AI agents remember context across sessions.
Why VasperaMemory?
- Persistent Memory — Your AI remembers decisions, patterns, and fixes across sessions
- Error Fix Memory — Save error fixes once, get suggestions automatically next time
- Change Impact Analysis — Understand what code changes will affect before making them
- Entity Intelligence — Track relationships between code entities across your codebase
- Pattern Library — Access and contribute to community-shared coding patterns
- Framework Ready — Works with Vercel AI SDK, LangChain, and more
Installation
npm install vasperamemory-sdkQuick Start
import { VasperaMemory } from 'vasperamemory-sdk';
const vm = new VasperaMemory({
apiKey: process.env.VASPERAMEMORY_API_KEY,
projectId: process.env.VASPERAMEMORY_PROJECT_ID
});
// Search your project's memory
const results = await vm.search('authentication patterns');
// Capture decisions for future reference
await vm.captureDecision({
category: 'architectural',
title: 'Use Redis for caching',
content: 'Chose Redis for its data structure support'
});
// Find past fixes for errors
const fix = await vm.findErrorFix('TypeError: Cannot read property');New in v0.2.0
Change Impact Analysis
Understand what will be affected before making code changes:
// Analyze impact before modifying code
const impact = await vm.analyzeChangeImpact(
'src/auth/handler.ts',
['validateToken', 'refreshSession']
);
console.log('Affected files:', impact.affectedFiles);
console.log('Risk level:', impact.riskLevel);
// Estimate risk for a set of changes
const risk = await vm.estimateChangeRisk(
['src/auth/handler.ts', 'src/middleware/auth.ts'],
'refactor'
);
console.log('Risk score:', risk.riskScore);
console.log('Recommendations:', risk.recommendations);
// Find similar code implementations
const similar = await vm.findSimilarCode(`
async function validateToken(token: string) {
const decoded = jwt.verify(token, secret);
return decoded;
}
`);Entity Intelligence
Track and query code entities across your codebase:
// Search for entities
const entities = await vm.searchEntities('auth', {
entityType: 'function',
limit: 10
});
// Get relationships between entities
const relationships = await vm.getEntityRelationships('UserService', {
direction: 'both',
predicateFilter: 'uses'
});
// Track entity evolution over time
const evolution = await vm.getEntityEvolution('src/services/auth.ts', 'validateUser');
console.log('Stability score:', evolution.stabilityScore);
console.log('Version count:', evolution.versionCount);Export & Import
Migrate or backup your project memory:
// Export memories
const exportResult = await vm.exportMemory({
format: 'json',
includeDecisions: true,
includeErrors: true
});
console.log('Download URL:', exportResult.downloadUrl);
// Import memories
const importResult = await vm.importMemory(memoryData, 'append');
console.log('Imported:', importResult.importedCount);Pattern Library
Access community patterns and share your own:
// Get pattern suggestions based on context
const suggestions = await vm.suggestPatterns({
context: 'implementing authentication middleware',
filePath: 'src/middleware/auth.ts'
});
// Search community patterns
const patterns = await vm.searchPatterns('error handling', {
category: 'typescript'
});
// Contribute a pattern
await vm.contributePattern(
'Repository Pattern',
'Abstract data access layer for database operations',
'architecture',
`class UserRepository {
async findById(id: string): Promise<User> { ... }
}`
);Vercel AI SDK Integration
import { createVasperaMemoryTools } from 'vasperamemory-sdk/vercel-ai';
import { generateText } from 'ai';
const tools = createVasperaMemoryTools(vm);
const result = await generateText({
model: openai('gpt-4'),
prompt: 'What patterns do we use?',
tools
});API Reference
Core Methods
| Method | Description |
|--------|-------------|
| search(query, options?) | Search memories by semantic similarity |
| captureMemory(request) | Save a new memory |
| captureDecision(request) | Record an architectural decision |
| captureErrorFix(request) | Save an error fix for future reference |
| findErrorFix(errorMessage) | Find a fix for a known error |
| getSessionContext(options?) | Get comprehensive session context |
| fuseContext(options?) | Merge context from multiple sources |
Change Analysis Methods (v0.2.0)
| Method | Description |
|--------|-------------|
| analyzeChangeImpact(file, symbols) | Analyze impact of modifying code |
| predictChangeImpact(file, options?) | Predict ripple effects of changes |
| estimateChangeRisk(files, changeType?) | Assess risk before making changes |
| findSimilarCode(code, options?) | Find similar implementations |
Entity Methods (v0.2.0)
| Method | Description |
|--------|-------------|
| searchEntities(query, options?) | Search code entities |
| getEntityRelationships(entity, options?) | Get entity dependencies |
| getEntityEvolution(file, entity?) | Track entity history |
Export/Import Methods (v0.2.0)
| Method | Description |
|--------|-------------|
| exportMemory(options?) | Export to JSON/markdown/YAML |
| importMemory(data, strategy?) | Import from external sources |
Pattern Methods (v0.2.0)
| Method | Description |
|--------|-------------|
| suggestPatterns(options?) | Get context-aware pattern suggestions |
| searchPatterns(query, options?) | Search community patterns |
| contributePattern(name, desc, category, example?) | Share a pattern |
Get Your API Key
- Run
npx vasperamemory connectin any project - Enter your email when prompted
- Your API key is generated automatically
Or sign up at vasperamemory.com
Documentation
Full API documentation: vasperamemory.com/docs/sdk
Links
- Website: vasperamemory.com
- CLI: npmjs.com/package/vasperamemory
- GitHub: github.com/RCOLKITT/VasperaMemory
License
MIT — Use it, modify it, ship it.
