128 lines
3.9 KiB
Markdown
128 lines
3.9 KiB
Markdown
# CLAUDE.md
|
||
|
||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||
|
||
## Project Overview
|
||
|
||
Memos CLI is a command-line tool for interacting with Memos (a self-hosted note-taking application) via its API. The project is in early development stage with minimal implementation.
|
||
|
||
## Development Commands
|
||
|
||
### Environment Setup
|
||
```bash
|
||
# Create virtual environment (Python 3.13 required)
|
||
python -m venv .venv
|
||
|
||
# Activate virtual environment
|
||
# Windows:
|
||
.venv\Scripts\activate
|
||
# Unix/macOS:
|
||
source .venv/bin/activate
|
||
|
||
# Install project in development mode
|
||
pip install -e .
|
||
```
|
||
|
||
### Running the Application
|
||
```bash
|
||
# Run main module
|
||
python -m memoscli
|
||
# or
|
||
python main.py
|
||
```
|
||
|
||
## Architecture
|
||
|
||
### Project Structure
|
||
- `main.py` - Entry point with basic Memos API integration
|
||
- `memos.py` - Main module file (currently minimal)
|
||
- `src/send.py` - Memos API client implementation for content posting
|
||
- `src/config.py` - Configuration management for .env file operations
|
||
- `src/__init__.py` - Package initialization
|
||
- `pyproject.toml` - Project configuration with dependencies
|
||
- `.env` - Environment variables template (auto-generated if missing)
|
||
- `examples/send_example.py` - API usage examples
|
||
- `examples/config_example.py` - Configuration usage examples
|
||
|
||
### Planned Features
|
||
1. **Content submission**: `memos send <content> [--type <type>]`
|
||
2. **AI-powered summaries**: `memos summary [--date <date>] [--tags <tags>]`
|
||
3. **Configuration management**: `memos config set <key> <value>`
|
||
|
||
### Required Environment Variables
|
||
```
|
||
MEMOS_BASE_URL=<your_memos_base_url>
|
||
MEMOS_TOKEN=<your_token>
|
||
MEMOS_AI_MODEL_NAME=<your_ai_model_name>
|
||
MEMOS_AI_MODEL_API_KEY=<your_ai_model_api_key>
|
||
MEMOS_AI_MODEL_API_URL=<your_ai_model_base_url>
|
||
```
|
||
|
||
### Technical Requirements
|
||
- Python 3.13 (specified in `.python-version`)
|
||
- Dependencies: `requests>=2.31.0`, `python-dotenv>=1.0.0`
|
||
- Uses Memos API with Bearer token authentication
|
||
- Environment variable configuration via python-dotenv
|
||
|
||
### Implementation Status
|
||
- ✅ **Memos API client**: Basic implementation in `src/send.py`
|
||
- ✅ **Content posting**: Can send memos with content, visibility, and tags
|
||
- ✅ **Connection testing**: Built-in connection validation
|
||
- ✅ **Error handling**: Proper exception handling for API errors
|
||
- 🔄 **CLI interface**: Basic implementation in `main.py`
|
||
- ✅ **Configuration management**: Complete implementation in `src/config.py`
|
||
- ⏳ **AI integration**: Planned but not implemented
|
||
- ⏳ **Content summarization**: Planned but not implemented
|
||
|
||
### Usage Examples
|
||
|
||
#### Memos API 使用示例
|
||
```python
|
||
# 方法1:使用便捷函数
|
||
from src.send import send_memo
|
||
result = send_memo("内容", visibility="PRIVATE", tags=["标签1", "标签2"])
|
||
|
||
# 方法2:使用API客户端类
|
||
from src.send import MemosAPI
|
||
api = MemosAPI()
|
||
result = api.send_memo("内容", visibility="PUBLIC", tags=["测试"])
|
||
```
|
||
|
||
#### 配置管理使用示例
|
||
```python
|
||
# 方法1:使用ConfigManager类
|
||
from src.config import ConfigManager
|
||
config = ConfigManager()
|
||
config.set('MEMOS_BASE_URL', 'https://memos.example.com')
|
||
url = config.get('MEMOS_BASE_URL')
|
||
config.show_config()
|
||
|
||
# 方法2:使用便捷函数
|
||
from src.config import set_config, get_config
|
||
set_config('MEMOS_TOKEN', 'your-token-here')
|
||
token = get_config('MEMOS_TOKEN')
|
||
```
|
||
|
||
#### 命令行配置管理
|
||
```bash
|
||
# 显示当前配置
|
||
python src/config.py show
|
||
|
||
# 设置配置项
|
||
python src/config.py set MEMOS_BASE_URL https://memos.example.com
|
||
python src/config.py set MEMOS_TOKEN your-token-here
|
||
|
||
# 获取配置项
|
||
python src/config.py get MEMOS_BASE_URL
|
||
|
||
# 验证配置
|
||
python src/config.py validate
|
||
```
|
||
|
||
## Development Notes
|
||
|
||
This project now has a functional Memos API client implementation. The core functionality for content posting is complete and tested. Remaining work includes:
|
||
- CLI argument parsing for command-line interface
|
||
- AI model integration for tag recommendations and summarization
|
||
- Enhanced configuration management
|
||
- Testing framework setup |