feat(namespace): implement Plan #71 CI repo standardization, schema_version parity & path normalization
This commit is contained in:
1 parent
1e2968f84e
commit
3945e3648a
14 files changed
+69
-50
No files matched your search
@@ -20,16 +20,11 @@ from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from hyperstitionstud_io import __version__ as CURRENT_VERSION
|
||||
from hyperstitionstud_io.config import load_workspace_config
|
||||
from hyperstitionstud_io.config import load_workspace_config, normalize_workspace_relpath
|
||||
|
||||
|
||||
def _norm_ws_path(p: Path | str, workspace_root: str | Path | None = None) -> str:
|
||||
cfg = load_workspace_config(workspace_root=workspace_root)
|
||||
ws_res = str(cfg.workspace_root.resolve())
|
||||
s = str(Path(p).resolve())
|
||||
if s.startswith(ws_res):
|
||||
return "/workspace" + s[len(ws_res):]
|
||||
return str(p)
|
||||
return normalize_workspace_relpath(p, workspace_root=workspace_root)
|
||||
|
||||
|
||||
def prepare_and_verify_deploy_scripts(
|
||||
|
||||
@@ -60,9 +60,7 @@ def _resolve_web_route_to_disk(route: str, cfg: Any) -> Path:
|
||||
core = cfg.core_dir
|
||||
zoo = cfg.zoology_dir
|
||||
kg = cfg.knowledge_graph_dir
|
||||
ci = cfg.paths.get("ci_build_dir") or (cfg.workspace_root / "hyperdope-ci-build")
|
||||
if not ci.is_dir() and (cfg.workspace_root / "ingglish-hyperdope-ci").is_dir():
|
||||
ci = cfg.workspace_root / "ingglish-hyperdope-ci"
|
||||
ci = cfg.ci_build_dir
|
||||
|
||||
if route == "/":
|
||||
return core / "site" / "index.html"
|
||||
|
||||
@@ -17,6 +17,8 @@ from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from hyperstitionstud_io import __version__ as _PKG_VERSION
|
||||
|
||||
CORE_REPO_ROOT = Path(__file__).resolve().parents[3]
|
||||
WORKSPACE_ROOT = CORE_REPO_ROOT.parent
|
||||
USER_WORKSPACE_TOML = Path.home() / ".config" / "hyperstitionstud.io" / "workspace.toml"
|
||||
@@ -173,7 +175,7 @@ def load_json_cached(path: str | Path, *, copy_result: bool = True) -> Any:
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class WorkspaceConfig:
|
||||
schema_version: str = "1.2.0"
|
||||
schema_version: str = _PKG_VERSION
|
||||
namespace_urn: str = "urn:io:hyperstitionstud"
|
||||
workspace_root: Path = WORKSPACE_ROOT
|
||||
paths: dict[str, Path] = field(default_factory=dict)
|
||||
@@ -288,7 +290,7 @@ def load_workspace_config(
|
||||
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")),
|
||||
schema_version=str(raw.get("schema_version", _PKG_VERSION)),
|
||||
namespace_urn=str(raw.get("namespace_urn", "urn:io:hyperstitionstud")),
|
||||
workspace_root=ws_root,
|
||||
paths=resolved_paths,
|
||||
|
||||
@@ -760,7 +760,7 @@ def call_mcp_tool(name: str, arguments: dict[str, Any]) -> dict[str, Any]:
|
||||
{
|
||||
"id": "ONBOARDING-INGGLISH-AQ",
|
||||
"category": "manuals",
|
||||
"md_path": (cfg.paths.get("ci_repo_dir") or (cfg.workspace_root / "hyperdope-ci-build")) / "ONBOARDING-INGGLISH-AQ.md",
|
||||
"md_path": cfg.ci_build_dir / "ONBOARDING-INGGLISH-AQ.md",
|
||||
"web_pdf_route": "/ci/ONBOARDING-INGGLISH-AQ.pdf",
|
||||
},
|
||||
{
|
||||
|
||||
@@ -949,7 +949,7 @@ def audit_and_fix_multi_compressed_files(
|
||||
cfg.zoology_dir,
|
||||
cfg.knowledge_graph_dir,
|
||||
cfg.paths["gematria_js_dir"],
|
||||
cfg.paths.get("ci_repo_dir", cfg.workspace_root / "hyperdope-ci-build"),
|
||||
cfg.ci_build_dir,
|
||||
]
|
||||
for ed in extra_dirs or []:
|
||||
ep = Path(ed)
|
||||
|
||||
@@ -348,7 +348,7 @@ def introspect_live_ui_elements(workspace_root: str | Path | None = None) -> dic
|
||||
core = cfg.core_dir
|
||||
kg = cfg.knowledge_graph_dir
|
||||
calc_dir = cfg.paths["gematria_js_dir"]
|
||||
ci_dir = cfg.paths.get("ci_repo_dir") or (cfg.workspace_root / "hyperdope-ci-build")
|
||||
ci_dir = cfg.ci_build_dir
|
||||
|
||||
surfaces: dict[str, Path] = {
|
||||
"home": core / "site" / "index.html",
|
||||
|
||||
@@ -639,9 +639,7 @@ def discover_web_and_repo_pdf_pairs(workspace_root: str | Path | None = None) ->
|
||||
core = cfg.core_dir
|
||||
zoo = cfg.zoology_dir
|
||||
kg = cfg.knowledge_graph_dir
|
||||
ci = cfg.paths.get("ci_build_dir") or (cfg.workspace_root / "hyperdope-ci-build")
|
||||
if not ci.is_dir() and (cfg.workspace_root / "ingglish-hyperdope-ci").is_dir():
|
||||
ci = cfg.workspace_root / "ingglish-hyperdope-ci"
|
||||
ci = cfg.ci_build_dir
|
||||
|
||||
web_surfaces = [
|
||||
core / "site" / "index.html",
|
||||
|
||||
@@ -34,7 +34,7 @@ if _SRC_DIR.is_dir() and str(_SRC_DIR) not in sys.path:
|
||||
sys.path.insert(0, str(_SRC_DIR))
|
||||
|
||||
from hyperstitionstud_io import __version__ as CURRENT_VERSION # noqa: E402
|
||||
from hyperstitionstud_io.config import load_workspace_config # noqa: E402
|
||||
from hyperstitionstud_io.config import load_workspace_config, resolve_workspace_repo_dir # noqa: E402
|
||||
|
||||
STATUS_START = "<!-- HS-COMMIT-STATUS:START -->"
|
||||
STATUS_END = "<!-- HS-COMMIT-STATUS:END -->"
|
||||
@@ -90,12 +90,7 @@ def _git_out(repo_dir: Path, args: list[str], strip_leading: bool = True) -> str
|
||||
|
||||
|
||||
def _resolve_repo_dir(ws_root: Path, repo_key: str) -> Path:
|
||||
cand = ws_root / repo_key
|
||||
if cand.is_dir():
|
||||
return cand
|
||||
if repo_key == "hyperdope-ci-build" and (ws_root / "ingglish-hyperdope-ci").is_dir():
|
||||
return ws_root / "ingglish-hyperdope-ci"
|
||||
return cand
|
||||
return resolve_workspace_repo_dir(ws_root, repo_key)
|
||||
|
||||
|
||||
def _introspect_repo_commit_context(repo_dir: Path, version: str) -> dict[str, Any]:
|
||||
|
||||
@@ -173,7 +173,7 @@ def collect_workspace_change_signals(ws_root: Path | None = None) -> dict[str, A
|
||||
cfg.zoology_dir,
|
||||
kg,
|
||||
cfg.paths["gematria_js_dir"],
|
||||
cfg.paths.get("ci_repo_dir", cfg.workspace_root / "hyperdope-ci-build"),
|
||||
cfg.ci_build_dir,
|
||||
]
|
||||
repo_diff_summary: dict[str, dict[str, int]] = {}
|
||||
total_dirty = 0
|
||||
@@ -491,12 +491,14 @@ def sync_workspace_version(target_version: str, check_only: bool = False, ws_roo
|
||||
path.write_text(updated, encoding="utf-8")
|
||||
modified_files.append(str(path))
|
||||
|
||||
if not check_only:
|
||||
ws_toml = cfg.workspace_root / "workspace.toml"
|
||||
if ws_toml.is_file():
|
||||
orig_ws = ws_toml.read_text(encoding="utf-8")
|
||||
upd_ws = re.sub(rf'schema_version\s*=\s*"{SEMVER_RE}"', f'schema_version = "{v}"', orig_ws, flags=re.M)
|
||||
if upd_ws != orig_ws:
|
||||
ws_toml = cfg.workspace_root / "workspace.toml"
|
||||
if ws_toml.is_file():
|
||||
orig_ws = ws_toml.read_text(encoding="utf-8")
|
||||
upd_ws = re.sub(rf'schema_version\s*=\s*"{SEMVER_RE}"', f'schema_version = "{v}"', orig_ws, flags=re.M)
|
||||
if upd_ws != orig_ws:
|
||||
if check_only:
|
||||
mismatched_files.append(str(ws_toml))
|
||||
else:
|
||||
ws_toml.write_text(upd_ws, encoding="utf-8")
|
||||
modified_files.append(str(ws_toml))
|
||||
|
||||
|
||||
Reference in new issue
Block a user