# @easbot/memory

[中文](./README.md) | English

Memory management library for the EASBOT ecosystem, providing intelligent memory indexing, search, and management capabilities.

## Features

- **Hybrid Search**: Combines vector search, full-text search (FTS), and graph search
- **Chinese/English Tokenization**: High-quality tokenization via jieba-wasm
- **Incremental Indexing**: Supports incremental updates with automatic file change detection
- **Multi-source Support**: Supports both memory and sessions memory sources
- **XDG Compliance**: Database stored in XDG data directory by default

## Installation

```bash
pnpm add @easbot/memory
```

## Usage

```typescript
import { MemoryIndexManager } from '@easbot/memory';

// Get memory manager instance
const manager = await MemoryIndexManager.get({
  workspaceDir: '/path/to/workspace',
});

// Search memories
const results = await manager.search('machine learning', {
  maxResults: 10,
  minScore: 0.5,
});

// Index a file
await manager.indexFile('/path/to/file.md');
```

## API

### MemoryIndexManager

| Method | Description |
|--------|-------------|
| `get(params)` | Get or create manager instance |
| `search(query, options)` | Hybrid search |
| `indexFile(filePath)` | Index a single file |
| `indexDirectory(dirPath)` | Index a directory |
| `getStatus()` | Get status information |

## Development

```bash
# Install dependencies
pnpm install

# Build
pnpm build

# Test
pnpm test

# Type check
pnpm type-check
```

## Database Location

Default storage: `$XDG_DATA_HOME/easbot/memory.db`

- Linux: `~/.local/share/easbot/memory.db`
- macOS: `~/Library/Application Support/easbot/memory.db`
- Windows: `%APPDATA%/easbot/memory.db`

## License

MIT
