feat(portability): add __file__-anchored WORKSPACE_ROOT discovery, cross-OS font resolver, and public HTTP onboarding quickstart (v1.2.0)
This commit is contained in:
1 parent
f8235a2037
commit
4e38541fbf
7 files changed
+227
-103
No files matched your search
@@ -1,5 +1,8 @@
|
||||
"""
|
||||
hyperstitionstud_io.config — Declarative Local Workspace Configuration Loader.
|
||||
hyperstitionstud_io.config — Location-Independent Declarative Workspace Configuration Loader.
|
||||
Derives WORKSPACE_ROOT dynamically from __file__ so sibling repositories cloned into any local
|
||||
parent directory (e.g., ~/hyperstition-workspace/, /tmp/test/, or /workspace/) resolve with zero
|
||||
hardcoded /workspace assumptions.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -10,7 +13,8 @@ from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
DEFAULT_WORKSPACE_TOML = Path("/workspace/workspace.toml")
|
||||
CORE_REPO_ROOT = Path(__file__).resolve().parents[2]
|
||||
WORKSPACE_ROOT = CORE_REPO_ROOT.parent
|
||||
USER_WORKSPACE_TOML = Path.home() / ".config" / "hyperstitionstud.io" / "workspace.toml"
|
||||
|
||||
|
||||
@@ -18,6 +22,7 @@ USER_WORKSPACE_TOML = Path.home() / ".config" / "hyperstitionstud.io" / "workspa
|
||||
class WorkspaceConfig:
|
||||
schema_version: str = "1.2.0"
|
||||
namespace_urn: str = "urn:io:hyperstitionstud"
|
||||
workspace_root: Path = WORKSPACE_ROOT
|
||||
paths: dict[str, Path] = field(default_factory=dict)
|
||||
read_only_files: list[Path] = field(default_factory=list)
|
||||
citation_path_mounts: dict[str, str] = field(default_factory=dict)
|
||||
@@ -25,33 +30,57 @@ class WorkspaceConfig:
|
||||
|
||||
@property
|
||||
def core_dir(self) -> Path:
|
||||
return self.paths.get("core_dir", Path("/workspace/hyperstitionstudio-core"))
|
||||
return self.paths.get("core_dir", self.workspace_root / "hyperstitionstudio-core")
|
||||
|
||||
@property
|
||||
def archive_dir(self) -> Path:
|
||||
return self.paths.get("archive_dir", Path("/workspace/ingglish-hyperdope-gematria"))
|
||||
return self.paths.get("archive_dir", self.workspace_root / "ingglish-hyperdope-gematria")
|
||||
|
||||
@property
|
||||
def zoology_dir(self) -> Path:
|
||||
return self.paths.get("zoology_dir", Path("/workspace/technocapital-singularity-zoology"))
|
||||
return self.paths.get("zoology_dir", self.workspace_root / "technocapital-singularity-zoology")
|
||||
|
||||
@property
|
||||
def knowledge_graph_dir(self) -> Path:
|
||||
return self.paths.get("knowledge_graph_dir", Path("/workspace/encyclopedia-knowledge-graph"))
|
||||
return self.paths.get("knowledge_graph_dir", self.workspace_root / "encyclopedia-knowledge-graph")
|
||||
|
||||
@property
|
||||
def ci_build_dir(self) -> Path:
|
||||
return self.paths.get("ci_build_dir", Path("/workspace/hyperdope-ci-build"))
|
||||
return self.paths.get("ci_build_dir", self.workspace_root / "hyperstition-ci-build")
|
||||
|
||||
|
||||
def load_workspace_config(explicit_path: str | Path | None = None) -> WorkspaceConfig:
|
||||
def _rebase_path(raw_path: str | Path, ws_root: Path) -> Path:
|
||||
s_raw = str(raw_path).strip()
|
||||
if s_raw.startswith("./") or not Path(s_raw).is_absolute():
|
||||
return (ws_root / s_raw).resolve()
|
||||
p = Path(s_raw)
|
||||
if p.exists():
|
||||
return p.resolve()
|
||||
s = p.as_posix()
|
||||
if s.startswith("/workspace/"):
|
||||
rel = s[len("/workspace/") :]
|
||||
cand = ws_root / rel
|
||||
if cand.exists() or ws_root != Path("/workspace"):
|
||||
return cand.resolve()
|
||||
return p
|
||||
|
||||
|
||||
def load_workspace_config(
|
||||
explicit_path: str | Path | None = None,
|
||||
workspace_root: str | Path | None = None,
|
||||
) -> WorkspaceConfig:
|
||||
ws_root = Path(workspace_root).resolve() if workspace_root else WORKSPACE_ROOT
|
||||
candidates: list[Path] = []
|
||||
if explicit_path:
|
||||
candidates.append(Path(explicit_path))
|
||||
env_p = os.environ.get("HYPERSTITIONSTUDIO_CONFIG", "").strip()
|
||||
if env_p:
|
||||
candidates.append(Path(env_p))
|
||||
candidates.extend([DEFAULT_WORKSPACE_TOML, USER_WORKSPACE_TOML])
|
||||
candidates.extend([
|
||||
ws_root / "workspace.toml",
|
||||
USER_WORKSPACE_TOML,
|
||||
Path("/workspace/workspace.toml"),
|
||||
])
|
||||
|
||||
chosen: Path | None = None
|
||||
for c in candidates:
|
||||
@@ -59,22 +88,31 @@ def load_workspace_config(explicit_path: str | Path | None = None) -> WorkspaceC
|
||||
chosen = c
|
||||
break
|
||||
|
||||
if chosen is not None and workspace_root is None:
|
||||
ws_root = chosen.resolve().parent
|
||||
|
||||
default_paths = {
|
||||
"core_dir": ws_root / "hyperstitionstudio-core",
|
||||
"archive_dir": ws_root / "ingglish-hyperdope-gematria",
|
||||
"zoology_dir": ws_root / "technocapital-singularity-zoology",
|
||||
"knowledge_graph_dir": ws_root / "encyclopedia-knowledge-graph",
|
||||
"ci_build_dir": ws_root / "hyperdope-ci-build",
|
||||
"gematria_js_dir": ws_root / "hyperdope-gematria",
|
||||
"memes_dir": ws_root / "memes",
|
||||
}
|
||||
default_ro = [
|
||||
default_paths["zoology_dir"] / "taxonomy" / "glossary-registry.json",
|
||||
default_paths["zoology_dir"] / "encyclopedia" / "encyclopedia-manifest.json",
|
||||
]
|
||||
|
||||
if chosen is None:
|
||||
return WorkspaceConfig(
|
||||
paths={
|
||||
"core_dir": Path("/workspace/hyperstitionstudio-core"),
|
||||
"archive_dir": Path("/workspace/ingglish-hyperdope-gematria"),
|
||||
"zoology_dir": Path("/workspace/technocapital-singularity-zoology"),
|
||||
"knowledge_graph_dir": Path("/workspace/encyclopedia-knowledge-graph"),
|
||||
"ci_build_dir": Path("/workspace/hyperdope-ci-build"),
|
||||
"gematria_js_dir": Path("/workspace/hyperdope-gematria"),
|
||||
"memes_dir": Path("/workspace/memes"),
|
||||
workspace_root=ws_root,
|
||||
paths=default_paths,
|
||||
read_only_files=default_ro,
|
||||
citation_path_mounts={
|
||||
str(default_paths["archive_dir"]): "https://git.libre.audio/m00t/ingglish-hyperdope-gematria/src/branch/main"
|
||||
},
|
||||
read_only_files=[
|
||||
Path("/workspace/technocapital-singularity-zoology/taxonomy/glossary-registry.json"),
|
||||
Path("/workspace/technocapital-singularity-zoology/encyclopedia/encyclopedia-manifest.json"),
|
||||
],
|
||||
citation_path_mounts={},
|
||||
source_file=None,
|
||||
)
|
||||
|
||||
@@ -83,11 +121,16 @@ def load_workspace_config(explicit_path: str | Path | None = None) -> WorkspaceC
|
||||
raw_iso = raw.get("isolation", {})
|
||||
raw_cit = raw.get("citations", {}).get("path_mounts", {})
|
||||
|
||||
resolved_paths = {k: _rebase_path(v, ws_root) for k, v in raw_paths.items()} if raw_paths else default_paths
|
||||
resolved_ro = [_rebase_path(p, ws_root) for p in raw_iso.get("read_only_files", [])] if raw_iso.get("read_only_files") else default_ro
|
||||
resolved_mounts = {str(_rebase_path(k, ws_root)): str(v) for k, v in raw_cit.items()}
|
||||
|
||||
return WorkspaceConfig(
|
||||
schema_version=str(raw.get("schema_version", "1.2.0")),
|
||||
namespace_urn=str(raw.get("namespace_urn", "urn:io:hyperstitionstud")),
|
||||
paths={k: Path(v) for k, v in raw_paths.items()},
|
||||
read_only_files=[Path(p) for p in raw_iso.get("read_only_files", [])],
|
||||
citation_path_mounts={str(k): str(v) for k, v in raw_cit.items()},
|
||||
workspace_root=ws_root,
|
||||
paths=resolved_paths,
|
||||
read_only_files=resolved_ro,
|
||||
citation_path_mounts=resolved_mounts,
|
||||
source_file=chosen,
|
||||
)
|
||||
Reference in new issue
Block a user