mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-09-22 00:32:49 +00:00
docs(protocol): add typed edge link protocol documentation Add comprehensive documentation for the link protocol supporting typed edges in body text. This includes specification for three legal inline forms (bare wikilink, line-level Dataview, inline-bracketed Dataview), predicate syntax rules, and the machine-managed Relations section convention for organizing discovered edges. fix(memory): update path reference from vault_root to working_dir Change the memory_create operation's path anchoring from vault_root to working_dir to maintain consistency with the current working directory configuration. refactor(components): remove edge_extractor module and simplify parsing Remove the edge_extractor component module entirely and inline edge extraction logic directly into LinkedFileParser using parse_wikilinks utility. This simplifies the architecture by eliminating the separate edge extraction component and delegating edge discovery to the maintainer's enrichment operations. feat(parser): update parse method signature and simplify edge extraction Modify LinkedFileParser to return (FileNode, list[FileChunk]) tuple instead of ParsedFile, remove dependency on BaseEdgeExtractor, and implement direct wikilink parsing from body text only. ```
51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
"""FileNode — engine-level file index entry.
|
|
|
|
Structural fields only: `path`, `st_mtime`, `edges`. Frontmatter fields
|
|
ride along as Pydantic extras (model_config has `extra="allow"`), so a
|
|
markdown file's parsed frontmatter dict is flattened into the node:
|
|
|
|
FileNode(path=..., st_mtime=..., edges=[...], **frontmatter_dict)
|
|
|
|
Two convenience properties:
|
|
|
|
* `file` — `Path(self.path).stem`, the filename without extension.
|
|
* `metadata` — dict view of the extras (the original frontmatter).
|
|
|
|
Domain-aware code that wants typed access to memory-schema fields
|
|
(lifecycle / scope / source / role / status / confidence …) wraps with
|
|
`reme2.memory.schema.MemoryFileNode.model_validate(node.model_dump())`.
|
|
|
|
The engine layer (file_store, file_parser, file_watcher) never imports
|
|
the memory schema — it stays domain-agnostic and just shuttles
|
|
`FileNode` instances around with their extras intact.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
from reme2.schema.file_edge import FileEdge
|
|
|
|
|
|
class FileNode(BaseModel):
|
|
model_config = ConfigDict(extra="allow")
|
|
|
|
path: str = Field(...)
|
|
st_mtime: float = Field(...)
|
|
edges: list["FileEdge"] = Field(default_factory=list)
|
|
|
|
@property
|
|
def file(self) -> str:
|
|
"""Filename stem derived from `path` (no extension)."""
|
|
return Path(self.path).stem
|
|
|
|
@property
|
|
def metadata(self) -> dict:
|
|
"""Frontmatter dict view — extras stored via `extra="allow"`.
|
|
|
|
Returns a fresh copy so callers can't mutate the node's internal
|
|
state by writing into the dict.
|
|
"""
|
|
return dict(self.__pydantic_extra__ or {})
|