ReMe/reme/utils/files/paths.py
jinliyl 54fa3381d7
Some checks failed
CI and Release / Docker / Build and test / amd64 (push) Has been cancelled
CI and Release / Docker / Build and test / arm64 (push) Has been cancelled
Security / CodeQL / Analyze python (push) Has been cancelled
CI / Python quality / Pre-commit (push) Has been cancelled
CI / Python tests / Unit Tests - py3.12 (push) Has been cancelled
CI / Python tests / Unit Tests - py3.13 (push) Has been cancelled
CI / Python tests / Unit Tests - py3.14 (push) Has been cancelled
CI / Python packages / Build and verify distributions (push) Has been cancelled
CI / Python quality / GitHub Actions (push) Has been cancelled
CI / Python tests / Hermes embedded - ubuntu-latest (push) Has been cancelled
CI / Python tests / Hermes embedded - windows-latest (push) Has been cancelled
CI / Python tests / Unit Tests - py3.11 (push) Has been cancelled
CI / ReMe Studio / Studio checks (push) Has been cancelled
Deploy / Documentation / Build documentation (push) Has been cancelled
CI / Windows / CLI smoke - py3.11 (push) Has been cancelled
Security / CodeQL / Analyze javascript-typescript (push) Has been cancelled
CI and Release / Docker / Publish multi-platform tags (push) Has been cancelled
Deploy / Documentation / deploy (push) Has been cancelled
refactor(core): reorganize the ReMe runtime and shared helpers (#769)
* refactor(core): reorganize the ReMe runtime and shared helpers

* test(status): import the base component from its canonical module

* test: remove redundant unit checks

* refactor(core): use canonical runtime imports and shared CLI discovery

Restore evolve behavior to the base branch and update its imports. Use Application as the runtime entry point and encode SSE in the HTTP service.

* fix(cli): honor caller config when service replay is incomplete

Use partial startup overrides for port probes and resolve named configs before requesting the service process working directory.
2026-11-20 22:06:46 +08:00

25 lines
1 KiB
Python

"""Shared workspace path spelling and lexical normalization."""
import posixpath
def canonical_index_path(path: str) -> str:
"""Return the workspace-relative POSIX spelling used as index identity.
Indexes persisted by older Windows builds store native separators in
``FileNode.path`` and ``FileChunk.path``, while the tag index, the search
filter and freshly indexed files use POSIX separators. Every consumer
compares these identities, so the same canonical form is applied when
loading, when writing and to query arguments; otherwise the two spellings
address different files.
Only separators are rewritten. Rejecting absolute or escaping paths stays
with the caller that owns the containment rule.
"""
return path.replace("\\", "/")
def normalize_posix_path(path: str) -> str:
"""Return a normalized, workspace-relative POSIX path string."""
normalized = posixpath.normpath(canonical_index_path((path or "").strip()).strip("/"))
return "" if normalized == "." else normalized