#!/usr/bin/env python3 """ hyperstitionstud_io.publishing.readme_sync — Deterministic Root `README.md` Synchronizer & Git Pre-Commit Hook Manager (`hs-readme-sync`). Maintains canonical root `README.md` files across all 6 repositories in the `hyperstitionstud.io` ecosystem: 1. `hyperstitionstudio-core` 2. `ingglish-hyperdope-gematria` 3. `technocapital-singularity-zoology` 4. `encyclopedia-knowledge-graph` 5. `haiperdohp-jemaytreeah` 6. `hyperdope-ci-build` (`ingglish-hyperdope-ci`) Each root `README.md` features: - An above-the-fold Gitea Commit & Release Telemetry Banner (` ... `) summarizing the repository's public route, latest commit/staged scope, touched files (excluding `README.md`), and live verified ecosystem metrics (`0` LLM tokens). - Canonical repository documentation kept 100% synchronized with `hyperstitionstud_io.__version__` and zero legacy `d-filter` text. - Idempotent `.git/hooks/pre-commit` installation so every commit automatically updates `/README.md` and stages it. """ from __future__ import annotations import argparse import json import os import re import subprocess import sys from pathlib import Path from typing import Any _SRC_DIR = Path(__file__).resolve().parents[2] 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 STATUS_START = "" STATUS_END = "" REPO_SPECS: dict[str, dict[str, str]] = { "hyperstitionstudio-core": { "gitea_slug": "hyperstitionstudio-core", "public_route": "https://hyperstitionstud.io/", "role": "Shared PEP 420 Python core library (`hyperstitionstud_io.*`), MCP/REST server, `/quant/`, `/learn/`, `/engineering/`, `/math/`, & `/donate/` webroots", }, "ingglish-hyperdope-gematria": { "gitea_slug": "ingglish-hyperdope-gematria", "public_route": "https://hyperstitionstud.io/archive/00-index-and-methodology.md", "role": "Master Ingglish Base-36 AQ News & Thematic Dossier Archive (`72` dossiers) & Zero-Synthetic-Data Financial/Macro Telemetry (`24` instruments)", }, "technocapital-singularity-zoology": { "gitea_slug": "technocapital-singularity-zoology", "public_route": "https://hyperstitionstud.io/zoology/encyclopedia-of-technocapital-singularity-zoology-overview-and-manifest.pdf", "role": "`S1-S6` & `M1-M7+` Taxonomy, `282`-Term Glossary, `ETI 0-100` Tier List, & `22`-Volume Alphabetized PDF Encyclopedia (`122` pages)", }, "encyclopedia-knowledge-graph": { "gitea_slug": "encyclopedia-knowledge-graph", "public_route": "https://hyperstitionstud.io/graph/index.html", "role": "`388`-Node / `1,282`-Edge Interactive Knowledge Graph Workbench (Modes 1-4), 6-Gate Verifier, & Architectural Plan/Release Archive", }, "haiperdohp-jemaytreeah": { "gitea_slug": "haiperdohp-jemaytreeah", "public_route": "https://hyperstitionstud.io/calc/index.html", "role": "Multi-Cipher Browser Gematria Workbench (`82` ciphers, `231,615` Ingglish-provisioned `db.txt` entries, progressive `db_lite.json` + `db.json` hydration)", }, "hyperdope-ci-build": { "gitea_slug": "ingglish-hyperdope-ci", "public_route": "https://hyperstitionstud.io/ci/ONBOARDING-INGGLISH-AQ.pdf", "role": "4-Gate CI/CD Ingglish Provisioning Pipeline (`100.0%` keep rate), `ci-audit-report.json`, & `db_ingglish_entries.txt`", }, } def _git_out(repo_dir: Path, args: list[str], strip_leading: bool = True) -> str: try: res = subprocess.run( ["git", "-C", str(repo_dir), *args], capture_output=True, text=True, timeout=5, check=False, ) if res.returncode == 0: return res.stdout.strip() if strip_leading else res.stdout.rstrip("\r\n") except Exception: pass return "" 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 def _introspect_repo_commit_context(repo_dir: Path, version: str) -> dict[str, Any]: """ Deterministically inspect staged or working-tree file paths for `repo_dir` (filtering out `README.md` and never echoing prior commit subject lines so old version strings can never leak into `README.md`). """ if not (repo_dir / ".git").exists(): return { "scope_summary": f"Synchronized v{version} release state & verified artifacts", "touched_files": ["README.md"], } # Check staged files first (for pre-commit hook) staged_raw = _git_out(repo_dir, ["diff", "--cached", "--name-only"]) staged = [ln.strip() for ln in staged_raw.splitlines() if ln.strip() and ln.strip() != "README.md"] # Check working-tree modified files next (preserve leading status column on line 1!) status_raw = _git_out(repo_dir, ["status", "--porcelain"], strip_leading=False) dirty: list[str] = [] for ln in status_raw.splitlines(): if not ln.strip(): continue p = re.sub(r"^[ MADRCU?!]{1,2}\s+", "", ln).split(" -> ")[-1].strip() if p and p != "README.md" and not p.startswith("untracked/"): dirty.append(p) head_files_raw = _git_out(repo_dir, ["diff-tree", "--no-commit-id", "--name-only", "-r", "HEAD"]) head_files = [ln.strip() for ln in head_files_raw.splitlines() if ln.strip() and ln.strip() != "README.md"] active_files = staged if staged else (dirty if dirty else head_files) dedup_files: list[str] = [] for f in active_files: if f not in dedup_files: dedup_files.append(f) if not dedup_files: dedup_files = ["README.md (release metadata sync)"] scope_summary = f"Synchronized v{version} release state across {len(dedup_files)} tracked module/artifact surface(s)" return { "scope_summary": scope_summary, "touched_files": dedup_files[:8], "total_touched_count": len(dedup_files), } def _render_status_banner(repo_key: str, version: str, ctx: dict[str, Any]) -> str: spec = REPO_SPECS[repo_key] files_list = ", ".join(f"`{p}`" for p in ctx["touched_files"]) extra = ctx.get("total_touched_count", len(ctx["touched_files"])) - len(ctx["touched_files"]) if extra > 0: files_list += f" (+{extra} more)" return "\n".join( [ STATUS_START, f"> **Gitea Commit & Release Telemetry (`v{version}` • Namespace `urn:io:hyperstitionstud`)**", f"> - **Repository Role & Public Route:** {spec['role']} → [`{spec['public_route']}`]({spec['public_route']})", f"> - **Latest Commit Scope (`{spec['gitea_slug']}`):** {ctx['scope_summary']}", f"> - **Touched Files / Surfaces:** {files_list}", f"> - **Live Verified Ecosystem Metrics (`v{version}`):** `6` Repositories • `17` CLI Entrypoints • `20` MCP/REST Tools • `14` URN Resources • `63` Verified Web Routes • `388` KG Nodes / `1,282` Edges • `282` Glossary Entries • `4,943` Offline CMUdict Phonetics • `0` Synthetic Data", STATUS_END, ] ) def _render_core_readme(version: str, banner: str) -> str: return f"""# `hyperstitionstudio-core` (`hyperstitionstud_io.*` — `v{version}`) {banner} Shared Python common library (`hyperstitionstud_io.*`), stateless read-only Model Context Protocol (`/mcp`) & OpenAPI 3.1 REST (`/api/v1/*`) server, SQLite FTS5 metadata catalog (`hs-db-build`), offline `URN:` JSON Schema registry (`urn:io:hyperstitionstud:schema:v1:*`), and Group 3 Stealth Basalt web workbenches (`/`, `/learn/`, `/quant/`, `/engineering/`, `/math/`, `/donate/`) with the 4-Ring Hardened Polyglot REPL (`Guile Scheme`, `TypeScript`, `Rust`) and Subtle Cybernetic Code Rain (`hs-matrix-coderain.js`). --- ## 5-Minute New-User Onboarding (Public HTTP Clone into Any Directory) ```bash # 1. Create a parent workspace folder anywhere on your machine mkdir -p ~/hyperstition-workspace && cd ~/hyperstition-workspace # 2. Clone the 6 peer repositories over public HTTPS (no SSH key required) git clone https://git.libre.audio/seasharp/hyperstitionstudio-core.git git clone https://git.libre.audio/seasharp/ingglish-hyperdope-gematria.git git clone https://git.libre.audio/seasharp/technocapital-singularity-zoology.git git clone https://git.libre.audio/seasharp/encyclopedia-knowledge-graph.git git clone https://git.libre.audio/seasharp/haiperdohp-jemaytreeah.git git clone -b feat/ingglish-aq-corpus https://git.libre.audio/seasharp/ingglish-hyperdope-ci.git # 2b. Supply the 3 untracked runtime files listed in haiperdohp-jemaytreeah/.gitignore (config.js, db.json, db_lite.json) cp haiperdohp-jemaytreeah/config.default.js haiperdohp-jemaytreeah/config.js (cd haiperdohp-jemaytreeah && python3 tools/generate_db_json.py db.txt db.json) # 3. Create & activate a local Python virtual environment and install dependencies python3 -m venv .venv source .venv/bin/activate pip install --upgrade pip pip install -r hyperstitionstudio-core/requirements.txt pip install --no-deps -e ./hyperstitionstudio-core # 4. Copy the location-independent workspace configuration and run the health check cp hyperstitionstudio-core/workspace.example.toml ./workspace.toml hs-doctor # 5. Run the 7-suite verification test runner (including ProtectSystem=strict EROFS introspection) python3 hyperstitionstudio-core/tests/test_core_suite.py # 6. Test the complete per-repository web deployment locally across all 63 HTTP routes + MCP/REST + P1-P6 smoke gates ./hyperstitionstudio-core/deploy/test-first-deployment.sh ``` --- ## Key Architecture & Capabilities (`v{version}`) 1. **17 CLI Entrypoints (`pyproject.toml [project.scripts]`):** - `hs-doctor`, `hs-citations`, `hs-pdf-build`, `hs-kg-build`, `hs-quant-harvest`, `hs-macro-harvest`, `hs-daily-brief`, `hs-ticker-card`, `hs-mcp`, `hs-db-build`, `hs-sync-version`, `hs-readme-sync`, `hs-archive-rotate`, `hs-public-smoke`, `hs-eng-docs`, `hs-math-docs`, and `hs-highlights`. 2. **20 Stateless Read-Only MCP & OpenAPI 3.1 REST Tools + HTTP `ETag` (`304 Not Modified`) Caching:** - Exposes all cipher, phonetics, knowledge-graph, `ETI`, financial/macro time-series, Bayesian daily-brief, polyglot AST sandbox, SQLite FTS5 catalog, and IPLD `dag-json` `CIDv1` tools over `/mcp` and `/api/v1/*`. 3. **Interactive Web Workbenches (`https://hyperstitionstud.io/`):** - `/` (Portal Home), `/learn/` (6-Module Interactive Track), `/quant/` (3-Pane Closing-Bell & FRED Macro Time-Series + 25-Scene Guided Tour), `/engineering/` (`E0-E5` Software Engineering Hub), `/math/` (`M0-M5` Applied Mathematics Hub), and `/donate/` (Signal Patronage). 4. **4,943-Entry Offline `CMUdict` Phonetics Lookup (`cmudict_fallback.json`):** - Translates `Gen 0` English tokens to `Gen 1` Ingglish 100% offline with zero network calls. """ def _render_ingglish_archive_readme(version: str, banner: str) -> str: return f"""# `ingglish-hyperdope-gematria` (`v{version}` — `https://hyperstitionstud.io/archive/`) {banner} Master **Bidirectional Base-36 Alphanumeric Qabbala (`AQ`) & CMUdict `Ingglish` Archive** (`ingglish-aq-archive/00..70-*.md`), automated news-wire and closing-bell quantitative harvesters (`collect_news_aq.py`, `collect_financial_quant_aq.py`), and Zero-Synthetic-Data market/macro time-series ledgers (`financial-aq-harvest-latest.json`, `real-macro-indicators-latest.json`, and `daily-brief-state.json`). --- ## Canonical Repository Structure (`v{version}`) | Path | Public Route / Role | | :--- | :--- | | `ingglish-aq-archive/00-index-and-methodology.md` | [`https://hyperstitionstud.io/archive/00-index-and-methodology.md`](https://hyperstitionstud.io/archive/00-index-and-methodology.md) — Master Archive Index (`Dossiers 01-70`) & Bidirectional `Gen 0 / Gen 1` Methodology | | `ingglish-aq-archive/01..70-*.md` | `72` verified cross-scale (`333 / 666 / 777`) thematic, zoological, and daily current-events exegesis dossiers | | `ingglish-aq-archive/data/financial-aq-harvest-latest.json` | [`https://hyperstitionstud.io/archive/data/financial-aq-harvest-latest.json`](https://hyperstitionstud.io/archive/data/financial-aq-harvest-latest.json) — `24`-instrument closing-bell telemetry across `S1-S6` guilds (`0` synthetic data) | | `ingglish-aq-archive/data/real-macro-indicators-latest.json` | Real Federal Reserve (`FRED`) macroeconomic & monetary series (`CPI`, `PPI`, `US10Y`, `EFFR`, `SOFR`, `M2`, `GDP`, `INDPRO`) | | `ingglish-aq-archive/data/daily-brief-state.json` | 5-Agenda 3-State Bayesian Regime Update (`R1` Expansion, `R2` Isometric Lock, `R3` Tail Drawdown) | | `ingglish-aq-archive/scripts/ci_provision_ingglish.py` | 4-Gate CI/CD corpus filter & `haiperdohp-jemaytreeah/db.txt` provisioner | --- ## Verification & CLI Usage ```bash # Run closing-bell quantitative harvest verification (offline deterministic check) hs-quant-harvest --mode us-closing-bell hs-macro-harvest --offline hs-daily-brief # Run full workspace verification suite python3 /workspace/hyperstitionstudio-core/tests/test_core_suite.py ``` """ def _render_zoology_readme(version: str, banner: str) -> str: return f"""# `technocapital-singularity-zoology` (`v{version}` — `https://hyperstitionstud.io/zoology/`) {banner} Identify, taxonomize, and synthesize cross-scale (`333 / 666 / 777`) Base-36 Alphanumeric Qabbala (`AQ`) dossiers, Ecological Trophic Index (`ETI` `0–100`) assemblage tier lists, a self-maintaining `282`-entry glossary, and a `9`-Division, `22`-Volume Alphabetized PDF Encyclopedia (`122` pages) for **Landian-Deleuzean technocapital singularities** (`S1–S6` & State-Gated Memetic Superclass `M1–M7+`). Powered by `hyperstitionstud_io.*` (`urn:io:hyperstitionstud`). Uses pure 36-character Base-36 `AQ` valuation (`0–9 = 0..9, A–Z = 10..35`) and offline CMUdict `Ingglish` phonetics (`Φ`). --- ## 5-Minute New-User Onboarding (Public HTTP Clone into Any Directory) ```bash mkdir -p ~/hyperstition-workspace && cd ~/hyperstition-workspace git clone https://git.libre.audio/seasharp/hyperstitionstudio-core.git git clone https://git.libre.audio/seasharp/ingglish-hyperdope-gematria.git git clone https://git.libre.audio/seasharp/technocapital-singularity-zoology.git git clone https://git.libre.audio/seasharp/encyclopedia-knowledge-graph.git git clone https://git.libre.audio/seasharp/haiperdohp-jemaytreeah.git git clone -b feat/ingglish-aq-corpus https://git.libre.audio/seasharp/ingglish-hyperdope-ci.git python3 -m venv .venv && source .venv/bin/activate pip install -r hyperstitionstudio-core/requirements.txt pip install --no-deps -e ./hyperstitionstudio-core cp hyperstitionstudio-core/workspace.example.toml ./workspace.toml hs-doctor python3 technocapital-singularity-zoology/scripts/classify_technocapital_singularity.py --terms "Dario Amodei" "Anthropic" "Blackwell" python3 technocapital-singularity-zoology/scripts/sources.py \\ --ledger technocapital-singularity-zoology/taxonomy/citations-ledger-common.json \\ verify technocapital-singularity-zoology/proposal-corporate-board-technocapital-allocation.md --evidence ``` --- ## Canonical Repository Structure (`v{version}`) | Path | Description | | :--- | :--- | | `scripts/classify_technocapital_singularity.py` | Master CLI (`v{version}`): `S1–S6` & `M1–M7+` classifier, `--revise-anchor`, `--build-tier-list`, `--sync-glossary`, `--build-encyclopedia` | | `scripts/sources.py` | Grounded-citations CLI & Python API (`reset`, `add`, `ingest`, `quote`, `list`, `render`, `verify`) backed by `hyperstitionstud_io.ci` | | `encyclopedia/` & `encyclopedia-of-technocapital-singularity-zoology-overview-and-manifest.{{md,pdf}}` | `9` Ontological Divisions (`00`–`08`), `22` Alphabetized PDF Volumes (`122` total pages, `291` placements) served at `https://hyperstitionstud.io/encyclopedia/` | | `technocapital-singularity-zoology-comprehensive-glossary.{{md,pdf}}` | Comprehensive `282`-entry Glossary (`19` pages PDF) backed by `taxonomy/glossary-registry.json` | | `tier-list-technocapital-assemblage-builds.{{md,pdf,png}}` | Ecological Trophic Index (`ETI` `0–100`) `S+` to `D/F` 6-stat Assemblage Builds Scorecard backed by `taxonomy/assemblage-builds-tier-list.json` | | `dossiers/65..69-dossier-*.md` | Canonical Exemplar Dossiers `65` (`S1`), `66` (`S2`), `67` (`S3`), `68` (`S6`), and `69` (`M1×S6`) (`150` verified `333/666/777` equations) | | `taxonomy/*.json` | All `8` versioned JSON registries (`glossary-registry`, `singularity-zoology-matrix`, `memetic-superclass-registry`, `quantitative-economic-anchors`, `assemblage-builds-tier-list`, and 2 citation ledgers) | | `proposal-*.{{md,pdf}}` | Layman & Stakeholder Proposals (Fantasy Football, Corporate Board, Out-of-Sample Fund Manager in Bidirectional & Pure Standard English `Gen 0` variants) | | `podcast-ep01..05-*.{{md,pdf}}` | Full transcripts and show notes for Episodes `01–05` of *The Singularity Field Guide* | """ def _render_kg_readme(version: str, banner: str) -> str: return f"""# `encyclopedia-knowledge-graph` (`v{version}` — `https://hyperstitionstud.io/graph/`) {banner} Standalone open-source interactive knowledge graph workbench, multi-format graph compiler (`JSON`, `GraphML`, `GEXF`, `Obsidian JSON Canvas`), visual atlas renderer, architectural plan ledger, and operator's manual for the **Encyclopedia of Technocapital Singularity Zoology**. Powered by `hyperstitionstud_io.*` (`urn:io:hyperstitionstud:ns:kg:1.0`). Ingests `technocapital-singularity-zoology` strictly in **read-only mode** with cryptographic pre/post `SHA-256` isolation verification so zero knowledge-graph or visualization concepts ever enter the upstream glossary or encyclopedia. --- ## 5-Minute Verification & Graph Build ```bash # Rebuild or verify all 6 Knowledge Graph CI gates (location-independent, zero flags needed) python3 encyclopedia-knowledge-graph/scripts/build_encyclopedia_knowledge_graph.py python3 encyclopedia-knowledge-graph/scripts/build_encyclopedia_knowledge_graph.py --verify-only # Run cold-storage archive rotation check for completed architectural plans hs-archive-rotate ``` --- ## Repository Structure (`v{version}`) | Path | Description | | :--- | :--- | | `OPERATORS-MANUAL-ENCYCLOPEDIA-KNOWLEDGE-GRAPH.{{md,pdf}}` | Step-by-step Operator's Manual (`7` pages PDF) at `https://hyperstitionstud.io/graph/OPERATORS-MANUAL-ENCYCLOPEDIA-KNOWLEDGE-GRAPH.pdf` | | `scripts/build_encyclopedia_knowledge_graph.py` | Location-independent graph compiler, 6-gate verifier, and CLI ego-network query engine | | `index.html` & `graph-data.js` | Offline-capable interactive dark-mode HTML5/Canvas workbench (`388` nodes, `1,282` deduplicated edges) | | `encyclopedia-graph.{{json,graphml,gexf}}` & `encyclopedia.canvas` | Open-source graph interchange exports (`xmlns:hs="urn:io:hyperstitionstud:ns:kg:1.0"`) | | `atlas-mode{{1,2,3}}.png` | High-resolution (`1600x1060`) visual atlas boards (Trophic Food-Web, Concentric ETI Radar `S+ -> D Periphery`, Bipartite `Gen 0 -> Gen 1` Funnel) | | `docs/VPS-AND-GIT-OPERATOR-DEPLOYMENT-GUIDE.{{md,pdf}}` | Two-Script Git Operator (`git.libre.audio`) & Linode/Akamai VPS deployment guide (`v{version}`) | | `docs/OPERATORS-MANUAL-LLM-TOKEN-DEPENDENT-DATA-PIPELINES.{{md,pdf}}` | Operator's Manual for zero-token VPS timers vs. LLM-token exegesis pipelines | | `docs/cross-repo-dependency-and-audit-flow-diagram.{{html,png,pdf,md}}` & `docs/periodic-harvest-cicd-to-vps-flow-diagram.png` | Visual Dependency & Periodic Harvest CI/CD Flow Diagrams | | `docs/archive/completed-plans-archive.tar.gz` & `docs/archive/archive-manifest.json` | Cold-rotated gzipped tar archive of completed architectural plans (`hs-archive-rotate`) | """ def _render_ci_build_readme(version: str, banner: str) -> str: return f"""# `ingglish-hyperdope-ci` / `hyperdope-ci-build` (`v{version}` — `https://hyperstitionstud.io/ci/`) {banner} Automated **4-Gate CI/CD Ingglish & Base-36 AQ Corpus Provisioning Repository** (`feat/ingglish-aq-corpus`), serving verified `db_ingglish_entries.txt` lexical candidates, `ci-audit-report.json` (`100.0%` 4-Gate keep rate), and `ONBOARDING-INGGLISH-AQ.{{md,pdf}}` for `https://hyperstitionstud.io/ci/` and `https://hyperstitionstud.io/calc/`. --- ## Canonical Repository Artifacts (`v{version}`) | Artifact | Public URL & Verification Role | | :--- | :--- | | `ONBOARDING-INGGLISH-AQ.{{md,pdf}}` | [`https://hyperstitionstud.io/ci/ONBOARDING-INGGLISH-AQ.pdf`](https://hyperstitionstud.io/ci/ONBOARDING-INGGLISH-AQ.pdf) — Complete 4-Gate CI & `haiperdohp-jemaytreeah` Integration Guide | | `ci-audit-report.json` | [`https://hyperstitionstud.io/ci/ci-audit-report.json`](https://hyperstitionstud.io/ci/ci-audit-report.json) — Machine-verifiable 4-Gate audit receipt (`Gate A` Format, `Gate B` Phonemic Determinism, `Gate C` AQ Isopsephic Parity, `Gate D` Deduplication) | | `db_ingglish_entries.txt` | Provisioned `Gen 0` and `Gen 1` (`Ingglish`) lexical entries merged into `haiperdohp-jemaytreeah/db.txt` (`231,615` total entries) | --- ## Re-Running the 4-Gate CI Provisioner ```bash python3 /workspace/ingglish-hyperdope-gematria/ingglish-aq-archive/scripts/ci_provision_ingglish.py \\ --archive-dir /workspace/ingglish-hyperdope-gematria/ingglish-aq-archive \\ --out-dir /workspace/hyperdope-ci-build \\ --tier 2 ``` """ def _render_calc_readme(repo_dir: Path, version: str, banner: str) -> str: readme_path = repo_dir / "README.md" existing = readme_path.read_text(encoding="utf-8") if readme_path.is_file() else "" # Strip any prior top header + status block above `## Quick Start` qs_idx = existing.find("## Quick Start") preserved_tail = existing[qs_idx:] if qs_idx != -1 else existing preserved_tail = re.sub(r"(?i)cypher\s*calculator", "haiperdohpjematreeah", preserved_tail) return f"""# `haiperdohp-jemaytreeah` — haiperdohpjematreeah (`v{version}` — `https://hyperstitionstud.io/calc/`) {banner} A gematria cypher workbench (`haiperdohpjematreeah`) with pre-computed instant matching (`82` ciphers, `231,615` Ingglish-provisioned `db.txt` entries across `db_lite.json` and `db.json`), progressive background hydration, and full whitelabel support via `config.js` at [`https://hyperstitionstud.io/calc/`](https://hyperstitionstud.io/calc/). ![haiperdohpjematreeah](res/preview.png) {preserved_tail.lstrip()}""" def build_repo_readme_content(repo_key: str, repo_dir: Path, version: str | None = None) -> str: v = (version or CURRENT_VERSION).lstrip("v").strip() ctx = _introspect_repo_commit_context(repo_dir, v) banner = _render_status_banner(repo_key, v, ctx) if repo_key == "hyperstitionstudio-core": return _render_core_readme(v, banner) if repo_key == "ingglish-hyperdope-gematria": return _render_ingglish_archive_readme(v, banner) if repo_key == "technocapital-singularity-zoology": return _render_zoology_readme(v, banner) if repo_key == "encyclopedia-knowledge-graph": return _render_kg_readme(v, banner) if repo_key == "hyperdope-ci-build": return _render_ci_build_readme(v, banner) if repo_key == "haiperdohp-jemaytreeah": return _render_calc_readme(repo_dir, v, banner) raise ValueError(f"Unknown repository key: {repo_key}") def sync_all_repo_readmes( ws_root: Path | None = None, version: str | None = None, check_only: bool = False, target_repo: str | None = None, ) -> dict[str, Any]: cfg = load_workspace_config(workspace_root=ws_root) root = cfg.workspace_root v = (version or CURRENT_VERSION).lstrip("v").strip() modified: list[str] = [] mismatched: list[str] = [] checked: list[str] = [] for repo_key in REPO_SPECS: if target_repo and target_repo not in (repo_key, REPO_SPECS[repo_key]["gitea_slug"]): continue rdir = _resolve_repo_dir(root, repo_key) if not rdir.is_dir(): continue readme_path = rdir / "README.md" rel_label = f"/workspace/{rdir.name}/README.md" checked.append(rel_label) expected = build_repo_readme_content(repo_key, rdir, version=v) actual = readme_path.read_text(encoding="utf-8") if readme_path.is_file() else "" if check_only: # Verify the file exists, contains the status markers, has 0 `EADME.md` truncations, # and every single semantic version token `vX.Y.Z` in the file equals `v{v}`. has_markers = STATUS_START in actual and STATUS_END in actual found_semver = set(re.findall(r"\bv(\d+\.\d+\.\d+)\b", actual)) strict_single_version = (found_semver == {v}) has_no_d_filter = "Zero-`d`-Filter" not in actual and "Zero-d-Filter" not in actual has_no_truncation = re.search(r"(? dict[str, Any]: cfg = load_workspace_config(workspace_root=ws_root) root = cfg.workspace_root installed: list[str] = [] missing: list[str] = [] for repo_key in REPO_SPECS: rdir = _resolve_repo_dir(root, repo_key) hooks_dir = rdir / ".git" / "hooks" if not hooks_dir.is_dir(): continue for h_name, h_script, markers in ( ("pre-commit", PRE_COMMIT_HOOK_SCRIPT, ("readme_sync", "closeups_sync", "deploy_scripts_sync")), ("commit-msg", COMMIT_MSG_HOOK_SCRIPT, ("COMMIT-MSG GATE",)), ): hook_path = hooks_dir / h_name rel_label = f"/workspace/{rdir.name}/.git/hooks/{h_name}" if check_only: txt_h = hook_path.read_text(encoding="utf-8") if hook_path.is_file() else "" if not (hook_path.is_file() and os.access(hook_path, os.X_OK) and all(m in txt_h for m in markers)): missing.append(rel_label) else: installed.append(rel_label) else: cur = hook_path.read_text(encoding="utf-8") if hook_path.is_file() else "" if cur != h_script: hook_path.write_text(h_script, encoding="utf-8") hook_path.chmod(0o755) installed.append(rel_label) return { "ok": len(missing) == 0, "installed_hooks": installed, "missing_hooks": missing, } def main(argv: list[str] | None = None) -> int: ap = argparse.ArgumentParser(prog="hs-readme-sync", description="Synchronize root README.md files and Gitea pre-commit hooks across all 6 repositories.") ap.add_argument("--all", action="store_true", help="Synchronize root README.md across all 6 repositories.") ap.add_argument("--repo", default=None, help="Synchronize only the specified repository name/slug.") ap.add_argument("--stage", action="store_true", help="Run `git add README.md` after updating the repository README.") ap.add_argument("--check", action="store_true", help="Verify all 6 root README.md files and pre-commit hooks are in sync without modifying files.") ap.add_argument("--install-hooks", action="store_true", help="Install idempotent .git/hooks/pre-commit and commit-msg hooks across all 6 repositories.") ap.add_argument("--hooks-only", action="store_true", help="Install git hooks without modifying tracked README.md files on disk.") ap.add_argument("--version", default=None, help="Override target semantic version.") args = ap.parse_args(argv) cfg = load_workspace_config() root = cfg.workspace_root if args.hooks_only: hook_res = install_git_pre_commit_hooks(ws_root=root, check_only=False) print(json.dumps({"ok": hook_res["ok"], "hooks_only": True, "hooks": hook_res}, indent=2)) return 0 if hook_res["ok"] else 1 if args.install_hooks: hook_res = install_git_pre_commit_hooks(ws_root=root, check_only=False) sync_res = sync_all_repo_readmes(ws_root=root, version=args.version, check_only=False, target_repo=args.repo) sync_res["hooks"] = hook_res print(json.dumps(sync_res, indent=2)) return 0 if args.check: sync_res = sync_all_repo_readmes(ws_root=root, version=args.version, check_only=True, target_repo=args.repo) hook_res = install_git_pre_commit_hooks(ws_root=root, check_only=True) sync_res["hooks"] = hook_res sync_res["all_in_sync"] = bool(sync_res["all_in_sync"] and hook_res["ok"]) print(json.dumps(sync_res, indent=2)) return 0 if sync_res["all_in_sync"] else 1 sync_res = sync_all_repo_readmes(ws_root=root, version=args.version, check_only=False, target_repo=args.repo) if args.stage and args.repo: for repo_key in REPO_SPECS: if args.repo in (repo_key, REPO_SPECS[repo_key]["gitea_slug"]): rdir = _resolve_repo_dir(root, repo_key) if (rdir / "README.md").is_file(): subprocess.run(["git", "-C", str(rdir), "add", "README.md"], check=False) print(json.dumps(sync_res, indent=2)) return 0 if __name__ == "__main__": raise SystemExit(main())