diff --git a/.github/workflows/context-snapshot.yml b/.github/workflows/context-snapshot.yml
index 9183653..1810c2f 100644
--- a/.github/workflows/context-snapshot.yml
+++ b/.github/workflows/context-snapshot.yml
@@ -1,4 +1,3 @@
-
name: Context Snapshot (mARCHCode)
on:
@@ -22,15 +21,19 @@ jobs:
python-version: "3.11"
- name: Install deps
- run: pip install pyyaml
+ run: |
+ python -m pip install --upgrade pip
+ python -m pip install pyyaml
- name: Create dirs
- run: mkdir -p scripts .archcode
+ run: |
+ mkdir -p scripts .archcode
- name: Write context_snapshot.py
shell: bash
run: |
cat > scripts/context_snapshot.py <<'PY'
+ #!/usr/bin/env python3
from __future__ import annotations
"""
Minimal context snapshot (stable)
@@ -298,7 +301,7 @@ jobs:
- name: Generate HTML page + true TiddlyWiki .tid (no truncation)
shell: bash
run: |
- python - <<'PY'
+ cat > .archcode/_context_snapshot_html_builder.py <<'PY'
import yaml, html, sys, json
from pathlib import Path
from datetime import datetime
@@ -332,11 +335,9 @@ jobs:
"""
- # ---- build the HTML *fragment* (for TiddlyWiki) ----
frag = []
frag.append(f"
Context Snapshot — {proj or '—'}
")
- # metadata
frag.append("")
- # tree
frag.append("Arbre du projet
")
frag.append(html.escape(s.get("tree","") or ""))
frag.append(" ")
- # files
files = s.get("files") or []
frag.append(f"Fichiers ({len(files)})
")
for f in files:
@@ -371,7 +370,7 @@ jobs:
if defs:
frag.append(f"
Defs ({ndefs})")
- for d in defs: # pas de limite: on affiche tout
+ for d in defs:
q = d.get("qualname","")
ln = d.get("lineno","")
params = d.get("params") or []
@@ -395,29 +394,24 @@ jobs:
frag.append(li)
frag.append("
")
frag.append("")
- frag.append("
") # end files
+ frag.append("")
fragment_html = CSS + "\n" + "\n".join(frag)
- # ---- write standalone HTML page ----
full_html = "\nContext Snapshot — %s%s" % (proj, fragment_html)
out_html.write_text(full_html, encoding="utf-8")
- # ---- write true TiddlyWiki .tid ----
- # TiddlyWiki single-tiddler format: header fields, blank line, then content.
- # We store the *fragment* only (no wrapper), as 'text/html' type.
def tw_timestamp(dt):
- # YYYYMMDDhhmmssmmm (UTC)
return dt.strftime("%Y%m%d%H%M%S") + f"{dt.microsecond//1000:03d}"
now = datetime.utcnow()
title = f"Context Snapshot — {meta.get('project') or '-'}"
header = [
- f"title: {title}",
- "tags: mARCHCode Snapshot",
- f"created: {tw_timestamp(now)}",
- f"modified: {tw_timestamp(now)}",
- "type: text/html",
+ f"title: {title}",
+ "tags: mARCHCode Snapshot",
+ f"created: {tw_timestamp(now)}",
+ f"modified: {tw_timestamp(now)}",
+ "type: text/html",
]
out_tid.write_text("\n".join(header) + "\n\n" + fragment_html, encoding="utf-8")