cc-continuity 0.3.20__tar.gz → 0.3.22__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.20 → cc_continuity-0.3.22}/PKG-INFO +1 -1
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/README.md +2 -2
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/__init__.py +1 -1
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/transcript.py +174 -15
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity.egg-info/PKG-INFO +1 -1
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/pyproject.toml +1 -1
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_transcript.py +129 -1
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/LICENSE +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/__main__.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/atomic.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/blink.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/blink_watch.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/bootstrap.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/checkpoint.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/cli.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/config.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/daemon_supervisor.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/doctor.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/gitsnap.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/hooks/__init__.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/hooks/common.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/hooks/pre_compact.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/hooks/pre_tool_use.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/hooks/session_end.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/hooks/session_start.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/hooks/stop.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/hooks/task.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/hooks/tool_use.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/hooks/user_prompt.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/hosting.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/install.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/launch.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/ledger.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/lock.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/managed.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/naming.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/notify.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/paths.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/power_plug.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/progress_pane.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/project.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/redact.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/rotator.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/settings_merge.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/skills.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/state.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/statusline.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/thresholds.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/validate.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/watchdog.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/watchdog_digest.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity/watchdogd.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity.egg-info/SOURCES.txt +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity.egg-info/dependency_links.txt +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity.egg-info/entry_points.txt +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/cc_continuity.egg-info/top_level.txt +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/setup.cfg +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_atomic.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_blink.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_blink_watch.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_bootstrap.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_checkpoint.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_cli.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_cli_ledger.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_config.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_daemon_supervisor.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_doctor.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_gitsnap.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_hooks_common.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_hooks_pre_compact.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_hooks_pre_tool_use.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_hooks_session_end.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_hooks_session_start.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_hooks_stop.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_hooks_task.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_hooks_tool_use.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_hooks_user_prompt.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_hosting.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_hygiene.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_install.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_integration_phase5.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_integration_phase6.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_integration_phase7.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_launch.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_ledger.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_lock.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_managed.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_naming.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_notify.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_notify_integration.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_paths.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_power_plug.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_progress_pane.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_project.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_redact.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_rotator.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_settings_merge.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_skills.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_state.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_status.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_statusline.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_thresholds.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_tmux_host.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_transcript_finalize.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_uninstall.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_validate.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_watchdog.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_watchdog_digest.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_watchdog_integration.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_watchdogd.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/tests/test_wsl_doctor.py +0 -0
- {cc_continuity-0.3.20 → cc_continuity-0.3.22}/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-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
|
+
- **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)).
|
|
29
31
|
- **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)).
|
|
30
32
|
- **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)).
|
|
31
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)).
|
|
32
|
-
- **2026-11-11**: `cc-continuity status [slug]`: inspect any registered project from anywhere - the same block (rotation line and `--json` included), resolved through the exact slug matching `ratio` uses, so the two commands can never point at different projects ([commit](https://github.com/pqant/claude-continuity/commit/2ea65a3)).
|
|
33
|
-
- **2026-11-11**: New `cc-continuity ledger [n]`: the session ledger finally has a reader. The gate decisions from #39, the state transitions and the prompts print as compact single lines (`HH:MM:SS type key=value…`), newest N (default 20), resolved the same way `status` resolves the session ([commit](https://github.com/pqant/claude-continuity/commit/d84a8ea)).
|
|
34
34
|
## How it works
|
|
35
35
|
|
|
36
36
|
The whole flow in one picture: the automatic session loop, the optional
|
|
@@ -17,11 +17,23 @@ import re
|
|
|
17
17
|
import time
|
|
18
18
|
from datetime import datetime
|
|
19
19
|
from pathlib import Path
|
|
20
|
+
from typing import NamedTuple
|
|
20
21
|
|
|
21
22
|
from cc_continuity import atomic, paths
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
Block
|
|
24
|
+
|
|
25
|
+
class Block(NamedTuple):
|
|
26
|
+
"""One conversation turn.
|
|
27
|
+
|
|
28
|
+
``images`` holds embeddable ``data:`` URIs for pasted attachments
|
|
29
|
+
(issue #55); empty means no embeddable image (a plain text chip may
|
|
30
|
+
still stand). The renderers also accept plain 3-tuples.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
role: str
|
|
34
|
+
text: str
|
|
35
|
+
ts: str | None
|
|
36
|
+
images: tuple[str, ...] = ()
|
|
25
37
|
|
|
26
38
|
_REMINDER_RE = re.compile(r"<system-reminder>.*?</system-reminder>", re.S)
|
|
27
39
|
_MULTI_NL = re.compile(r"\n{3,}")
|
|
@@ -29,6 +41,23 @@ _LIST_RE = re.compile(r"^\s*([-*]|\d+\.)\s+")
|
|
|
29
41
|
_SEP_ROW_RE = re.compile(r"^[\s:|-]+$")
|
|
30
42
|
_TABLE_SEP_RE = re.compile(r"^\s*\|?[\s:|-]+\|[\s:|-]*$")
|
|
31
43
|
|
|
44
|
+
#: Protocol plumbing dropped outright (issue #54): slash-command XML,
|
|
45
|
+
#: task notifications, skill base-directory lines (plus the pre-existing
|
|
46
|
+
#: local-command/caveat noise). "Stop hook feedback:" is checked
|
|
47
|
+
#: separately - only CONTINUITY-bearing injections are dropped.
|
|
48
|
+
_NOISE_PREFIXES = ("<local-command", "Caveat:", "<command-name>",
|
|
49
|
+
"<command-message>", "<command-args>",
|
|
50
|
+
"<task-notification>", "Base directory for this skill:")
|
|
51
|
+
#: Image metadata lines from pasted attachments (issue #54); they fold
|
|
52
|
+
#: into a single chip so the image trace survives without the bulk.
|
|
53
|
+
_IMAGE_PREFIXES = ("[Image: source:", "[Image: original")
|
|
54
|
+
_IMAGE_CHIP = "\U0001f5bc image"
|
|
55
|
+
#: Embeddable image bounds (issue #55): whitelisted media types and a
|
|
56
|
+
#: per-image base64 cap. Anything outside keeps a plain (non-clickable)
|
|
57
|
+
#: chip so the single-file export stays sane.
|
|
58
|
+
_IMG_MEDIA = ("image/png", "image/jpeg", "image/gif", "image/webp")
|
|
59
|
+
_MAX_IMG_B64 = 4_000_000
|
|
60
|
+
|
|
32
61
|
|
|
33
62
|
def md_inline(s: str) -> str:
|
|
34
63
|
"""Inline markdown on escaped text: code spans, bold, italic."""
|
|
@@ -44,6 +73,24 @@ def _is_table_start(lines: list[str], i: int) -> bool:
|
|
|
44
73
|
and _TABLE_SEP_RE.match(lines[i + 1] or "x"))
|
|
45
74
|
|
|
46
75
|
|
|
76
|
+
def _image_uri(block: dict) -> str:
|
|
77
|
+
"""Data URI for an embeddable base64 image block (empty if not).
|
|
78
|
+
|
|
79
|
+
Only whitelisted media types, ``source.type == "base64"`` and data
|
|
80
|
+
within ``_MAX_IMG_B64`` embed (issue #55).
|
|
81
|
+
"""
|
|
82
|
+
src = block.get("source")
|
|
83
|
+
if not isinstance(src, dict) or src.get("type") != "base64":
|
|
84
|
+
return ""
|
|
85
|
+
media = src.get("media_type")
|
|
86
|
+
data = src.get("data")
|
|
87
|
+
if media not in _IMG_MEDIA or not isinstance(data, str) or not data:
|
|
88
|
+
return ""
|
|
89
|
+
if len(data) > _MAX_IMG_B64:
|
|
90
|
+
return ""
|
|
91
|
+
return f"data:{media};base64,{data}"
|
|
92
|
+
|
|
93
|
+
|
|
47
94
|
def md_to_html(md: str) -> str:
|
|
48
95
|
"""Block-level markdown subset to an HTML fragment.
|
|
49
96
|
|
|
@@ -110,9 +157,16 @@ def parse_conversation(lines: list[str]) -> list[Block]:
|
|
|
110
157
|
"""Text turns of user/assistant records in order, noise removed.
|
|
111
158
|
|
|
112
159
|
Unparseable JSONL lines are skipped silently; tool-use payloads,
|
|
113
|
-
system/summary records, ``<system-reminder>`` spans, and
|
|
114
|
-
|
|
115
|
-
|
|
160
|
+
system/summary records, ``<system-reminder>`` spans, and protocol
|
|
161
|
+
plumbing (slash-command XML, task notifications, Continuity Stop-hook
|
|
162
|
+
feedback, skill base-directory lines, ``No response requested.``)
|
|
163
|
+
never reach the output (issue #54). The CONTINUITY RESUME blob and
|
|
164
|
+
CC's "Continue from where you left off." prompt collapse to one-line
|
|
165
|
+
anchors; image metadata lines fold into a ``🖼 image`` chip (runs of
|
|
166
|
+
chips collapse to one, their galleries merge). Embeddable base64
|
|
167
|
+
image blocks attach to the block as ``data:`` URIs for the lightbox
|
|
168
|
+
(issue #55). Runs of 3+ newlines in assistant text collapse to
|
|
169
|
+
exactly two.
|
|
116
170
|
"""
|
|
117
171
|
out: list[Block] = []
|
|
118
172
|
for raw in lines:
|
|
@@ -123,23 +177,67 @@ def parse_conversation(lines: list[str]) -> list[Block]:
|
|
|
123
177
|
if not isinstance(rec, dict) or rec.get("type") not in ("user", "assistant"):
|
|
124
178
|
continue
|
|
125
179
|
content = (rec.get("message") or {}).get("content")
|
|
180
|
+
imgs: list[str] = []
|
|
126
181
|
if isinstance(content, str):
|
|
127
182
|
parts = [content]
|
|
128
183
|
elif isinstance(content, list):
|
|
129
184
|
parts = [b.get("text", "") for b in content
|
|
130
185
|
if isinstance(b, dict) and b.get("type") == "text"]
|
|
186
|
+
for b in content:
|
|
187
|
+
if isinstance(b, dict) and b.get("type") == "image":
|
|
188
|
+
uri = _image_uri(b)
|
|
189
|
+
if uri:
|
|
190
|
+
imgs.append(uri)
|
|
131
191
|
else:
|
|
132
192
|
continue
|
|
133
193
|
text = "\n".join(t for t in parts if t and t.strip())
|
|
134
|
-
if not text:
|
|
135
|
-
continue
|
|
136
|
-
text = _REMINDER_RE.sub("", text).strip()
|
|
137
|
-
if not text or text.startswith(("<local-command", "Caveat:")):
|
|
194
|
+
if not text and not imgs:
|
|
138
195
|
continue
|
|
196
|
+
if text:
|
|
197
|
+
text = _REMINDER_RE.sub("", text).strip()
|
|
198
|
+
had_image = False
|
|
199
|
+
if text:
|
|
200
|
+
if text.startswith(_NOISE_PREFIXES):
|
|
201
|
+
continue
|
|
202
|
+
# Real records are "Stop hook feedback:\nCONTINUITY ...";
|
|
203
|
+
# only these injections drop, other hook feedback survives
|
|
204
|
+
# (issue #54).
|
|
205
|
+
if text[:120].replace("\n", " ").startswith(
|
|
206
|
+
"Stop hook feedback: CONTINUITY"):
|
|
207
|
+
continue
|
|
208
|
+
if (rec["type"] == "assistant"
|
|
209
|
+
and text.startswith("No response requested.")):
|
|
210
|
+
continue
|
|
211
|
+
# Image metadata lines become a chip; human text in a mixed
|
|
212
|
+
# record survives without them (issue #54).
|
|
213
|
+
kept = []
|
|
214
|
+
for ln in text.split("\n"):
|
|
215
|
+
if ln.startswith(_IMAGE_PREFIXES):
|
|
216
|
+
had_image = True
|
|
217
|
+
else:
|
|
218
|
+
kept.append(ln)
|
|
219
|
+
text = "\n".join(kept).strip()
|
|
220
|
+
if not text:
|
|
221
|
+
if not had_image and not imgs:
|
|
222
|
+
continue
|
|
223
|
+
text = _IMAGE_CHIP
|
|
224
|
+
if out and out[-1].text == _IMAGE_CHIP:
|
|
225
|
+
# Fold the run: merge the galleries into one chip.
|
|
226
|
+
if imgs:
|
|
227
|
+
out[-1] = out[-1]._replace(
|
|
228
|
+
images=out[-1].images + tuple(imgs))
|
|
229
|
+
continue
|
|
230
|
+
if text.startswith("CONTINUITY RESUME cp-"):
|
|
231
|
+
m = re.search(r"cp-(\d{3})", text)
|
|
232
|
+
tag = f"cp-{m.group(1)} " if m else ""
|
|
233
|
+
text = f"↻ CONTINUITY RESUME {tag}· handoff.md"
|
|
234
|
+
elif text.startswith("Continue from where you left off."):
|
|
235
|
+
text = "↻ CC resume"
|
|
139
236
|
if rec["type"] == "assistant":
|
|
140
237
|
text = _MULTI_NL.sub("\n\n", text)
|
|
141
238
|
ts = rec.get("timestamp")
|
|
142
|
-
out.append((rec["type"], text,
|
|
239
|
+
out.append(Block(rec["type"], text,
|
|
240
|
+
ts if isinstance(ts, str) else None, tuple(imgs)))
|
|
143
241
|
return out
|
|
144
242
|
|
|
145
243
|
|
|
@@ -181,6 +279,16 @@ ul,ol{margin:.45em 0;padding-left:1.5em}li{margin:.15em 0}
|
|
|
181
279
|
table{border-collapse:collapse;margin:10px 0}th,td{border:1px solid var(--line);padding:5px 10px}th{background:var(--hdr)}
|
|
182
280
|
mark{background:var(--mark);color:inherit;border-radius:2px;padding:0 1px}
|
|
183
281
|
.block.hidden{display:none}
|
|
282
|
+
.chipbtn{cursor:pointer;border:0;background:none;font:inherit;color:inherit;padding:0;text-decoration:underline dotted}
|
|
283
|
+
.chipbtn:hover{text-decoration:underline}
|
|
284
|
+
.lb{position:fixed;inset:0;background:rgba(0,0,0,.85);z-index:60;display:flex;align-items:center;justify-content:center}
|
|
285
|
+
.lb[hidden]{display:none}
|
|
286
|
+
.lbb{display:flex;flex-direction:column;align-items:center;gap:10px;max-width:92vw}
|
|
287
|
+
.lbb img{max-width:92vw;max-height:80vh;border-radius:8px;background:#fff}
|
|
288
|
+
.lbn{display:flex;gap:10px;align-items:center}
|
|
289
|
+
.lbn button,.lbx{background:#222b;border:1px solid #555;color:#fff;border-radius:6px;padding:4px 12px;font-size:15px;cursor:pointer}
|
|
290
|
+
.lbn span{color:#fff;font-size:14px}
|
|
291
|
+
.lbx{position:fixed;top:14px;right:18px}
|
|
184
292
|
"""
|
|
185
293
|
|
|
186
294
|
#: In-page search (case-insensitive ``<mark>`` hits, optional block filter
|
|
@@ -239,6 +347,38 @@ if(lbl)lbl.textContent=all.length>1?'Sessions':'Session';
|
|
|
239
347
|
sel.onchange=function(){if(this.value)location.href=up+this.value;};})();
|
|
240
348
|
"""
|
|
241
349
|
|
|
350
|
+
#: Lightbox shell for the image chips (issue #55): one fixed overlay,
|
|
351
|
+
#: reused by every chip button. Injected only when images are embedded.
|
|
352
|
+
_LIGHTBOX = ('<div id="lb" class="lb" hidden>'
|
|
353
|
+
'<button id="lbx" class="lbx">close</button>'
|
|
354
|
+
'<div class="lbb"><img id="lbi" alt="">'
|
|
355
|
+
'<div class="lbn"><button id="lbp">‹ prev</button>'
|
|
356
|
+
'<span id="lbc"></span>'
|
|
357
|
+
'<button id="lbn">next ›</button></div></div></div>')
|
|
358
|
+
|
|
359
|
+
#: Chip click opens the matching ``.lbg`` gallery in the overlay; prev/
|
|
360
|
+
#: next cycle with an ``i / n`` counter; close button, backdrop click or
|
|
361
|
+
#: Escape dismiss. ASCII only.
|
|
362
|
+
_LIGHTBOX_JS = r"""
|
|
363
|
+
(function(){var lb=document.getElementById('lb');if(!lb)return;
|
|
364
|
+
var img=document.getElementById('lbi'),ctr=document.getElementById('lbc'),g=null,n=0;
|
|
365
|
+
function hide(){lb.hidden=true;g=null;}
|
|
366
|
+
function show(){if(!g)return;var a=g.querySelectorAll('img');if(!a.length){hide();return;}
|
|
367
|
+
n=(n+a.length)%a.length;img.src=a[n].getAttribute('src');
|
|
368
|
+
ctr.textContent=(n+1)+' / '+a.length;}
|
|
369
|
+
document.addEventListener('click',function(e){var t=e.target;
|
|
370
|
+
var b=t.closest?t.closest('.chipbtn'):null;
|
|
371
|
+
if(b){g=document.getElementById(b.getAttribute('data-g'));n=0;
|
|
372
|
+
lb.hidden=false;show();return;}
|
|
373
|
+
if(t.id==='lbp'){n--;show();return;}
|
|
374
|
+
if(t.id==='lbn'){n++;show();return;}
|
|
375
|
+
if(t.id==='lbx'||t===lb){hide();}});
|
|
376
|
+
document.addEventListener('keydown',function(e){if(lb.hidden)return;
|
|
377
|
+
if(e.key==='Escape'){hide();}
|
|
378
|
+
else if(e.key==='ArrowLeft'){n--;show();}
|
|
379
|
+
else if(e.key==='ArrowRight'){n++;show();}});})();
|
|
380
|
+
"""
|
|
381
|
+
|
|
242
382
|
|
|
243
383
|
def _session_entry(html_path: Path, project_dir: Path) -> dict:
|
|
244
384
|
"""One manifest entry; ``_k`` is the private sort key (datetime)."""
|
|
@@ -464,13 +604,29 @@ def render_html(blocks: list[Block], meta: dict) -> str:
|
|
|
464
604
|
f'<select id="s" data-cur="{cur}" data-up="{up}"></select>')
|
|
465
605
|
switch_js = _SWITCH_JS
|
|
466
606
|
sections = []
|
|
467
|
-
|
|
607
|
+
galleries = []
|
|
608
|
+
for role, text, ts, *rest in blocks:
|
|
609
|
+
images = rest[0] if rest else ()
|
|
468
610
|
cls = "user" if role == "user" else "asst"
|
|
469
611
|
label = "User" if role == "user" else "Assistant"
|
|
612
|
+
if images:
|
|
613
|
+
# Issue #55: the chip opens a lightbox of the real pasted
|
|
614
|
+
# images; data URIs keep the export a single HTML file.
|
|
615
|
+
gid = f"lb-{len(galleries)}"
|
|
616
|
+
galleries.append(
|
|
617
|
+
f'<div class="lbg" id="{gid}" hidden>'
|
|
618
|
+
+ "".join(f'<img src="{html.escape(u, quote=True)}" alt="">'
|
|
619
|
+
for u in images) + "</div>")
|
|
620
|
+
chip = (f'<button class="chipbtn" data-g="{gid}">'
|
|
621
|
+
f'{_IMAGE_CHIP}</button>')
|
|
622
|
+
body = chip if text == _IMAGE_CHIP else (
|
|
623
|
+
md_to_html(text) + f"<p>{chip}</p>")
|
|
624
|
+
else:
|
|
625
|
+
body = md_to_html(text)
|
|
470
626
|
sections.append(
|
|
471
627
|
f'<section class="block {cls}"><h2 class="{cls}">{label} '
|
|
472
628
|
f'<span class="ts">{_ts_hms(ts)}</span></h2>'
|
|
473
|
-
f'<div class="body">{
|
|
629
|
+
f'<div class="body">{body}</div></section>')
|
|
474
630
|
return (
|
|
475
631
|
'<!doctype html><html data-theme="auto"><head><meta charset="utf-8">\n'
|
|
476
632
|
'<meta name="viewport" content="width=device-width,initial-scale=1">\n'
|
|
@@ -491,7 +647,10 @@ def render_html(blocks: list[Block], meta: dict) -> str:
|
|
|
491
647
|
'matching blocks only</label>\n'
|
|
492
648
|
'<button id="t">theme</button><span id="stats"></span></div></div></header>\n'
|
|
493
649
|
f'<main>{"".join(sections)}</main>\n'
|
|
494
|
-
f'{
|
|
650
|
+
f'{"".join(galleries)}'
|
|
651
|
+
f'{_LIGHTBOX if galleries else ""}'
|
|
652
|
+
f'{ext}<script>{_JS}{switch_js}'
|
|
653
|
+
f'{_LIGHTBOX_JS if galleries else ""}</script></body>')
|
|
495
654
|
|
|
496
655
|
|
|
497
656
|
def resolve_transcript_path(metric: dict | None, root: Path, sid: str | None,
|
|
@@ -543,7 +702,7 @@ def render_markdown(blocks: list[Block], meta: dict) -> str:
|
|
|
543
702
|
"""Canonical Markdown export: ``# <stem>`` title, then one section
|
|
544
703
|
per block (``## User``/``## Assistant`` + local time + raw text)."""
|
|
545
704
|
out = [f"# {meta.get('stem') or 'session'}", ""]
|
|
546
|
-
for role, text, ts in blocks:
|
|
705
|
+
for role, text, ts, *_ in blocks:
|
|
547
706
|
label = "User" if role == "user" else "Assistant"
|
|
548
707
|
clock = _ts_hms(ts)
|
|
549
708
|
out.append(f"## {label}" + (f" {clock}" if clock else ""))
|
|
@@ -589,7 +748,7 @@ def export_session(jsonl_path: Path, dest_dir: Path, meta: dict,
|
|
|
589
748
|
if oversize:
|
|
590
749
|
blocks = blocks + [("assistant", "[truncated]", None)]
|
|
591
750
|
first = last = None
|
|
592
|
-
for _, _, ts in blocks:
|
|
751
|
+
for _, _, ts, *_ in blocks:
|
|
593
752
|
stamp = _parse_ts(ts)
|
|
594
753
|
if stamp:
|
|
595
754
|
first = first or stamp
|
|
@@ -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.22"
|
|
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)
|
|
@@ -19,7 +19,7 @@ def test_order_roles_and_noise():
|
|
|
19
19
|
_rec("user", "<local-command-caveat>skip"), _rec("user", " "),
|
|
20
20
|
_rec("user", "Caveat: the messages below")]
|
|
21
21
|
blocks = transcript.parse_conversation(lines)
|
|
22
|
-
assert [(r, t) for r, t, _ in blocks] == [("user", "hello"), ("assistant", "hi"), ("user", "ok")]
|
|
22
|
+
assert [(r, t) for r, t, _, _ in blocks] == [("user", "hello"), ("assistant", "hi"), ("user", "ok")]
|
|
23
23
|
assert blocks[0][2] == "2026-11-05T19:26:03.123Z"
|
|
24
24
|
|
|
25
25
|
|
|
@@ -28,6 +28,134 @@ def test_assistant_whitespace_collapsed():
|
|
|
28
28
|
assert b[0][1] == "a\n\nb"
|
|
29
29
|
|
|
30
30
|
|
|
31
|
+
# --- issue #54: protocol plumbing must not crowd out the conversation ----
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_plumbing_records_dropped():
|
|
35
|
+
lines = [_rec("user", "gercek mesaj"),
|
|
36
|
+
_rec("user", "<command-name>/clear</command-name> "
|
|
37
|
+
"<command-message>clear</command-message> "
|
|
38
|
+
"<command-args></command-args>"),
|
|
39
|
+
_rec("user", "<task-notification>\n<task-id>bgc</task-id>\n"
|
|
40
|
+
"</task-notification>"),
|
|
41
|
+
_rec("user", "Stop hook feedback:\nCONTINUITY: context at 67%. "
|
|
42
|
+
"Rotation pending."),
|
|
43
|
+
_rec("user", "Base directory for this skill: /Users/x/.claude/skills/y"),
|
|
44
|
+
_rec("assistant", "No response requested."),
|
|
45
|
+
_rec("user", "devam")]
|
|
46
|
+
blocks = transcript.parse_conversation(lines)
|
|
47
|
+
assert [(r, t) for r, t, _, _ in blocks] == [("user", "gercek mesaj"),
|
|
48
|
+
("user", "devam")]
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def test_resume_anchors_collapsed():
|
|
52
|
+
resume = ("CONTINUITY RESUME cp-223: read /Users/x/handoff.md completely, "
|
|
53
|
+
"apply the VALIDATION result, then continue... " * 5)
|
|
54
|
+
blocks = transcript.parse_conversation(
|
|
55
|
+
[_rec("user", resume),
|
|
56
|
+
_rec("user", "Continue from where you left off.")])
|
|
57
|
+
assert [t for _, t, _, _ in blocks] == [
|
|
58
|
+
"↻ CONTINUITY RESUME cp-223 · handoff.md", "↻ CC resume"]
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def test_image_records_become_chips():
|
|
62
|
+
# consecutive chips fold into one; human text in a record survives
|
|
63
|
+
# without the metadata lines.
|
|
64
|
+
blocks = transcript.parse_conversation([
|
|
65
|
+
_rec("user", [{"type": "text", "text": "[Image: source: /x/1.png]"},
|
|
66
|
+
{"type": "text",
|
|
67
|
+
"text": "[Image: original 958x2062, displayed at 929x2000]"}]),
|
|
68
|
+
_rec("user", "[Image: source: /x/2.png]"),
|
|
69
|
+
_rec("user", "bunu gordun mu ???\n[Image: source: /x/3.png]")])
|
|
70
|
+
assert [t for _, t, _, _ in blocks] == ["🖼 image", "bunu gordun mu ???"]
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# --- issue #55: pasted images open in a lightbox modal --------------------
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _img(media="image/png", data="QUJD", stype="base64"):
|
|
77
|
+
return {"type": "image",
|
|
78
|
+
"source": {"type": stype, "media_type": media, "data": data}}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def test_image_blocks_attach_data_uris():
|
|
82
|
+
blocks = transcript.parse_conversation([
|
|
83
|
+
_rec("user", [{"type": "text", "text": "[Image: source: /x/1.png]"},
|
|
84
|
+
_img()])])
|
|
85
|
+
assert [t for _, t, _, _ in blocks] == ["🖼 image"]
|
|
86
|
+
assert list(blocks[0][3]) == ["data:image/png;base64,QUJD"]
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def test_pure_image_record_without_text_line():
|
|
90
|
+
blocks = transcript.parse_conversation([_rec("user", [_img(data="RAA=")])])
|
|
91
|
+
assert len(blocks) == 1
|
|
92
|
+
assert blocks[0][1] == "🖼 image"
|
|
93
|
+
assert list(blocks[0][3]) == ["data:image/png;base64,RAA="]
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def test_mixed_text_and_image_appends_chip():
|
|
97
|
+
blocks = transcript.parse_conversation([
|
|
98
|
+
_rec("user", [{"type": "text",
|
|
99
|
+
"text": "bunu gordun mu ???\n[Image: source: /x/3.png]"},
|
|
100
|
+
_img(media="image/jpeg", data="SUVHRQ==")])])
|
|
101
|
+
assert len(blocks) == 1
|
|
102
|
+
assert blocks[0][1] == "bunu gordun mu ???"
|
|
103
|
+
assert list(blocks[0][3]) == ["data:image/jpeg;base64,SUVHRQ=="]
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def test_folded_chips_merge_galleries():
|
|
107
|
+
blocks = transcript.parse_conversation([
|
|
108
|
+
_rec("user", [{"type": "text", "text": "[Image: source: /a]"},
|
|
109
|
+
_img(data="QQ==")]),
|
|
110
|
+
_rec("user", [{"type": "text", "text": "[Image: original 10x10]"},
|
|
111
|
+
_img(data="Qg==")])])
|
|
112
|
+
assert [t for _, t, _, _ in blocks] == ["🖼 image"]
|
|
113
|
+
assert list(blocks[0][3]) == ["data:image/png;base64,QQ==",
|
|
114
|
+
"data:image/png;base64,Qg=="]
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def test_oversize_and_bad_type_stay_plain_chip():
|
|
118
|
+
big = "A" * (transcript._MAX_IMG_B64 + 1)
|
|
119
|
+
blocks = transcript.parse_conversation([
|
|
120
|
+
_rec("user", [{"type": "text", "text": "[Image: source: /big]"},
|
|
121
|
+
_img(data=big)]),
|
|
122
|
+
_rec("user", [{"type": "text", "text": "[Image: source: /tif]"},
|
|
123
|
+
_img(media="image/tiff")]),
|
|
124
|
+
_rec("user", [{"type": "text", "text": "[Image: source: /u]"},
|
|
125
|
+
_img(stype="url")])])
|
|
126
|
+
assert [t for _, t, _, _ in blocks] == ["🖼 image"]
|
|
127
|
+
assert list(blocks[0][3]) == []
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def test_render_html_chip_clickable_with_images():
|
|
131
|
+
b = [("user", "🖼 image", None, ("data:image/png;base64,QUJD",)),
|
|
132
|
+
("user", "metin", None, ("data:image/png;base64,QkI=",))]
|
|
133
|
+
d = transcript.render_html(b, META)
|
|
134
|
+
assert d.count('class="chipbtn"') == 2
|
|
135
|
+
assert "data:image/png;base64,QUJD" in d
|
|
136
|
+
assert 'id="lb"' in d and 'id="lbi"' in d
|
|
137
|
+
assert d.index("metin") < d.rindex('class="chipbtn"') # mixed chip trails text
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def test_render_html_plain_chip_not_clickable():
|
|
141
|
+
d = transcript.render_html([("user", "🖼 image", None)], META)
|
|
142
|
+
assert 'class="chipbtn"' not in d and 'id="lb"' not in d
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def test_render_html_folded_run_one_button_two_images():
|
|
146
|
+
b = [("user", "🖼 image", None,
|
|
147
|
+
("data:image/png;base64,QQ==", "data:image/png;base64,Qg=="))]
|
|
148
|
+
d = transcript.render_html(b, META)
|
|
149
|
+
assert d.count('class="chipbtn"') == 1
|
|
150
|
+
assert d.count('src="data:image/png;base64') == 2
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def test_render_markdown_ignores_images():
|
|
154
|
+
b = [("user", "metin", None, ("data:image/png;base64,QUJD",))]
|
|
155
|
+
md = transcript.render_markdown(b, META)
|
|
156
|
+
assert "metin" in md and "base64" not in md
|
|
157
|
+
|
|
158
|
+
|
|
31
159
|
def test_table_fenced_and_escaping():
|
|
32
160
|
md = "|a|b|\n|--|--|\n|1|b|\n\n<script>x</script>\n\n```\nprint(1)\n```\n\nplain **b** `c`"
|
|
33
161
|
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
|