Files
AgentHub/embed-images.py
T
nntrivi2001 952e8584f0 feat: per-change-block hunk actions (#50), codex lanes without a pipeline, macOS LaunchAgent
- git (#50): stage-hunk/discard-hunk take an optional `block` — one run of
  consecutive +/- lines inside an @@ hunk. `onlyBlock` (server/lib/git-diff.js)
  cuts git's fresh hunk down to it, folding the other blocks into the side
  being checked; LaneDiffView hangs one review bar per block (unified + split)
  and its arrows walk blocks.
- git exclude: entries AgentHub writes for a lane go to the COMMON git dir with
  the lane's path prefix (server/lib/git-exclude.js, used by router-apply and
  lane-mcp) — a linked worktree's own info/exclude is never read by git, and a
  subdir lane has no .git. MCP sync no longer fails with ENOTDIR on a worktree
  lane or creates a stray .git in a non-repo lane.
- codex lanes carry no pipeline: codex-ingest mirrors only idle/running,
  codex-nudge is removed, agents install writes nothing for codex, the
  Workspace hides stage/pipeline/feature pickers/PipelineMap for them, and
  every server start clears leftover codex stage data and the old AGENTS.md
  stage block.
- Changes panel: a whole file opens for reading and enters the editor on a
  click on its text (caret at the clicked line), not automatically.
- macOS: LaunchAgent start-at-login (scripts/launchd-service.js, picked by
  scripts/service-manager.js).
- Adds the AgentHub introduction slides and their image-embedding script.
2026-09-25 17:30:28 +07:00

36 lines
1.2 KiB
Python

#!/usr/bin/env python3
"""Nhúng mọi ảnh cục bộ của slide vào thẳng file HTML dưới dạng data URI.
Đọc agenthub-introduction.html, thay từng src="*.png" bằng chuỗi base64, ghi ra
agenthub-introduction-standalone.html - một file duy nhất, gửi cho ai cũng thấy ảnh.
Chạy lại sau mỗi lần sửa slide.
@author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
"""
import base64
import mimetypes
import pathlib
import re
import sys
import urllib.parse
SRC = pathlib.Path(__file__).parent / "agenthub-introduction.html"
OUT = SRC.with_name("agenthub-introduction-standalone.html")
def inline(match):
raw = match.group(1)
if raw.startswith(("data:", "http://", "https://")):
return match.group(0)
path = SRC.parent / urllib.parse.unquote(raw)
if not path.is_file():
sys.exit(f"thiếu ảnh: {path}")
mime = mimetypes.guess_type(path.name)[0] or "application/octet-stream"
b64 = base64.b64encode(path.read_bytes()).decode()
return f'src="data:{mime};base64,{b64}"'
html = SRC.read_text(encoding="utf-8")
OUT.write_text(re.sub(r'src="([^"]+)"', inline, html), encoding="utf-8")
print(f"{OUT.name} - {OUT.stat().st_size / 1024 / 1024:.1f} MB")