| name | comm-legal |
| description | Use when checking ISDS and email communication status for sp. zn. 0 P 29/2026, scanning for new documents, running OCR on attachments, updating evidence catalog, or getting a dashboard of what arrived, what was sent, and what's pending |
comm-legal — ISDS + Email Communication Dashboard
Overview
Spravuje veškerou ISDS a email komunikaci pro sp. zn. 0 P 29/2026. Skenuje nové dokumenty, spouští OCR, aktualizuje evidenci JSON a zobrazuje dashboard.
Legal instance = ISDS správce od 13.1.2026. Volat při každém super-start.
When to Use
- Super-start init — automaticky spustit po A3 (deep-read)
- Přišel signál o novém ISDS dokumentu
- Před odesláním — ověř stav fronty + STOP ORDER
- Tom ptá: "co nám přišlo?", "co jsme poslali?", "co čeká?"
- Po přidání nového souboru do
Inbox/isds/
Execution
Krok 1 — Skenování nových dokumentů + OCR
import sys, json, os, subprocess, urllib.request, base64, time
from pathlib import Path
sys.stdout.reconfigure(encoding='utf-8')
ISDS_DIR = Path(r"L:\GitHub\legal-ship-2026\Inbox\isds")
EVIDENCE_FILE = ISDS_DIR / "isds_evidence.json"
OLLAMA_URL = "http://127.0.0.1:11434/api/generate"
OCR_MODEL = "glm-ocr:latest"
PDF_EXTS = {".pdf", ".PDF"}
ev = json.loads(EVIDENCE_FILE.read_text(encoding='utf-8')) if EVIDENCE_FILE.exists() else {"received": [], "sent": [], "pending": [], "alerts": []}
known_files = {r["filename"] for r in ev.get("received", [])}
all_pdfs = [f for f in ISDS_DIR.iterdir() if f.suffix in PDF_EXTS]
new_files = [f for f in all_pdfs if f.name not in known_files]
no_ocr = [f for f in all_pdfs if not (ISDS_DIR / (f.name + ".ocr.txt")).exists()]
print(f"[comm-legal] Skenování: {len(all_pdfs)} PDF, {len(new_files)} nových, {len(no_ocr)} bez OCR")
def ocr_pdf_pages(pdf_path: Path) -> str:
"""Konvertuje PDF stránky na obrázky a OCRuje přes glm-ocr."""
try:
import subprocess
try:
import pdfplumber
with pdfplumber.open(str(pdf_path)) as pdf:
text = "\n".join(p.extract_text() or "" for p in pdf.pages[:10])
if len(text.strip()) > 200:
return text
except Exception:
pass
png_path = Path(str(pdf_path) + "_p0.png")
subprocess.run(
["pdftoppm", "-r", "150", "-l", "1", "-png", str(pdf_path),
str(pdf_path) + "_p"],
capture_output=True, timeout=60
)
if not png_path.exists():
return "(OCR failed — pdftoppm not available)"
img_data = base64.b64encode(png_path.read_bytes()).decode()
payload = {"model": OCR_MODEL, "prompt": "Extract all text from this document image. Output plain text only.", "images": [img_data], "stream": False}
req = urllib.request.Request(OLLAMA_URL, data=json.dumps(payload).encode(), headers={"Content-Type": "application/json"})
with urllib.request.urlopen(req, timeout=240) as resp:
return json.loads(resp.read())["response"]
except Exception as e:
return f"(OCR error: {e})"
for pdf in no_ocr:
ocr_txt = ISDS_DIR / (pdf.name + ".ocr.txt")
print(f" OCR: {pdf.name} ...", end=" ", flush=True)
text = ocr_pdf_pages(pdf)
ocr_txt.write_text(text, encoding='utf-8')
print(f"✓ ({len(text)} znaků)")
Krok 2 — Přidat nové soubory do evidence
for pdf in new_files:
ocr_path = ISDS_DIR / (pdf.name + ".ocr.txt")
ocr_text = ocr_path.read_text(encoding='utf-8')[:500] if ocr_path.exists() else ""
new_entry = {
"id": f"recv_{len(ev['received'])+1:03d}",
"filename": pdf.name,
"from_institution": "unknown",
"subject": "(načíst z OCR)",
"date_approx": "2026",
"ocr": ocr_path.exists(),
"processed": False,
"priority": "P2",
"notes": f"AUTO: {ocr_text[:200]}"
}
ev["received"].append(new_entry)
print(f" + evidence: {pdf.name}")
EVIDENCE_FILE.write_text(json.dumps(ev, ensure_ascii=False, indent=2), encoding='utf-8')
Krok 3 — Dashboard výstup
print("\n" + "="*65)
print(" ISDS + EMAIL DASHBOARD | 0 P 29/2026 | legal instance")
print("="*65)
alerts = [a for a in ev.get("alerts", [])]
if alerts:
print(f"\n🔴 ALERTY ({len(alerts)}):")
for a in alerts:
sev = "CRITICAL" if a["severity"] == "CRITICAL" else "HIGH" if a["severity"] == "HIGH" else "MED"
print(f" [{sev}] {a['subject']}")
print(f" → {a.get('action_required','')}")
pending = ev.get("pending", [])
if pending:
print(f"\n⏸️ ČEKÁ NA ODESLÁNÍ ({len(pending)}) — STOP ORDER #1452:")
for p in sorted(pending, key=lambda x: x.get("send_order", 99)):
print(f" [{p['send_order']}] {p['subject']}")
print(f" ZIP: {p.get('zip','?')} | Status: {p['status']}")
unprocessed = [r for r in ev.get("received", []) if not r.get("processed") and r.get("priority","P2") in ("P0","P0_ALERT","P1")]
if unprocessed:
print(f"\n📥 PŘIJATO — NEZPRACOVÁNO ({len(unprocessed)}):")
for r in sorted(unprocessed, key=lambda x: x.get("priority","P2")):
print(f" [{r['priority']}] {r['filename']}")
print(f" {r['subject']}")
sent = ev.get("sent", [])
print(f"\n📤 ODESLÁNO: {len(sent)} zásilek")
for s in sent:
print(f" [{s.get('wave','?')}] {s['subject']} ({s.get('date','?')})")
print(f"\n📊 Celkem: {len(ev.get('received',[]))} přijato | {len(sent)} odesláno | {len(pending)} čeká")
print("="*65)
Email seznam.cz
Pro email komunikaci zkontroluj /lg13-skills:email-read. Filtruj:
- Odesílatel/adresát:
@c-budejovice.cz, @kraj-jihocesky.cz, @euceb.cz, @akjudrflaska.com
- Předmět:
0 P 29/2026, Kopecký, Matouš
Evidence soubory
| Soubor | Účel |
|---|
Inbox/isds/isds_evidence.json | Primární evidence — received/sent/pending/alerts |
Inbox/isds/*.ocr.txt | OCR text každého PDF |
L:\LG13\legal_docs_catalogue\ | Globální katalog všech legal docs |
OCR katalogizace hromadně:
python L:\LG13\app\agent_pre_junction_backup\skills\legal_ocr_catalogue.py --scan
Institutions DS
| Instituce | DS | Role |
|---|
| OS České Budějovice | ws6abvh | soud |
| Mgr. Jan Škorpil, EU ČB | hvknnv7 | exekutor |
| Jihočeský kraj OSPOD | kdib3rr | nadřízený OSPOD |
| Tom Kopecký | vprwiuq | my DS |
Common Mistakes
- Zapomenout spustit OCR před katalogizací →
no_ocr list pokaždé zkontrolovat
- Označit dokument jako processed bez skutečné analýzy →
processed: true jen po Tom GO
- Přehlédnout P0_ALERT priority → vždy zobrazit první