"""Publish tracked research documents and source text without importing research code. Run with Python-Markdown 3.9 installed. The output is a static GitHub Pages site. """ from __future__ import annotations import argparse import html import json import posixpath import subprocess from html.parser import HTMLParser from pathlib import Path from urllib.parse import quote, unquote, urlsplit import markdown ROOT = Path(__file__).resolve().parents[1] REPOSITORY = "KennyMcSimpson/measurement-scene-state" GITHUB = f"https://github.com/{REPOSITORY}" RAW = f"https://raw.githubusercontent.com/{REPOSITORY}/main" CORE = ( "STATUS.md", "EXPERIMENTS.md", "README.md", "ROADMAP.md", "docs/research_summary_20261003.md", "docs/handoff/REPOSITORY_MAP.md", "docs/handoff/SHARED_WORKSPACE.md", "docs/handoff/3D_REPRODUCTION.md", "docs/provenance/CLAIMS.md", "docs/provenance/DATA.md", "docs/PROTOCOL.md", "docs/DATASETS.md", ) CSS = """ :root{color-scheme:light;--ink:#182b40;--muted:#576879;--accent:#096b73} *{box-sizing:border-box}body{margin:0;background:#fafaf7;color:var(--ink); font:17px/1.75 system-ui,-apple-system,"Segoe UI","Noto Sans SC",sans-serif} header,main,footer{max-width:1080px;margin:auto;padding:28px 32px} header{border-bottom:1px solid #dae0e2}nav{display:flex;gap:20px;flex-wrap:wrap} a{color:var(--accent);text-underline-offset:3px}h1,h2,h3{line-height:1.3} h1{font-size:2.2rem;letter-spacing:-.025em}h2{margin-top:2em} .eyebrow,.meta,footer{color:var(--muted)}.eyebrow{font-size:.85rem;letter-spacing:.1em} .lead{font-size:1.12rem;max-width:820px}.meta{font-size:.88rem;overflow-wrap:anywhere} .links{display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:22px} .links h2{font-size:1.1rem;margin-bottom:4px}.links p{margin-top:4px} .links section{min-width:0;overflow-wrap:anywhere} article{overflow-wrap:anywhere}table{display:block;overflow-x:auto;border-collapse:collapse} td,th{padding:10px 14px;border:1px solid #d8dfe2;text-align:left} pre{background:#edf1f2;padding:20px;border-radius:5px;overflow:auto;line-height:1.55} pre code{white-space:pre;font-size:.86rem}code{font-size:.9em} img{max-width:100%;height:auto}blockquote{margin-left:0;padding-left:20px; border-left:3px solid #9eb6bc;color:var(--muted)}li{margin:5px 0} .directory li{font-size:.92rem}footer{border-top:1px solid #dae0e2;margin-top:45px} @media(max-width:650px){header,main,footer{padding:22px 18px}h1{font-size:1.75rem}} """ ALLOWED_TAGS = set( "a p br hr h1 h2 h3 h4 h5 h6 pre code ul ol li blockquote strong em b i " "table thead tbody tr td th img div span details summary sup sub del dl dt dd".split() ) VOID_TAGS = {"br", "hr", "img"} def git(*args: str) -> str: return subprocess.check_output(["git", *args], cwd=ROOT, text=True).strip() def text_path(path: str) -> str: return "text/" + (path[:-3] + ".txt" if path.endswith(".md") else path + ".txt") class DocumentHTML(HTMLParser): """Keep passive Markdown HTML and resolve links against the original source path.""" def __init__(self, source: str, pages: dict[str, str], directories: set[str]) -> None: super().__init__(convert_charrefs=True) self.source = source self.pages = pages self.directories = directories self.output: list[str] = [] self.blocked = 0 def target(self, value: str, image: bool = False) -> str: parsed = urlsplit(value) if parsed.netloc and not parsed.scheme: return "https:" + value if parsed.scheme or parsed.netloc: return value if parsed.scheme in {"http", "https", "mailto"} else "#" if not parsed.path: return value source = posixpath.normpath( posixpath.join(posixpath.dirname(self.source), unquote(parsed.path)) ) if source.startswith("outputs/"): archived = "docs/experiments/" + source[len("outputs/") :] if archived in self.pages: source = archived if source in self.pages and not image: value = posixpath.relpath( self.pages[source], posixpath.dirname(self.pages[self.source]) ) else: prefix = ( RAW if image else f"{GITHUB}/{'tree' if source in self.directories else 'blob'}/main" ) value = prefix + "/" + quote(source, safe="/") if parsed.query: value += "?" + parsed.query if parsed.fragment: value += "#" + parsed.fragment return value def handle_starttag(self, tag: str, attrs: list[tuple[str, str | None]]) -> None: if tag in {"script", "style", "iframe"}: self.blocked += 1 if self.blocked or tag not in ALLOWED_TAGS: return safe = [] for key, value in attrs: if value is None or key not in {"href", "src", "alt", "title", "id", "class", "open"}: continue if key in {"href", "src"}: value = self.target(value, image=key == "src") safe.append(f' {key}="{html.escape(value, quote=True)}"') self.output.append(f"<{tag}{''.join(safe)}>") def handle_endtag(self, tag: str) -> None: if tag in {"script", "style", "iframe"} and self.blocked: self.blocked -= 1 return if not self.blocked and tag in ALLOWED_TAGS and tag not in VOID_TAGS: self.output.append(f"{tag}>") def handle_startendtag(self, tag: str, attrs: list[tuple[str, str | None]]) -> None: self.handle_starttag(tag, attrs) if tag not in VOID_TAGS: self.handle_endtag(tag) def handle_data(self, data: str) -> None: if not self.blocked: self.output.append(html.escape(data)) def main() -> None: parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--output", type=Path, default=ROOT / "_site") parser.add_argument( "--base-url", default="https://kennymcsimpson.github.io/measurement-scene-state/" ) args = parser.parse_args() base = args.base_url.rstrip("/") + "/" if urlsplit(base).scheme != "https": parser.error("--base-url must be an HTTPS URL") output = args.output.resolve() if output == ROOT or output in ROOT.parents: parser.error("--output must not overwrite the repository or its parents") output.mkdir(parents=True, exist_ok=True) tracked = git("ls-files", "-z").split("\0") documents = sorted( path for path in tracked if path.endswith(".md") and ("/" not in path or path.startswith(("docs/", "research/ideas/"))) ) sources = sorted( path for path in tracked if ( path.startswith(("src/", "scripts/", "configs/", "docs/", "tests/")) and path.endswith((".py", ".yaml", ".yml", ".toml")) ) or path == "pyproject.toml" ) pages = {path: "pages/" + path[:-3] + ".html" for path in documents} pages.update({path: "code/" + path + ".html" for path in sources}) directories = {str(parent) for path in tracked for parent in Path(path).parents} commit = git("rev-parse", "HEAD") updated = git("show", "-s", "--format=%cI", "HEAD") def write(path: str, content: str) -> None: target = output / path target.parent.mkdir(parents=True, exist_ok=True) target.write_text(content, encoding="utf-8", newline="") def shell(title: str, body: str, path: str, description: str) -> str: return f'''
{html.escape(text)}"
meta = (
f''
)
write(page, shell(path, meta + "PUBLIC RESEARCH ARCHIVE · KennyMcSimpson
Inverse-JEPA、Dynamic-TTT 与场景状态的研究档案。 本页提供原始文档、实验记录和源代码的公开阅读入口。
Repository: KennyMcSimpson/measurement-scene-state
阅读研究结论时,先查看 STATUS.md 和 EXPERIMENTS.md 的证据等级、数据划分与限制。 这些页面同步仓库原文,保留历史记录;具体结论以对应实验协议和报告为准。
核心文档合并原文 / Core documents in one text file · 研究文档与源码的文本索引
可把上述链接直接交给具备网页读取功能的 AI。 直接读取公开 URL 不依赖关键词搜索是否已有结果。