feat(core): initialize hyperstitionstudio-core (hyperstitionstud_io.* / urn:io:hyperstitionstud:*) shared library, 4897-entry offline CMUdict fallback, local-config citation resolver, CLI entrypoints, and test suite (v1.2.0)

This commit is contained in:
Hermes Agent committed 2026-11-29 21:06:48 +00:00
commit f8235a2037
32 files changed
+6646

No files matched your search

@@ -0,0 +1,93 @@
"""
hyperstitionstud_io.config — Declarative Local Workspace Configuration Loader.
"""
from __future__ import annotations
import os
import tomllib
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any
DEFAULT_WORKSPACE_TOML = Path("/workspace/workspace.toml")
USER_WORKSPACE_TOML = Path.home() / ".config" / "hyperstitionstud.io" / "workspace.toml"
@dataclass(frozen=True)
class WorkspaceConfig:
schema_version: str = "1.2.0"
namespace_urn: str = "urn:io:hyperstitionstud"
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)
source_file: Path | None = None
@property
def core_dir(self) -> Path:
return self.paths.get("core_dir", Path("/workspace/hyperstitionstudio-core"))
@property
def archive_dir(self) -> Path:
return self.paths.get("archive_dir", Path("/workspace/ingglish-hyperdope-gematria"))
@property
def zoology_dir(self) -> Path:
return self.paths.get("zoology_dir", Path("/workspace/technocapital-singularity-zoology"))
@property
def knowledge_graph_dir(self) -> Path:
return self.paths.get("knowledge_graph_dir", Path("/workspace/encyclopedia-knowledge-graph"))
@property
def ci_build_dir(self) -> Path:
return self.paths.get("ci_build_dir", Path("/workspace/hyperdope-ci-build"))
def load_workspace_config(explicit_path: str | Path | None = None) -> WorkspaceConfig:
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])
chosen: Path | None = None
for c in candidates:
if c.is_file():
chosen = c
break
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"),
},
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,
)
raw: dict[str, Any] = tomllib.loads(chosen.read_text(encoding="utf-8"))
raw_paths = raw.get("paths", {})
raw_iso = raw.get("isolation", {})
raw_cit = raw.get("citations", {}).get("path_mounts", {})
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()},
source_file=chosen,
)