Add memory_manager source files and tests
Some checks failed
CI / build (push) Has been cancelled
CI / test (push) Has been cancelled

This commit is contained in:
2026-03-22 16:18:59 +00:00
parent 71a6e02e04
commit 6fd2644296

View File

@@ -1,24 +1,27 @@
"""Pydantic schemas for API."""
"""Pydantic schemas for API request/response validation."""
from datetime import datetime
from typing import List, Optional
from typing import Any
from pydantic import BaseModel, Field
from memory_manager.db.models import MemoryCategory
class MemoryEntryCreate(BaseModel):
title: str = Field(..., min_length=1, max_length=255)
content: str = Field(..., min_length=1)
category: str = Field(...)
tags: List[str] = Field(default_factory=list)
agent_id: Optional[str] = Field(default="unknown")
project_path: Optional[str] = Field(default=".")
parent_id: Optional[int] = None
category: MemoryCategory
tags: list[str] = Field(default_factory=list)
agent_id: str | None = None
project_path: str | None = None
class MemoryEntryUpdate(BaseModel):
title: Optional[str] = Field(None, min_length=1, max_length=255)
content: Optional[str] = Field(None, min_length=1)
category: Optional[str] = None
tags: Optional[List[str]] = None
title: str | None = Field(None, min_length=1, max_length=255)
content: str | None = Field(None, min_length=1)
category: MemoryCategory | None = None
tags: list[str] | None = None
class MemoryEntryResponse(BaseModel):
@@ -26,21 +29,25 @@ class MemoryEntryResponse(BaseModel):
title: str
content: str
category: str
tags: List[str]
tags: list[str]
agent_id: str
project_path: str
created_at: datetime
updated_at: datetime
parent_id: Optional[int] = None
created_at: datetime | None
updated_at: datetime | None
class Config:
from_attributes = True
class SearchQuery(BaseModel):
q: str = Field(..., min_length=1)
category: MemoryCategory | None = None
agent_id: str | None = None
project_path: str | None = None
limit: int = Field(default=100, ge=1, le=1000)
class CommitCreate(BaseModel):
message: str = Field(..., min_length=1)
agent_id: Optional[str] = Field(default="unknown")
project_path: Optional[str] = Field(default=".")
agent_id: str | None = None
project_path: str | None = None
class CommitResponse(BaseModel):
@@ -49,21 +56,24 @@ class CommitResponse(BaseModel):
message: str
agent_id: str
project_path: str
created_at: datetime
class Config:
from_attributes = True
snapshot: list[dict[str, Any]]
created_at: datetime | None
class DiffResponse(BaseModel):
hash1: str
hash2: str
added: List[dict]
removed: List[dict]
modified: List[dict]
commit1: dict[str, Any]
commit2: dict[str, Any]
added: list[dict[str, Any]]
removed: list[dict[str, Any]]
modified: list[dict[str, Any]]
class HealthResponse(BaseModel):
status: str
version: str
class StatsResponse(BaseModel):
total_entries: int
entries_by_category: dict[str, int]
total_commits: int
category_counts: dict