cc-continuity 0.3.22__tar.gz → 0.3.23__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/PKG-INFO +1 -1
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/README.md +1 -1
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/__init__.py +1 -1
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/transcript.py +45 -2
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity.egg-info/PKG-INFO +1 -1
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/pyproject.toml +1 -1
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_transcript.py +66 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/LICENSE +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/__main__.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/atomic.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/blink.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/blink_watch.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/bootstrap.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/checkpoint.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/cli.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/config.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/daemon_supervisor.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/doctor.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/gitsnap.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/hooks/__init__.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/hooks/common.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/hooks/pre_compact.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/hooks/pre_tool_use.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/hooks/session_end.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/hooks/session_start.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/hooks/stop.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/hooks/task.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/hooks/tool_use.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/hooks/user_prompt.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/hosting.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/install.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/launch.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/ledger.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/lock.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/managed.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/naming.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/notify.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/paths.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/power_plug.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/progress_pane.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/project.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/redact.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/rotator.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/settings_merge.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/skills.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/state.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/statusline.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/thresholds.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/validate.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/watchdog.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/watchdog_digest.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity/watchdogd.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity.egg-info/SOURCES.txt +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity.egg-info/dependency_links.txt +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity.egg-info/entry_points.txt +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/cc_continuity.egg-info/top_level.txt +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/setup.cfg +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_atomic.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_blink.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_blink_watch.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_bootstrap.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_checkpoint.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_cli.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_cli_ledger.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_config.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_daemon_supervisor.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_doctor.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_gitsnap.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_hooks_common.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_hooks_pre_compact.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_hooks_pre_tool_use.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_hooks_session_end.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_hooks_session_start.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_hooks_stop.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_hooks_task.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_hooks_tool_use.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_hooks_user_prompt.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_hosting.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_hygiene.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_install.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_integration_phase5.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_integration_phase6.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_integration_phase7.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_launch.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_ledger.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_lock.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_managed.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_naming.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_notify.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_notify_integration.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_paths.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_power_plug.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_progress_pane.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_project.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_redact.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_rotator.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_settings_merge.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_skills.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_state.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_status.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_statusline.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_thresholds.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_tmux_host.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_transcript_finalize.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_uninstall.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_validate.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_watchdog.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_watchdog_digest.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_watchdog_integration.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_watchdogd.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_wsl_doctor.py +0 -0
- {cc_continuity-0.3.22 → cc_continuity-0.3.23}/tests/test_wsl_install.py +0 -0
|
@@ -26,11 +26,11 @@ The five most recent updates, newest first. Each line links to its
|
|
|
26
26
|
commit, so you can see what changed lately without digging through the
|
|
27
27
|
log:
|
|
28
28
|
|
|
29
|
+
- **2026-11-12**: The `🖼 image` chip gained a second source: records that keep only the `[Image: source: <path>]` line (no base64 block) now have their file read from disk at export time and embedded, so those chips open in the lightbox too. The read is best-effort (whitelisted extensions, per-image cap), and missing, pruned or oversized files keep the plain chip ([commit](https://github.com/pqant/claude-continuity/commit/26d0144)).
|
|
29
30
|
- **2026-11-11**: The `🖼 image` chip became a window: clicking it opens the real pasted image in a lightbox modal right on the transcript page (prev/next + `i / n` counter, Escape or backdrop click closes). Images are embedded as data URIs, so the export stays a single self-contained HTML file; a folded run of chips shares one merged gallery, and over-cap or non-whitelisted images keep the plain chip ([commit](https://github.com/pqant/claude-continuity/commit/369f9a4)).
|
|
30
31
|
- **2026-11-11**: The transcript page now stays out of the conversation's way: protocol plumbing is filtered out (slash-command XML from `/clear` and `/rename`, task notifications, Continuity Stop-hook feedback, skill base-directory lines, `No response requested.`), the CONTINUITY RESUME blob and CC's resume prompt collapse to one-line anchors (`↻ CONTINUITY RESUME cp-NNN · handoff.md`, `↻ CC resume`), and pasted images fold into a single `🖼 image` chip instead of raw metadata lines ([commit](https://github.com/pqant/claude-continuity/commit/6366583)).
|
|
31
32
|
- **2026-11-11**: Deferred rotations now wake themselves up: when the rotator defers because the agent was still active after the Stop, it arms a bounded self-retry tick that re-checks a short delay later and drives the rotation itself once the session is quiet. The Stop hook stays the primary route, the tick is idempotent (rotation_id guard) and capped in attempts, and `"retry_deferred": false` in the config turns the path off ([commit](https://github.com/pqant/claude-continuity/commit/dacaab0)).
|
|
32
33
|
- **2026-11-11**: DEGRADED handoffs now freeze themselves: the banner gained a direct order for the still-alive pre-rotation agent ("This file is finalized. Do not edit it and do not start any more work in this session; end your turn now."), so a finished handoff can no longer be reached into and edited after finalization ([commit](https://github.com/pqant/claude-continuity/commit/5b2a07e)).
|
|
33
|
-
- **2026-11-11**: The HUD prev-task segment is now readable at a glance: the Active Usage line reads `⏱ Previous task completion 39m 15s` (spaced units; `1h 2m 03s` and `47s` too) instead of `⏱ prev task 39m15s`, while the turn clock prompt line keeps its compact shape ([commit](https://github.com/pqant/claude-continuity/commit/12dd90b)).
|
|
34
34
|
## How it works
|
|
35
35
|
|
|
36
36
|
The whole flow in one picture: the automatic session loop, the optional
|
|
@@ -11,6 +11,7 @@ finalize, validation, or resume (P9-D7). Stdlib only, English strings.
|
|
|
11
11
|
|
|
12
12
|
from __future__ import annotations
|
|
13
13
|
|
|
14
|
+
import base64
|
|
14
15
|
import html
|
|
15
16
|
import json
|
|
16
17
|
import re
|
|
@@ -57,6 +58,11 @@ _IMAGE_CHIP = "\U0001f5bc image"
|
|
|
57
58
|
#: chip so the single-file export stays sane.
|
|
58
59
|
_IMG_MEDIA = ("image/png", "image/jpeg", "image/gif", "image/webp")
|
|
59
60
|
_MAX_IMG_B64 = 4_000_000
|
|
61
|
+
#: Path-only records (issue #56): extension -> media type for reading a
|
|
62
|
+
#: pasted image whose file is still sitting under ``.claude/image-cache``
|
|
63
|
+
#: (the directory is pruned later, so only the export can catch it).
|
|
64
|
+
_IMG_MIME = {".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg",
|
|
65
|
+
".gif": "image/gif", ".webp": "image/webp"}
|
|
60
66
|
|
|
61
67
|
|
|
62
68
|
def md_inline(s: str) -> str:
|
|
@@ -91,6 +97,29 @@ def _image_uri(block: dict) -> str:
|
|
|
91
97
|
return f"data:{media};base64,{data}"
|
|
92
98
|
|
|
93
99
|
|
|
100
|
+
def _image_from_path(path: str) -> str:
|
|
101
|
+
"""Data URI for a pasted image whose file is still on disk (issue #56).
|
|
102
|
+
|
|
103
|
+
Some records keep only the ``[Image: source: <path>]`` text line and
|
|
104
|
+
no base64 block; the bytes live under ``.claude/image-cache`` until
|
|
105
|
+
pruned, so the export (which runs at rotation time, minutes after the
|
|
106
|
+
paste) reads them best-effort. Non-whitelisted extensions, anything
|
|
107
|
+
unreadable, and data past ``_MAX_IMG_B64`` return an empty string so
|
|
108
|
+
the chip stays plain.
|
|
109
|
+
"""
|
|
110
|
+
p = Path(path)
|
|
111
|
+
try:
|
|
112
|
+
media = _IMG_MIME.get(p.suffix.lower())
|
|
113
|
+
if media is None or not p.is_file():
|
|
114
|
+
return ""
|
|
115
|
+
data = base64.b64encode(p.read_bytes()).decode("ascii")
|
|
116
|
+
except OSError:
|
|
117
|
+
return ""
|
|
118
|
+
if not data or len(data) > _MAX_IMG_B64:
|
|
119
|
+
return ""
|
|
120
|
+
return f"data:{media};base64,{data}"
|
|
121
|
+
|
|
122
|
+
|
|
94
123
|
def md_to_html(md: str) -> str:
|
|
95
124
|
"""Block-level markdown subset to an HTML fragment.
|
|
96
125
|
|
|
@@ -165,8 +194,9 @@ def parse_conversation(lines: list[str]) -> list[Block]:
|
|
|
165
194
|
anchors; image metadata lines fold into a ``🖼 image`` chip (runs of
|
|
166
195
|
chips collapse to one, their galleries merge). Embeddable base64
|
|
167
196
|
image blocks attach to the block as ``data:`` URIs for the lightbox
|
|
168
|
-
(issue #55)
|
|
169
|
-
|
|
197
|
+
(issue #55); records that only carry the ``[Image: source: <path>]``
|
|
198
|
+
line read the file from disk when it is still present (issue #56).
|
|
199
|
+
Runs of 3+ newlines in assistant text collapse to exactly two.
|
|
170
200
|
"""
|
|
171
201
|
out: list[Block] = []
|
|
172
202
|
for raw in lines:
|
|
@@ -211,12 +241,25 @@ def parse_conversation(lines: list[str]) -> list[Block]:
|
|
|
211
241
|
# Image metadata lines become a chip; human text in a mixed
|
|
212
242
|
# record survives without them (issue #54).
|
|
213
243
|
kept = []
|
|
244
|
+
src_paths: list[str] = []
|
|
214
245
|
for ln in text.split("\n"):
|
|
215
246
|
if ln.startswith(_IMAGE_PREFIXES):
|
|
216
247
|
had_image = True
|
|
248
|
+
# Path-only records (issue #56): collect the disk path
|
|
249
|
+
# unless a base64 block already embeds this record.
|
|
250
|
+
if not imgs and ln.startswith("[Image: source:"):
|
|
251
|
+
p = ln.split("source:", 1)[1].strip()
|
|
252
|
+
if p.endswith("]"):
|
|
253
|
+
p = p[:-1].strip()
|
|
254
|
+
if p:
|
|
255
|
+
src_paths.append(p)
|
|
217
256
|
else:
|
|
218
257
|
kept.append(ln)
|
|
219
258
|
text = "\n".join(kept).strip()
|
|
259
|
+
for p in src_paths:
|
|
260
|
+
uri = _image_from_path(p)
|
|
261
|
+
if uri:
|
|
262
|
+
imgs.append(uri)
|
|
220
263
|
if not text:
|
|
221
264
|
if not had_image and not imgs:
|
|
222
265
|
continue
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "cc-continuity"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.23"
|
|
8
8
|
description = "Zero-touch session rotation for Claude Code (local large-context model)"
|
|
9
9
|
requires-python = ">=3.11"
|
|
10
10
|
dependencies = [] # stdlib only at runtime (PRD §0.5)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""transcript.py: issue #8 - JSONL parsing, markdown rendering, HTML export."""
|
|
2
2
|
|
|
3
|
+
import base64
|
|
3
4
|
import json
|
|
4
5
|
from datetime import datetime
|
|
5
6
|
from pathlib import Path
|
|
@@ -156,6 +157,71 @@ def test_render_markdown_ignores_images():
|
|
|
156
157
|
assert "metin" in md and "base64" not in md
|
|
157
158
|
|
|
158
159
|
|
|
160
|
+
# --- issue #56: path-only image records read from disk at export ---------
|
|
161
|
+
|
|
162
|
+
PNG1x1 = ("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQ"
|
|
163
|
+
"DwAEhQGAhKmMIQAAAABJRU5ErkJggg==")
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def _png(tmp_path, name="shot.png"):
|
|
167
|
+
p = tmp_path / name
|
|
168
|
+
p.write_bytes(base64.b64decode(PNG1x1))
|
|
169
|
+
return p
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def test_path_only_record_embeds_disk_image(tmp_path):
|
|
173
|
+
png = _png(tmp_path)
|
|
174
|
+
blocks = transcript.parse_conversation([
|
|
175
|
+
_rec("user", f"[Image: source: {png}]")])
|
|
176
|
+
assert [t for _, t, _, _ in blocks] == ["🖼 image"]
|
|
177
|
+
assert list(blocks[0][3]) == [f"data:image/png;base64,{PNG1x1}"]
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def test_mixed_text_and_source_path_keeps_text(tmp_path):
|
|
181
|
+
png = _png(tmp_path)
|
|
182
|
+
blocks = transcript.parse_conversation([
|
|
183
|
+
_rec("user", f"bunu gordun mu ???\n[Image: source: {png}]")])
|
|
184
|
+
assert len(blocks) == 1
|
|
185
|
+
assert blocks[0][1] == "bunu gordun mu ???"
|
|
186
|
+
assert list(blocks[0][3]) == [f"data:image/png;base64,{PNG1x1}"]
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def test_unreadable_paths_stay_plain_chip(tmp_path):
|
|
190
|
+
missing = tmp_path / "gone.png"
|
|
191
|
+
adir = tmp_path / "dir.png"
|
|
192
|
+
adir.mkdir()
|
|
193
|
+
txt = tmp_path / "note.txt"
|
|
194
|
+
txt.write_bytes(b"not an image")
|
|
195
|
+
big = tmp_path / "big.png"
|
|
196
|
+
big.write_bytes(b"\x00" * (transcript._MAX_IMG_B64 + 1))
|
|
197
|
+
blocks = transcript.parse_conversation([
|
|
198
|
+
_rec("user", f"[Image: source: {missing}]"),
|
|
199
|
+
_rec("user", f"[Image: source: {adir}]"),
|
|
200
|
+
_rec("user", f"[Image: source: {txt}]"),
|
|
201
|
+
_rec("user", f"[Image: source: {big}]"),
|
|
202
|
+
_rec("user", "[Image: source: not-a-real-path]")])
|
|
203
|
+
assert [t for _, t, _, _ in blocks] == ["🖼 image"]
|
|
204
|
+
assert list(blocks[0][3]) == []
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def test_base64_block_prevents_disk_reread(tmp_path):
|
|
208
|
+
png = _png(tmp_path)
|
|
209
|
+
blocks = transcript.parse_conversation([
|
|
210
|
+
_rec("user", [{"type": "text", "text": f"[Image: source: {png}]"},
|
|
211
|
+
_img(data="QQ==")])])
|
|
212
|
+
assert list(blocks[0][3]) == ["data:image/png;base64,QQ=="]
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def test_multiple_source_lines_embed_in_order(tmp_path):
|
|
216
|
+
a = _png(tmp_path, "a.png")
|
|
217
|
+
b = _png(tmp_path, "b.jpg")
|
|
218
|
+
blocks = transcript.parse_conversation([
|
|
219
|
+
_rec("user", f"[Image: source: {a}]\n[Image: source: {b}]")])
|
|
220
|
+
assert [t for _, t, _, _ in blocks] == ["🖼 image"]
|
|
221
|
+
assert list(blocks[0][3]) == [f"data:image/png;base64,{PNG1x1}",
|
|
222
|
+
f"data:image/jpeg;base64,{PNG1x1}"]
|
|
223
|
+
|
|
224
|
+
|
|
159
225
|
def test_table_fenced_and_escaping():
|
|
160
226
|
md = "|a|b|\n|--|--|\n|1|b|\n\n<script>x</script>\n\n```\nprint(1)\n```\n\nplain **b** `c`"
|
|
161
227
|
out = transcript.md_to_html(md)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|