cc-continuity 0.3.42__tar.gz → 0.3.44__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.42 → cc_continuity-0.3.44}/PKG-INFO +1 -1
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/README.md +2 -2
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/__init__.py +1 -1
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/cli.py +85 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/transcript.py +10 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity.egg-info/PKG-INFO +1 -1
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity.egg-info/SOURCES.txt +1 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/pyproject.toml +1 -1
- cc_continuity-0.3.44/tests/test_cli_log.py +92 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_transcript.py +66 -6
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/LICENSE +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/__main__.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/atomic.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/blink.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/blink_watch.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/bootstrap.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/checkpoint.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/config.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/daemon_supervisor.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/doctor.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/gitsnap.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/hooks/__init__.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/hooks/common.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/hooks/pre_compact.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/hooks/pre_tool_use.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/hooks/session_end.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/hooks/session_start.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/hooks/stop.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/hooks/task.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/hooks/tool_use.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/hooks/user_prompt.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/hosting.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/install.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/launch.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/ledger.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/lock.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/managed.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/naming.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/notify.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/paths.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/power_plug.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/progress_pane.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/project.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/redact.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/rotator.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/settings_merge.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/skills.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/state.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/statusline.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/thresholds.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/validate.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/watchdog.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/watchdog_digest.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity/watchdogd.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity.egg-info/dependency_links.txt +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity.egg-info/entry_points.txt +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/cc_continuity.egg-info/top_level.txt +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/setup.cfg +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_atomic.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_blink.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_blink_watch.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_bootstrap.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_changelog_notes.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_checkpoint.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_cli.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_cli_ledger.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_config.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_daemon_supervisor.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_doctor.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_gitsnap.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_hooks_common.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_hooks_pre_compact.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_hooks_pre_tool_use.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_hooks_session_end.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_hooks_session_start.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_hooks_stop.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_hooks_task.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_hooks_tool_use.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_hooks_user_prompt.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_hosting.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_hygiene.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_install.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_integration_phase5.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_integration_phase6.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_integration_phase7.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_launch.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_ledger.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_lock.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_managed.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_naming.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_notify.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_notify_integration.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_paths.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_power_plug.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_progress_pane.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_project.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_redact.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_rotator.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_settings_merge.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_skills.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_state.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_status.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_statusline.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_thresholds.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_tmux_host.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_transcript_finalize.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_uninstall.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_validate.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_watchdog.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_watchdog_digest.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_watchdog_integration.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_watchdogd.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/tests/test_wsl_doctor.py +0 -0
- {cc_continuity-0.3.42 → cc_continuity-0.3.44}/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-
|
|
29
|
+
- **2026-11-17**: Pasted images stopped cloning themselves in transcript exports. Claude Code writes one paste as two records: the base64 record plus an isMeta sibling carrying the same `[Image: source: ...]` lines. While the image cache was still on disk the sibling embedded the very same images, so the export opened a second User block repeating the whole gallery right next to the first. A sibling whose timestamp and image count both match the block before it is the same paste and is now folded away; a genuine second paste carries its own timestamp and still gets its own gallery ([commit](https://github.com/pqant/claude-continuity/commit/55b1c1c)).
|
|
30
|
+
- **2026-11-17**: Debugging the logs got a front door: `cc-continuity log blink` and `cc-continuity log errors` tail the root log files read-only (newest last, default 20 lines, `--lines N`, `--follow` keeps streaming), with UTC stamps rendered in your local time; blink's already-local stamps and traceback continuation lines stay byte-identical so nothing shifts twice ([commit](https://github.com/pqant/claude-continuity/commit/1ce3269)).
|
|
30
31
|
- **2026-11-17**: Zombie panes are measured now too. After the 0.3.40 revival, Claude Code still rendered the status line with the abandoned startup session id, so the ratio metric kept landing on the dead id: the pane showed a ratio while the tracked session never moved (measurement without reaction). The hook entry now stamps a pane-scoped binding with the session id it actually runs as, and the status line writes its metric under it whenever that binding is fresh and names a different live session. Non-tmux runs and normal panes behave byte-for-byte exactly as before ([commit](https://github.com/pqant/claude-continuity/commit/361b7b1)).
|
|
31
32
|
- **2026-11-16**: Zombie sessions are gone. Claude Code remembers the last conversation it opened per project (lastSessionId); a plain `claude` could reopen a conversation that died in a rotation and then run forever unmonitored (no ratio movement, no rotation, and the handoff chain silently broken). Now a resumed conversation whose session id is no longer alive is anchored onto the open chain tip under the same index, handed the bootstrap protocol, and taken over by the normal monitoring; live resumes behave exactly as before ([commit](https://github.com/pqant/claude-continuity/commit/dbaea33)).
|
|
32
33
|
- **2026-11-16**: The transcript fold arrows are anchored: both triangles now share one slot at the true screen center of the header (the previous version centered against the controls row, which spans only the left half of the header grid, so the arrow sat off-center over the theme button), they carry a red tint (a deeper red in light theme, a lighter red in dark theme), and folding keeps the reopen arrow in the very same spot so the button never jumps ([commit](https://github.com/pqant/claude-continuity/commit/1ca6ad5), [commit](https://github.com/pqant/claude-continuity/commit/e33874d)).
|
|
33
|
-
- **2026-11-16**: The transcript density view got its polish pass: the two panel toggles are plain filled triangles now (the up-triangle folds the header panel into the slim bar, the down-triangle brings it back, and the words live in the tooltips), the fold eases closed over 180 ms instead of snapping, and the folded bar only spans the left column when the 2-column mode is on, with the fold arrow sitting centered in the controls row in the theme's accent color. The "2-column · 75%" mode opens enabled by default now; unchecking it is still remembered in your browser ([commit](https://github.com/pqant/claude-continuity/commit/3959db9), [commit](https://github.com/pqant/claude-continuity/commit/7feba54)).
|
|
34
34
|
|
|
35
35
|
## How it works
|
|
36
36
|
|
|
@@ -14,9 +14,11 @@ import argparse
|
|
|
14
14
|
import hashlib
|
|
15
15
|
import json
|
|
16
16
|
import os
|
|
17
|
+
import re
|
|
17
18
|
import subprocess
|
|
18
19
|
import sys
|
|
19
20
|
import time
|
|
21
|
+
from datetime import datetime
|
|
20
22
|
from pathlib import Path
|
|
21
23
|
from typing import Callable
|
|
22
24
|
|
|
@@ -79,6 +81,15 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
79
81
|
p_ledger.add_argument("n", nargs="?", type=int, default=20,
|
|
80
82
|
help="how many newest entries (default 20)")
|
|
81
83
|
|
|
84
|
+
p_log = sub.add_parser("log",
|
|
85
|
+
help="tail a root log file with local-time "
|
|
86
|
+
"stamps (issue #35)")
|
|
87
|
+
p_log.add_argument("kind", choices=["blink", "errors"])
|
|
88
|
+
p_log.add_argument("--lines", type=int, default=20,
|
|
89
|
+
help="how many newest lines (default 20)")
|
|
90
|
+
p_log.add_argument("--follow", action="store_true",
|
|
91
|
+
help="keep streaming appended lines")
|
|
92
|
+
|
|
82
93
|
p_vd = sub.add_parser("validate-draft",
|
|
83
94
|
help="validate a handoff draft (PRD §10.1)")
|
|
84
95
|
p_vd.add_argument("file", help="path to handoff.draft.md")
|
|
@@ -750,6 +761,78 @@ def cmd_ledger(args: argparse.Namespace) -> int:
|
|
|
750
761
|
return 0
|
|
751
762
|
|
|
752
763
|
|
|
764
|
+
_LOG_STAMP = re.compile(
|
|
765
|
+
r"^(?P<open>\[?)(?P<iso>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?)"
|
|
766
|
+
r"(?P<offset>Z|[+-]\d{2}:\d{2})(?P<close>\]?)")
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
def render_log_line(line, tz=None):
|
|
770
|
+
"""Rewrite an offset-bearing leading stamp into local time (issue #35).
|
|
771
|
+
|
|
772
|
+
errors.log stamps carry ``+00:00`` (UTC) and get converted; blink.log
|
|
773
|
+
stamps are naive local ``time.strftime`` output and MUST pass through
|
|
774
|
+
byte-identical (converting a naive stamp would double-shift it), and
|
|
775
|
+
so do untimestamped traceback continuation lines.
|
|
776
|
+
"""
|
|
777
|
+
match = _LOG_STAMP.match(line)
|
|
778
|
+
if not match:
|
|
779
|
+
return line
|
|
780
|
+
offset = "+00:00" if match.group("offset") == "Z" else match.group("offset")
|
|
781
|
+
try:
|
|
782
|
+
stamp = datetime.fromisoformat(match.group("iso") + offset)
|
|
783
|
+
except ValueError:
|
|
784
|
+
return line
|
|
785
|
+
local = stamp.astimezone(tz)
|
|
786
|
+
return (f"{match.group('open')}{local.isoformat()}{match.group('close')}"
|
|
787
|
+
+ line[match.end():])
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
def follow_lines(path, offset, poll=0.5, max_lines=None):
|
|
791
|
+
"""Yield whole lines appended to ``path`` after ``offset`` (issue #35).
|
|
792
|
+
|
|
793
|
+
``tail -f`` semantics for ``log --follow``: polls for growth, yields
|
|
794
|
+
only newline-terminated lines (a torn partial write is kept in the
|
|
795
|
+
buffer until complete), and tolerates a missing file by waiting for
|
|
796
|
+
it to appear. ``max_lines`` bounds the stream (tests).
|
|
797
|
+
"""
|
|
798
|
+
emitted = 0
|
|
799
|
+
buf = b""
|
|
800
|
+
while max_lines is None or emitted < max_lines:
|
|
801
|
+
chunk = b""
|
|
802
|
+
try:
|
|
803
|
+
with open(path, "rb") as fh:
|
|
804
|
+
fh.seek(offset)
|
|
805
|
+
chunk = fh.read()
|
|
806
|
+
except OSError:
|
|
807
|
+
pass
|
|
808
|
+
if chunk:
|
|
809
|
+
offset += len(chunk)
|
|
810
|
+
*complete, buf = (buf + chunk).split(b"\n")
|
|
811
|
+
for raw in complete:
|
|
812
|
+
yield raw.decode("utf-8", "replace")
|
|
813
|
+
emitted += 1
|
|
814
|
+
if max_lines is not None and emitted >= max_lines:
|
|
815
|
+
return
|
|
816
|
+
time.sleep(poll)
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
def cmd_log(args: argparse.Namespace) -> int:
|
|
820
|
+
"""Read-only tail of the root ``logs/`` files (issue #35).
|
|
821
|
+
|
|
822
|
+
``blink``/``errors`` are global (not per-session); stamps render in
|
|
823
|
+
local time, newest last. A missing file is an empty success.
|
|
824
|
+
"""
|
|
825
|
+
path = paths.logs_dir() / f"{args.kind}.log"
|
|
826
|
+
n = args.lines if isinstance(args.lines, int) and args.lines > 0 else 20
|
|
827
|
+
data = path.read_bytes() if path.is_file() else b""
|
|
828
|
+
for line in data.decode("utf-8", "replace").splitlines()[-n:]:
|
|
829
|
+
print(render_log_line(line))
|
|
830
|
+
if args.follow:
|
|
831
|
+
for line in follow_lines(path, len(data)):
|
|
832
|
+
print(render_log_line(line), flush=True)
|
|
833
|
+
return 0
|
|
834
|
+
|
|
835
|
+
|
|
753
836
|
# ----------------------------------------------------------- Phase 4 cmds
|
|
754
837
|
|
|
755
838
|
|
|
@@ -1678,6 +1761,8 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
1678
1761
|
return cmd_ratio(args)
|
|
1679
1762
|
if args.command == "ledger":
|
|
1680
1763
|
return cmd_ledger(args)
|
|
1764
|
+
if args.command == "log":
|
|
1765
|
+
return cmd_log(args)
|
|
1681
1766
|
if args.command == "validate-draft":
|
|
1682
1767
|
return cmd_validate_draft(args)
|
|
1683
1768
|
if args.command == "validate":
|
|
@@ -279,6 +279,16 @@ def parse_conversation(lines: list[str]) -> list[Block]:
|
|
|
279
279
|
# next to the live gallery is worse than folding it in
|
|
280
280
|
# (issue #59).
|
|
281
281
|
continue
|
|
282
|
+
rec_ts = rec.get("timestamp")
|
|
283
|
+
if (imgs and out and out[-1].images
|
|
284
|
+
and isinstance(rec_ts, str)
|
|
285
|
+
and out[-1].ts == rec_ts
|
|
286
|
+
and len(out[-1].images) == len(imgs)):
|
|
287
|
+
# While the image cache is on disk, CC's isMeta sibling of
|
|
288
|
+
# a paste embeds the very same images the base64 record
|
|
289
|
+
# already showed. Same timestamp plus equal image count
|
|
290
|
+
# marks the same paste, not a second one (issue #72).
|
|
291
|
+
continue
|
|
282
292
|
text = _IMAGE_CHIP
|
|
283
293
|
if out and out[-1].text == _IMAGE_CHIP:
|
|
284
294
|
# Fold the run: merge the galleries into one chip.
|
|
@@ -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.44"
|
|
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)
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"""cli `log [blink|errors]` (issue #35): read-only tail, UTC stamps in local time.
|
|
2
|
+
|
|
3
|
+
errors.log carries explicit-offset UTC stamps (``[ISO+00:00]``); blink.log
|
|
4
|
+
stamps are naive LOCAL (``time.strftime``). Only offset-bearing stamps get
|
|
5
|
+
converted - converting naive ones would double-shift; untimestamped lines
|
|
6
|
+
(tracebacks) pass through untouched. Newest last, default tail 20,
|
|
7
|
+
``--follow`` streams appended lines. No session or rotation-state
|
|
8
|
+
dependency: the logs live at the root ``logs/`` dir.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from datetime import timedelta, timezone
|
|
12
|
+
|
|
13
|
+
import pytest
|
|
14
|
+
|
|
15
|
+
from cc_continuity import cli, paths
|
|
16
|
+
|
|
17
|
+
TZ = timezone(timedelta(hours=1))
|
|
18
|
+
|
|
19
|
+
UTC_STAMPED = "[2026-11-17T07:28:07.123456+00:00] notify: push failed: 403"
|
|
20
|
+
NAIVE = "2026-11-17T11:51:06 focus suppress-stored @0 key='(False, False)'"
|
|
21
|
+
TRACEBACK = ' File "cc_continuity/hooks/common.py", line 58, in log_error'
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _write_log(name, lines):
|
|
25
|
+
d = paths.logs_dir()
|
|
26
|
+
d.mkdir(parents=True, exist_ok=True)
|
|
27
|
+
(d / name).write_text("".join(line + "\n" for line in lines),
|
|
28
|
+
encoding="utf-8")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _plain(count):
|
|
32
|
+
return [f"evt {i}" for i in range(1, count + 1)]
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
# ------------------------------------------------------------- renderer
|
|
36
|
+
|
|
37
|
+
def test_render_converts_offset_stamps_only():
|
|
38
|
+
out = cli.render_log_line(UTC_STAMPED, tz=TZ)
|
|
39
|
+
assert out == "[2026-11-17T08:28:07.123456+01:00] notify: push failed: 403"
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def test_render_keeps_naive_local_stamps_untouched():
|
|
43
|
+
assert cli.render_log_line(NAIVE, tz=TZ) == NAIVE
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def test_render_passes_untimestamped_lines():
|
|
47
|
+
assert cli.render_log_line(TRACEBACK, tz=TZ) == TRACEBACK
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def test_render_accepts_zulu_without_brackets():
|
|
51
|
+
out = cli.render_log_line("2026-11-17T07:28:07Z heartbeat ok", tz=TZ)
|
|
52
|
+
assert out.startswith("2026-11-17T08:28:07+01:00")
|
|
53
|
+
assert out.endswith("heartbeat ok")
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
# ------------------------------------------------------------------ tail
|
|
57
|
+
|
|
58
|
+
def test_log_errors_tails_newest_last(cc_home, capsys):
|
|
59
|
+
_write_log("errors.log", _plain(25))
|
|
60
|
+
assert cli.main(["log", "errors", "--lines", "5"]) == 0
|
|
61
|
+
assert capsys.readouterr().out.splitlines() == _plain(25)[-5:]
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def test_log_defaults_to_twenty_and_nonpositive_falls_back(cc_home, capsys):
|
|
65
|
+
_write_log("blink.log", _plain(25))
|
|
66
|
+
assert cli.main(["log", "blink"]) == 0
|
|
67
|
+
assert capsys.readouterr().out.splitlines() == _plain(25)[-20:]
|
|
68
|
+
assert cli.main(["log", "blink", "--lines", "0"]) == 0
|
|
69
|
+
assert capsys.readouterr().out.splitlines() == _plain(25)[-20:]
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def test_log_missing_file_is_empty_success(cc_home, capsys):
|
|
73
|
+
assert cli.main(["log", "errors"]) == 0
|
|
74
|
+
assert capsys.readouterr().out == ""
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def test_log_unknown_kind_is_rejected(cc_home):
|
|
78
|
+
with pytest.raises(SystemExit) as exc:
|
|
79
|
+
cli.main(["log", "rotator"])
|
|
80
|
+
assert exc.value.code == 2
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# ---------------------------------------------------------------- follow
|
|
84
|
+
|
|
85
|
+
def test_follow_emits_appended_lines(cc_home):
|
|
86
|
+
_write_log("blink.log", _plain(3))
|
|
87
|
+
path = paths.logs_dir() / "blink.log"
|
|
88
|
+
offset = len(path.read_bytes())
|
|
89
|
+
with open(path, "a", encoding="utf-8") as fh:
|
|
90
|
+
fh.write("evt 4\nevt 5\n")
|
|
91
|
+
emitted = list(cli.follow_lines(path, offset, poll=0.01, max_lines=2))
|
|
92
|
+
assert emitted == ["evt 4", "evt 5"]
|
|
@@ -105,11 +105,14 @@ def test_mixed_text_and_image_appends_chip():
|
|
|
105
105
|
|
|
106
106
|
|
|
107
107
|
def test_folded_chips_merge_galleries():
|
|
108
|
+
# Two GENUINE back-to-back pastes (distinct timestamps, issue #72
|
|
109
|
+
# realism) merge their galleries; an identical-timestamp pair would be
|
|
110
|
+
# one paste's echo and folds instead.
|
|
108
111
|
blocks = transcript.parse_conversation([
|
|
109
112
|
_rec("user", [{"type": "text", "text": "[Image: source: /a]"},
|
|
110
|
-
_img(data="QQ==")]),
|
|
113
|
+
_img(data="QQ==")], ts="2026-11-17T10:00:01.100Z"),
|
|
111
114
|
_rec("user", [{"type": "text", "text": "[Image: original 10x10]"},
|
|
112
|
-
_img(data="Qg==")])])
|
|
115
|
+
_img(data="Qg==")], ts="2026-11-17T10:00:09.200Z")])
|
|
113
116
|
assert [t for _, t, _, _ in blocks] == ["🖼 image"]
|
|
114
117
|
assert list(blocks[0][3]) == ["data:image/png;base64,QQ==",
|
|
115
118
|
"data:image/png;base64,Qg=="]
|
|
@@ -306,16 +309,73 @@ def test_empty_image_record_folds_into_preceding_gallery(tmp_path):
|
|
|
306
309
|
assert list(blocks[0][3]) == ["data:image/png;base64,QUJD"]
|
|
307
310
|
|
|
308
311
|
|
|
309
|
-
def
|
|
312
|
+
def test_recoverable_sibling_of_same_paste_folds(tmp_path):
|
|
313
|
+
# Issue #72: the sibling is CC's echo of the SAME paste - connector-255
|
|
314
|
+
# proved both records carry the identical timestamp string. While the
|
|
315
|
+
# image cache is still on disk the sibling embeds the same images and
|
|
316
|
+
# every thumbnail rendered twice in a second User block; the echo must
|
|
317
|
+
# fold just like the pruned sibling does.
|
|
310
318
|
png = _png(tmp_path)
|
|
311
319
|
blocks = transcript.parse_conversation([
|
|
312
|
-
_rec("user", [{"type": "text", "text": "metin oncesi"}, _img(data="QQ==")]
|
|
313
|
-
|
|
314
|
-
|
|
320
|
+
_rec("user", [{"type": "text", "text": "metin oncesi"}, _img(data="QQ==")],
|
|
321
|
+
ts="2026-11-17T10:49:03.973Z"),
|
|
322
|
+
_rec("user", f"[Image: source: {png}]",
|
|
323
|
+
ts="2026-11-17T10:49:03.973Z")])
|
|
324
|
+
assert [(r, t) for r, t, _, _ in blocks] == [("user", "metin oncesi")]
|
|
315
325
|
assert list(blocks[0][3]) == ["data:image/png;base64,QQ=="]
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
def test_sibling_with_different_timestamp_keeps_its_own_chip(tmp_path):
|
|
329
|
+
# A genuine second paste carries a later timestamp: even with the same
|
|
330
|
+
# image count it is NOT an echo and keeps its own chip.
|
|
331
|
+
png = _png(tmp_path)
|
|
332
|
+
blocks = transcript.parse_conversation([
|
|
333
|
+
_rec("user", [{"type": "text", "text": "first paste"}, _img(data="QQ==")],
|
|
334
|
+
ts="2026-11-17T10:49:03.973Z"),
|
|
335
|
+
_rec("user", f"[Image: source: {png}]",
|
|
336
|
+
ts="2026-11-17T10:49:41.120Z")])
|
|
337
|
+
assert [t for _, t, _, _ in blocks] == ["first paste", "🖼 image"]
|
|
338
|
+
assert list(blocks[1][3]) == [f"data:image/png;base64,{PNG1x1}"]
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
def test_same_timestamp_different_count_keeps_its_own_chip(tmp_path):
|
|
342
|
+
# Count guard: an adjacent recoverable chip with a DIFFERENT image
|
|
343
|
+
# count is not the echo of the gallery next to it, even at the same
|
|
344
|
+
# timestamp; it survives as its own chip.
|
|
345
|
+
png = _png(tmp_path)
|
|
346
|
+
blocks = transcript.parse_conversation([
|
|
347
|
+
_rec("user", [{"type": "text", "text": "two images here"},
|
|
348
|
+
_img(data="QQ=="), _img(data="Qg==")],
|
|
349
|
+
ts="2026-11-17T10:49:03.973Z"),
|
|
350
|
+
_rec("user", f"[Image: source: {png}]",
|
|
351
|
+
ts="2026-11-17T10:49:03.973Z")])
|
|
352
|
+
assert [t for _, t, _, _ in blocks] == ["two images here", "🖼 image"]
|
|
316
353
|
assert list(blocks[1][3]) == [f"data:image/png;base64,{PNG1x1}"]
|
|
317
354
|
|
|
318
355
|
|
|
356
|
+
def test_mixed_text_base64_record_folds_sibling_echo(tmp_path):
|
|
357
|
+
# connector-255 reproduction: text + 3 base64 images, then the isMeta
|
|
358
|
+
# sibling (identical timestamp) repeating the same three images as
|
|
359
|
+
# [Image: source:] lines while the cache exists. One User block,
|
|
360
|
+
# original gallery intact, no duplicate thumbnails.
|
|
361
|
+
a = _png(tmp_path, "a.png")
|
|
362
|
+
b = _png(tmp_path, "b.png")
|
|
363
|
+
c = _png(tmp_path, "c.png")
|
|
364
|
+
ts = "2026-11-17T10:49:03.973Z"
|
|
365
|
+
blocks = transcript.parse_conversation([
|
|
366
|
+
_rec("user", [{"type": "text", "text": "[Image #6] fix the readme now"},
|
|
367
|
+
_img(data="QQ=="), _img(data="Qg=="), _img(data="Qw==")],
|
|
368
|
+
ts=ts),
|
|
369
|
+
_rec("user", f"[Image: source: {a}]\n[Image: source: {b}]\n"
|
|
370
|
+
f"[Image: source: {c}]", ts=ts)])
|
|
371
|
+
assert [(r, t) for r, t, _, _ in blocks] == [
|
|
372
|
+
("user", "[Image #6] fix the readme now")]
|
|
373
|
+
assert list(blocks[0][3]) == [
|
|
374
|
+
"data:image/png;base64,QQ==",
|
|
375
|
+
"data:image/png;base64,Qg==",
|
|
376
|
+
"data:image/png;base64,Qw=="]
|
|
377
|
+
|
|
378
|
+
|
|
319
379
|
def test_dead_chip_survives_when_no_gallery_to_fold_into():
|
|
320
380
|
# Without an adjacent gallery the plain chip is the only trace of the
|
|
321
381
|
# unrecoverable paste; it must not disappear.
|
|
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
|