mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-09-22 00:32:49 +00:00
feat(file_watcher): add directory deletion support with descendant indexing Add support for deleting entire directories and their indexed descendants in the file watcher. Previously only individual file deletions were handled properly. Now when a directory is deleted, the system finds all indexed files beneath that directory path and removes them along with their metadata and chunks. The implementation includes: - New `_descendant_indexed_paths` method to find all indexed files under a given directory path - Updated `_on_deleted` method to process both the target path and all its indexed descendants - Proper handling of symlinks and path resolution differences - Enhanced logging to show directory deletion with child count Also adds necessary os import for path operations. refactor(config): restructure configuration profiles for clarity Rename curated.yaml to remove outdated configuration file and rename full.yaml to expert.yaml with updated documentation. Add new service.yaml configuration profile that provides a service-aligned MCP surface with three main tools: - retrieve: graph-aware hybrid retrieval - remember: single write entry point with log/distill modes - maintain: vault hygiene sweep The expert configuration now excludes the ingest tool since cold-path operations are handled by external agents, and adds memory_lint tool for structural issue detection. Updated documentation to clarify the different configuration profiles and their intended usage patterns. ```
39 lines
1.4 KiB
Python
39 lines
1.4 KiB
Python
"""Tolerant parser — never raises, always returns (memory_or_None, errors).
|
|
|
|
Used by:
|
|
- Maintainer.lint : surfaces schema violations on existing files
|
|
- any read path : turn raw frontmatter into a typed view when possible
|
|
|
|
For *write* paths (`sync`, Ingestor) call `Memory.model_validate`
|
|
directly so validation errors propagate as exceptions and stop the write.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pydantic import ValidationError
|
|
|
|
from .memory import Memory
|
|
|
|
|
|
def parse_frontmatter(raw: dict) -> tuple[Memory | None, list[str]]:
|
|
"""Tolerant parse. Returns (parsed, errors).
|
|
|
|
Success → (Memory(...), [])
|
|
Failure → (None, ["loc: msg", ...])
|
|
|
|
Migration is automatic via Memory's `model_validator(mode='before')`,
|
|
so frontmatter that only carries the legacy `category` field still
|
|
parses successfully.
|
|
"""
|
|
if not isinstance(raw, dict):
|
|
return None, [f"frontmatter must be a dict, got {type(raw).__name__}"]
|
|
try:
|
|
return Memory.model_validate(raw), []
|
|
except ValidationError as e:
|
|
msgs: list[str] = []
|
|
for err in e.errors(include_context=False, include_url=False):
|
|
loc = ".".join(str(x) for x in err.get("loc", ()))
|
|
msgs.append(f"{loc}: {err.get('msg', '')}".strip(": "))
|
|
return None, msgs
|
|
except Exception as e: # noqa: BLE001 — defensive: never raise from a tolerant parser
|
|
return None, [f"{type(e).__name__}: {e}"]
|