mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-09-23 00:43:18 +00:00
- add neo4j dependency to project requirements - introduce NetworkXFileGraph to replace LocalFileGraph implementation - rename local_file_graph.py to networkx_file_graph.py with updated component registration as 'networkx' - remove pickle persistence logic from NetworkX backend, simplify initialization - update Neo4jFileGraph to return FileLink objects instead of (FileNode, FileLink) tuples from get_inlinks/get_outlinks methods - remove unused AsyncIterator import and adjust method signatures - add BareFileParser for handling binary/attachment files without content parsing - move wikilink resolution utilities to dedicated utility module - refactor memory I/O to use file graph's link resolution methods directly - remove link extraction utilities from schema module, consolidate in utils.wikilink_resolver
61 lines
2.3 KiB
Python
61 lines
2.3 KiB
Python
"""FileLink — typed wikilink between vault files.
|
|
|
|
One type, two states (the value of ``path`` distinguishes them):
|
|
|
|
* **pre-resolution** — ``path`` holds the raw wikilink target as
|
|
written, e.g. ``"Foo"`` or ``"topics/Bar"``.
|
|
* **resolved** — ``path`` holds the vault-relative path
|
|
file_graph stores, e.g. ``"topics/Foo/Foo.md"``.
|
|
|
|
The extractor (``utils.wikilink_resolver.iter_links``) produces the
|
|
pre-resolution form from body text. The resolver
|
|
(``utils.wikilink_resolver.resolve_links``, or one-shot
|
|
``text_to_links``) rewrites ``path`` to the resolved form, expanding
|
|
stem ambiguity into one ``FileLink`` per candidate.
|
|
|
|
file_graph trusts ``link.path`` directly for adjacency: it only ever
|
|
stores resolved links. The pre-resolution form is internal pipeline
|
|
plumbing.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
class FileLink(BaseModel):
|
|
"""Typed wikilink — ``(path, anchor, predicate)``.
|
|
|
|
Single type for both states (see module docstring): ``path`` is
|
|
a raw wikilink target before resolution, a vault-relative resolved
|
|
path after.
|
|
|
|
Fields:
|
|
path wikilink target. Raw target text in pre-resolution
|
|
form (e.g. ``"Foo"``, ``"topics/Bar"``);
|
|
vault-relative resolved path in stored form
|
|
(e.g. ``"topics/Foo/Foo.md"``).
|
|
anchor heading or block anchor (text after ``#`` in the
|
|
wikilink). Pass-through across resolution.
|
|
predicate Dataview-style typed-link predicate; ``None`` for bare.
|
|
"""
|
|
|
|
model_config = ConfigDict(extra="forbid")
|
|
|
|
path: str = Field(
|
|
...,
|
|
description=(
|
|
"Wikilink target. Pre-resolution: the raw target as written "
|
|
"(e.g. 'Foo'). Resolved: the vault-relative path file_graph "
|
|
"stores. Stem ambiguity is resolved BEFORE construction of "
|
|
"the resolved form by emitting one FileLink per candidate."
|
|
),
|
|
)
|
|
anchor: str | None = Field(
|
|
default=None,
|
|
description="Heading or block anchor (text after '#'). None if absent.",
|
|
)
|
|
predicate: str | None = Field(
|
|
default=None,
|
|
description="Typed-link predicate (Dataview-style). None for bare [[X]].",
|
|
)
|