Release v2.0.28: Refresh all 84 web-interface-linked and encyclopedia PDFs into Group 3 Dark Mode via hs-pdf-build --refresh-all-web-pdfs
This commit is contained in:
1 parent
36867a4ff8
commit
c644dcfb65
25 files changed
+175
-64
No files matched your search
@@ -1,3 +1,3 @@
|
||||
"""hyperstitionstud_io — Shared Common Library for the hyperstitionstud.io workspace (v2.0.27)."""
|
||||
__version__ = "2.0.27"
|
||||
"""hyperstitionstud_io — Shared Common Library for the hyperstitionstud.io workspace (v2.0.28)."""
|
||||
__version__ = "2.0.28"
|
||||
NAMESPACE_URN = "urn:io:hyperstitionstud"
|
||||
@@ -35,8 +35,8 @@ from hyperstitionstud_io.mcp.tools import MCP_TOOLS_SCHEMA, call_mcp_tool # noq
|
||||
|
||||
SERVER_INFO = {
|
||||
"name": "hyperstitionstudio-mcp",
|
||||
"version": "2.0.27",
|
||||
"namespace_urn": "urn:io:hyperstitionstud:mcp:2.0.27",
|
||||
"version": "2.0.28",
|
||||
"namespace_urn": "urn:io:hyperstitionstud:mcp:2.0.28",
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -619,12 +619,118 @@ def compile_markdown_to_pdf(
|
||||
}
|
||||
|
||||
|
||||
def discover_web_and_repo_pdf_pairs(workspace_root: str | Path | None = None) -> list[tuple[Path, Path]]:
|
||||
"""
|
||||
Discover all `(md_path, pdf_path)` pairs across the workspace in priority order:
|
||||
1. First, every `.pdf` explicitly linked from any web interface surface (`/`, `/quant/`, `/learn/`, `/donate/`, `/graph/`, and `timeseries.py`),
|
||||
2. Second, all 22 Encyclopedia volume PDFs under `technocapital-singularity-zoology/encyclopedia/` and top-level `zoology/*.pdf`,
|
||||
3. Third, all remaining `.md -> .pdf` pairs across `encyclopedia-knowledge-graph/`, `hyperstitionstudio-core/`, and `hyperdope-ci-build/`.
|
||||
"""
|
||||
from hyperstitionstud_io.config import load_workspace_config
|
||||
|
||||
cfg = load_workspace_config(workspace_root=workspace_root)
|
||||
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"
|
||||
|
||||
web_surfaces = [
|
||||
core / "site" / "index.html",
|
||||
core / "site" / "quant" / "index.html",
|
||||
core / "site" / "quant" / "quant-app.js",
|
||||
core / "site" / "quant" / "quant-tutorials.js",
|
||||
core / "site" / "learn" / "index.html",
|
||||
core / "site" / "learn" / "learn-app.js",
|
||||
core / "site" / "donate" / "index.html",
|
||||
kg / "index.html",
|
||||
core / "src" / "hyperstitionstud_io" / "quant" / "timeseries.py",
|
||||
]
|
||||
|
||||
ordered_pdfs: list[Path] = []
|
||||
seen_pdfs: set[Path] = set()
|
||||
|
||||
def _resolve_link_to_pdf(lk: str) -> Path | None:
|
||||
clean = lk.split("#")[0].split("?")[0].strip()
|
||||
if not clean.endswith(".pdf") or "${" in clean or "+" in clean:
|
||||
return None
|
||||
if clean.startswith("/encyclopedia/"):
|
||||
p = zoo / "encyclopedia" / clean[len("/encyclopedia/"):]
|
||||
elif clean.startswith("/technocapital-singularity-zoology/"):
|
||||
p = zoo / clean[len("/technocapital-singularity-zoology/"):]
|
||||
elif clean.startswith("/zoology/"):
|
||||
p = zoo / clean[len("/zoology/"):]
|
||||
elif clean.startswith("/graph/"):
|
||||
p = kg / clean[len("/graph/"):]
|
||||
elif clean.startswith("/quant/") or clean.startswith("./OPERATORS-MANUAL"):
|
||||
p = core / "site" / "quant" / Path(clean).name
|
||||
elif clean.startswith("/ci/"):
|
||||
p = ci / clean[len("/ci/"):]
|
||||
elif clean.startswith("0") and "/" in clean:
|
||||
p = zoo / "encyclopedia" / clean
|
||||
else:
|
||||
p = (kg / clean).resolve()
|
||||
return p.resolve() if p.is_file() else None
|
||||
|
||||
for wf in web_surfaces:
|
||||
if not wf.is_file():
|
||||
continue
|
||||
txt = wf.read_text(encoding="utf-8")
|
||||
for m in re.findall(r'["\']([^"\']*?\.pdf(?:#[^"\']*)?)["\']', txt):
|
||||
rp = _resolve_link_to_pdf(m)
|
||||
if rp and rp not in seen_pdfs:
|
||||
seen_pdfs.add(rp)
|
||||
ordered_pdfs.append(rp)
|
||||
|
||||
for scan_dir in (zoo / "encyclopedia", zoo, kg, core / "site" / "quant", ci):
|
||||
if not scan_dir.is_dir():
|
||||
continue
|
||||
for p in sorted(scan_dir.rglob("*.pdf")):
|
||||
rp = p.resolve()
|
||||
if rp not in seen_pdfs:
|
||||
seen_pdfs.add(rp)
|
||||
ordered_pdfs.append(rp)
|
||||
|
||||
pairs: list[tuple[Path, Path]] = []
|
||||
for pdf_p in ordered_pdfs:
|
||||
md_p = pdf_p.with_suffix(".md")
|
||||
if not md_p.is_file() and pdf_p.name == "ONBOARDING-INGGLISH-AQ.pdf":
|
||||
alt = pdf_p.parent / "docs" / "ONBOARDING-INGGLISH-AQ.md"
|
||||
if alt.is_file():
|
||||
md_p = alt
|
||||
if md_p.is_file():
|
||||
pairs.append((md_p, pdf_p))
|
||||
return pairs
|
||||
|
||||
|
||||
def refresh_all_web_and_repo_pdfs(workspace_root: str | Path | None = None) -> dict[str, Any]:
|
||||
pairs = discover_web_and_repo_pdf_pairs(workspace_root=workspace_root)
|
||||
refreshed: list[str] = []
|
||||
for md_p, pdf_p in pairs:
|
||||
compile_markdown_to_pdf(md_p, pdf_p)
|
||||
refreshed.append(str(pdf_p))
|
||||
return {
|
||||
"refreshed_count": len(refreshed),
|
||||
"dark_mode_style": "group_3_stealth_basalt",
|
||||
"priority_order": "web_interface_links_first",
|
||||
"refreshed_pdfs": refreshed,
|
||||
}
|
||||
|
||||
|
||||
def main(argv: list[str] | None = None) -> int:
|
||||
ap = argparse.ArgumentParser(prog="hs-pdf-build", description="Compile Markdown to verified Dark-Mode ReportLab PDF.")
|
||||
ap.add_argument("--md", required=True)
|
||||
ap.add_argument("--pdf", required=True)
|
||||
ap.add_argument("--md", default=None)
|
||||
ap.add_argument("--pdf", default=None)
|
||||
ap.add_argument("--title", default=None)
|
||||
ap.add_argument("--refresh-all-web-pdfs", action="store_true", help="Discover all PDFs linked from web interfaces first and refresh all .md -> .pdf pairs in Dark Mode.")
|
||||
args = ap.parse_args(argv)
|
||||
if args.refresh_all_web_pdfs:
|
||||
res = refresh_all_web_and_repo_pdfs()
|
||||
print(json.dumps({"refreshed_count": res["refreshed_count"], "dark_mode_style": res["dark_mode_style"]}, indent=2))
|
||||
return 0
|
||||
if not args.md or not args.pdf:
|
||||
ap.error("--md and --pdf are required unless --refresh-all-web-pdfs is passed.")
|
||||
res = compile_markdown_to_pdf(args.md, args.pdf, title=args.title)
|
||||
print(json.dumps(res, indent=2))
|
||||
return 0
|
||||
|
||||
@@ -678,7 +678,7 @@ def build_financial_quant_harvest(
|
||||
payload: dict[str, Any] = {
|
||||
"$schema": "./schemas/v1/financial-aq-harvest.schema.json",
|
||||
"$id": "urn:io:hyperstitionstud:schema:v1:financial-aq-harvest",
|
||||
"version": "2.0.27",
|
||||
"version": "2.0.28",
|
||||
"target_date_utc": datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%d"),
|
||||
"harvest_mode": harvest_mode,
|
||||
"synthetic_data_eliminated": True,
|
||||
|
||||
Reference in new issue
Block a user