cc-continuity 0.3.30__tar.gz → 0.3.32__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.
Files changed (112) hide show
  1. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/PKG-INFO +1 -1
  2. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/README.md +3 -2
  3. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/__init__.py +1 -1
  4. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/cli.py +142 -0
  5. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/config.py +5 -0
  6. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity.egg-info/PKG-INFO +1 -1
  7. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/pyproject.toml +1 -1
  8. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_cli.py +147 -0
  9. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/LICENSE +0 -0
  10. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/__main__.py +0 -0
  11. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/atomic.py +0 -0
  12. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/blink.py +0 -0
  13. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/blink_watch.py +0 -0
  14. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/bootstrap.py +0 -0
  15. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/checkpoint.py +0 -0
  16. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/daemon_supervisor.py +0 -0
  17. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/doctor.py +0 -0
  18. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/gitsnap.py +0 -0
  19. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/hooks/__init__.py +0 -0
  20. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/hooks/common.py +0 -0
  21. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/hooks/pre_compact.py +0 -0
  22. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/hooks/pre_tool_use.py +0 -0
  23. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/hooks/session_end.py +0 -0
  24. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/hooks/session_start.py +0 -0
  25. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/hooks/stop.py +0 -0
  26. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/hooks/task.py +0 -0
  27. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/hooks/tool_use.py +0 -0
  28. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/hooks/user_prompt.py +0 -0
  29. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/hosting.py +0 -0
  30. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/install.py +0 -0
  31. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/launch.py +0 -0
  32. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/ledger.py +0 -0
  33. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/lock.py +0 -0
  34. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/managed.py +0 -0
  35. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/naming.py +0 -0
  36. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/notify.py +0 -0
  37. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/paths.py +0 -0
  38. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/power_plug.py +0 -0
  39. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/progress_pane.py +0 -0
  40. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/project.py +0 -0
  41. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/redact.py +0 -0
  42. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/rotator.py +0 -0
  43. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/settings_merge.py +0 -0
  44. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/skills.py +0 -0
  45. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/state.py +0 -0
  46. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/statusline.py +0 -0
  47. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/thresholds.py +0 -0
  48. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/transcript.py +0 -0
  49. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/validate.py +0 -0
  50. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/watchdog.py +0 -0
  51. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/watchdog_digest.py +0 -0
  52. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity/watchdogd.py +0 -0
  53. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity.egg-info/SOURCES.txt +0 -0
  54. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity.egg-info/dependency_links.txt +0 -0
  55. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity.egg-info/entry_points.txt +0 -0
  56. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/cc_continuity.egg-info/top_level.txt +0 -0
  57. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/setup.cfg +0 -0
  58. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_atomic.py +0 -0
  59. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_blink.py +0 -0
  60. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_blink_watch.py +0 -0
  61. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_bootstrap.py +0 -0
  62. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_checkpoint.py +0 -0
  63. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_cli_ledger.py +0 -0
  64. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_config.py +0 -0
  65. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_daemon_supervisor.py +0 -0
  66. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_doctor.py +0 -0
  67. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_gitsnap.py +0 -0
  68. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_hooks_common.py +0 -0
  69. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_hooks_pre_compact.py +0 -0
  70. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_hooks_pre_tool_use.py +0 -0
  71. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_hooks_session_end.py +0 -0
  72. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_hooks_session_start.py +0 -0
  73. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_hooks_stop.py +0 -0
  74. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_hooks_task.py +0 -0
  75. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_hooks_tool_use.py +0 -0
  76. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_hooks_user_prompt.py +0 -0
  77. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_hosting.py +0 -0
  78. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_hygiene.py +0 -0
  79. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_install.py +0 -0
  80. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_integration_phase5.py +0 -0
  81. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_integration_phase6.py +0 -0
  82. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_integration_phase7.py +0 -0
  83. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_launch.py +0 -0
  84. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_ledger.py +0 -0
  85. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_lock.py +0 -0
  86. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_managed.py +0 -0
  87. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_naming.py +0 -0
  88. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_notify.py +0 -0
  89. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_notify_integration.py +0 -0
  90. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_paths.py +0 -0
  91. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_power_plug.py +0 -0
  92. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_progress_pane.py +0 -0
  93. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_project.py +0 -0
  94. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_redact.py +0 -0
  95. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_rotator.py +0 -0
  96. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_settings_merge.py +0 -0
  97. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_skills.py +0 -0
  98. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_state.py +0 -0
  99. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_status.py +0 -0
  100. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_statusline.py +0 -0
  101. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_thresholds.py +0 -0
  102. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_tmux_host.py +0 -0
  103. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_transcript.py +0 -0
  104. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_transcript_finalize.py +0 -0
  105. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_uninstall.py +0 -0
  106. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_validate.py +0 -0
  107. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_watchdog.py +0 -0
  108. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_watchdog_digest.py +0 -0
  109. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_watchdog_integration.py +0 -0
  110. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_watchdogd.py +0 -0
  111. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_wsl_doctor.py +0 -0
  112. {cc_continuity-0.3.30 → cc_continuity-0.3.32}/tests/test_wsl_install.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cc-continuity
3
- Version: 0.3.30
3
+ Version: 0.3.32
4
4
  Summary: Zero-touch session rotation for Claude Code (local large-context model)
5
5
  Requires-Python: >=3.11
6
6
  License-File: LICENSE
@@ -26,11 +26,12 @@ 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-14**: Tab-completion for the whole command tree: `cc-continuity completion zsh|bash` prints a completion script generated from the very argparse tree the CLI builds, so a subcommand added upstream shows up on the next Tab for free. Install it with one eval line in `~/.zshrc`: `eval "$(cc-continuity completion zsh)"`; unsupported shells exit 1 with a clear stderr line instead of a half-script ([commit](https://github.com/pqant/claude-continuity/commit/2d7ddfe)).
30
+ - **2026-11-12**: `cc-continuity configure --show` prints the effective config as the code sees it: one sorted `key value` line per setting, defaults filled in where the file omits them, the installer stamp block left out of the noise, and `--json` for scripts. No config file is no longer a dead end: the defaults-only view prints with a one-line note instead of failing, and the command never writes anything ([commit](https://github.com/pqant/claude-continuity/commit/2ae1243)).
29
31
  - **2026-11-12**: A `cc-continuity signal needs-human` fired while the session idles now lights up the animated pane too: in progress mode 1 the animator owns the blink but only consulted the rendered status-line text, the reply flag and the pane capture, never `ledger.blocked_reason`, so the push reached the phone while the tab stayed dark. The animator's ~1 s blink poll now reads the ledger and paints the blocked chip with a reason-carrying gate key, mirroring the reply-flag pattern ([commit](https://github.com/pqant/claude-continuity/commit/055c824)).
30
32
  - **2026-11-12**: The tab blink and the Dock bounce no longer die behind a backgrounded iTerm2: iTerm2 answers the frontmost-session query even while backgrounded, so the focus watcher kept believing the user was still on the tab and, worse, a selection prompt (AskUserQuestion) vanished from the pane region whenever the input box held a draft, so the wait never even armed. The frontmost-tty probe now checks which app is actually in the foreground first (any other app means "no reader present"), and a live selection footer anchors its own region regardless of the draft below it, so prompts gate again and the bounce survives until the wait is answered or read ([commit](https://github.com/pqant/claude-continuity/commit/97c5227)).
31
33
  - **2026-11-12**: The Dock bounce can no longer be swallowed by macOS: a bounce written while the terminal app is frontmost (the system only bounces backgrounded apps) is re-fired the moment iTerm2 goes to the background: the poller and the animator watch the frontmost app on their ~1 s tick and re-write a still-armed bounce exactly once per foreground-to-background transition, never per tick ([commit](https://github.com/pqant/claude-continuity/commit/fe215b4)).
32
- - **2026-11-12**: The Dock bounce now covers the reply-ready blink too: when a turn finishes and its tab is waiting to be read, the iTerm2 Dock icon bounces just like it does for needs-human waits, so a finished turn catches your eye while you work in another app. Set `"blink_reply_attention": false` in `~/.claude-continuity/config.json` to keep turn-ends tab-blink only ([commit](https://github.com/pqant/claude-continuity/commit/3dc9c0d)).
33
- - **2026-11-12**: Needs-human and blocked waits now bounce the iTerm2 Dock icon too, not just the tab: an unconsumed `needs_human` reason (a `signal needs-human` or a watchdog stall), a permission or selection prompt, or the blocked marker arm `RequestAttention=yes` on the client ttys, and the bounce is cancelled with `no` once the wait is answered or the tab has been read (focus dwell); a crashed poller's stranded bounce is healed by the startup sweep ([commit](https://github.com/pqant/claude-continuity/commit/89d55c2)).
34
+
34
35
  ## How it works
35
36
 
36
37
  The whole flow in one picture: the automatic session loop, the optional
@@ -4,4 +4,4 @@ Spec: docs/PRD.md (v1.0). Platform facts verified in docs/VERIFICATION.md.
4
4
  Standard library only at runtime; pytest is dev-only.
5
5
  """
6
6
 
7
- __version__ = "0.3.30"
7
+ __version__ = "0.3.32"
@@ -171,6 +171,10 @@ def build_parser() -> argparse.ArgumentParser:
171
171
  p_cfg.add_argument("--watchdog-enabled", default=None,
172
172
  choices=["true", "false"],
173
173
  help="enable/disable the watchdog daemon")
174
+ p_cfg.add_argument("--show", action="store_true",
175
+ help="print the effective config (read-only) and exit")
176
+ p_cfg.add_argument("--json", action="store_true",
177
+ help="with --show: one JSON object for scripts")
174
178
 
175
179
  p_wd = sub.add_parser("watchdog",
176
180
  help="LLM watchdog daemon (Phase 10)")
@@ -267,6 +271,14 @@ def build_parser() -> argparse.ArgumentParser:
267
271
  "issue #7)")
268
272
  p_ne.add_argument("spec_path")
269
273
 
274
+ p_comp = sub.add_parser("completion",
275
+ help="print a shell completion script (issue #50)")
276
+ p_comp.description = (
277
+ "Print a completion script for bash or zsh to stdout.\n"
278
+ 'Install (zsh): eval "$(cc-continuity completion zsh)" '
279
+ "# add to ~/.zshrc")
280
+ p_comp.add_argument("shell", help="target shell: bash or zsh")
281
+
270
282
  p_launch = sub.add_parser("launch",
271
283
  help="zsh wrapper backend (Appendix D)")
272
284
  p_launch.add_argument("claude_args", nargs=argparse.REMAINDER,
@@ -1182,6 +1194,28 @@ def cmd_configure(args: argparse.Namespace) -> int:
1182
1194
  """P9-D2: post-install config changes — no reinstall needed."""
1183
1195
  from . import atomic, install, paths
1184
1196
  cfg_path = paths.config_path()
1197
+ if args.show:
1198
+ if (args.ntfy is not None or args.unattended
1199
+ or args.watchdog_health is not None
1200
+ or args.watchdog_enabled is not None):
1201
+ print("cc-continuity configure: --show is read-only (cannot "
1202
+ "combine with change flags)", file=sys.stderr)
1203
+ return 1
1204
+ missing = not cfg_path.is_file()
1205
+ # The installer stamp block is noise when asking "what does this
1206
+ # session actually run on?" (issue #49); never written here.
1207
+ shown = {k: v for k, v in config.load_config().items()
1208
+ if k != "install"}
1209
+ if args.json:
1210
+ print(json.dumps(shown, sort_keys=True))
1211
+ else:
1212
+ for key in sorted(shown):
1213
+ val = shown[key]
1214
+ print(key, val if isinstance(val, str) else json.dumps(val))
1215
+ if missing:
1216
+ print("cc-continuity configure: no config file yet (showing "
1217
+ "the built-in defaults)", file=sys.stderr)
1218
+ return 0
1185
1219
  cfg: dict = {}
1186
1220
  if cfg_path.is_file():
1187
1221
  try:
@@ -1233,6 +1267,112 @@ def cmd_configure(args: argparse.Namespace) -> int:
1233
1267
  return 0
1234
1268
 
1235
1269
 
1270
+ # --------------------------------------------------------------- completion
1271
+
1272
+
1273
+ def _completion_clean(text: str) -> str:
1274
+ """One-line, quote-free help text safe to embed in generated scripts."""
1275
+ return " ".join((text or "").split()).replace("'", "")
1276
+
1277
+
1278
+ def _completion_tree(parser: argparse.ArgumentParser) -> dict:
1279
+ """``{name: (help, {sub-name: (help, {})})}`` from the live argparse tree.
1280
+
1281
+ Walks the very parser ``build_parser`` produces (issue #50), so a
1282
+ subcommand added upstream appears in the scripts for free.
1283
+ """
1284
+ tree: dict = {}
1285
+ for action in parser._actions:
1286
+ if not isinstance(action, argparse._SubParsersAction):
1287
+ continue
1288
+ helps = {a.dest: _completion_clean(a.help)
1289
+ for a in action._choices_actions}
1290
+ for name, subparser in action.choices.items():
1291
+ if name.startswith("_"):
1292
+ continue
1293
+ tree[name] = (helps.get(name, ""), _completion_tree(subparser))
1294
+ return tree
1295
+
1296
+
1297
+ def _bash_completion_script(tree: dict) -> str:
1298
+ top = " ".join(sorted(tree))
1299
+ lines = [
1300
+ "# cc-continuity bash completion (generated by `completion bash`)",
1301
+ "_cc_continuity_completions() {",
1302
+ ' local cur="${COMP_WORDS[COMP_CWORD]}"',
1303
+ ' if [ "$COMP_CWORD" -eq 1 ]; then',
1304
+ f' COMPREPLY=( $(compgen -W "{top}" -- "$cur") )',
1305
+ " return 0",
1306
+ " fi",
1307
+ ' case "${COMP_WORDS[1]}" in',
1308
+ ]
1309
+ for name, (_, subs) in sorted(tree.items()):
1310
+ if subs:
1311
+ words = " ".join(sorted(subs))
1312
+ lines += [
1313
+ f" {name})",
1314
+ f' COMPREPLY=( $(compgen -W "{words}" -- "$cur") )',
1315
+ " return 0 ;;",
1316
+ ]
1317
+ lines += [" esac",
1318
+ " COMPREPLY=()",
1319
+ "}",
1320
+ "complete -F _cc_continuity_completions cc-continuity"]
1321
+ return "\n".join(lines) + "\n"
1322
+
1323
+
1324
+ def _zsh_completion_script(tree: dict) -> str:
1325
+ lines = [
1326
+ "#compdef cc-continuity",
1327
+ "# cc-continuity zsh completion (generated by `completion zsh`)",
1328
+ "_cc_continuity_completions() {",
1329
+ " local -a commands",
1330
+ " commands=(",
1331
+ ]
1332
+ for name, (help_text, _) in sorted(tree.items()):
1333
+ lines.append(f" '{name}:{help_text}'")
1334
+ lines += [" )",
1335
+ " if (( CURRENT == 2 )); then",
1336
+ " _describe -t commands 'cc-continuity command' commands",
1337
+ " return 0",
1338
+ " fi",
1339
+ ' case "$words[2]" in']
1340
+ for name, (_, subs) in sorted(tree.items()):
1341
+ if subs:
1342
+ lines.append(f" {name})")
1343
+ lines.append(" local -a subcommands")
1344
+ lines.append(" subcommands=(")
1345
+ for sname, (shelp, _) in sorted(subs.items()):
1346
+ lines.append(f" '{sname}:{shelp}'")
1347
+ lines += [" )",
1348
+ f" _describe -t subcommands '{name} action' "
1349
+ "subcommands",
1350
+ " return 0 ;;"]
1351
+ lines += [" esac",
1352
+ " _files",
1353
+ "}",
1354
+ "compdef _cc_continuity_completions cc-continuity"]
1355
+ return "\n".join(lines) + "\n"
1356
+
1357
+
1358
+ def cmd_completion(args: argparse.Namespace) -> int:
1359
+ """Issue #50: print the completion script for bash or zsh to stdout.
1360
+
1361
+ Pure presentation: generated from the same argparse tree the CLI
1362
+ builds; never touches hooks state, rotation, or any write path.
1363
+ """
1364
+ shell = str(args.shell or "").strip().lower()
1365
+ if shell not in ("bash", "zsh"):
1366
+ print(f"cc-continuity completion: unsupported shell {args.shell!r} "
1367
+ "(supported: bash, zsh)", file=sys.stderr)
1368
+ return 1
1369
+ tree = _completion_tree(build_parser())
1370
+ script = (_zsh_completion_script(tree) if shell == "zsh"
1371
+ else _bash_completion_script(tree))
1372
+ sys.stdout.write(script)
1373
+ return 0
1374
+
1375
+
1236
1376
  def cmd_watchdog(args: argparse.Namespace, home: Path | None = None,
1237
1377
  runner=subprocess.run) -> int:
1238
1378
  """P10-D2: the watchdog CLI — host lifecycle + foreground run.
@@ -1568,6 +1708,8 @@ def main(argv: list[str] | None = None) -> int:
1568
1708
  return cmd_install(args)
1569
1709
  if args.command == "configure":
1570
1710
  return cmd_configure(args)
1711
+ if args.command == "completion":
1712
+ return cmd_completion(args)
1571
1713
  if args.command == "uninstall":
1572
1714
  return cmd_uninstall(args)
1573
1715
  if args.command == "doctor":
@@ -48,6 +48,11 @@ DEFAULTS: dict = {
48
48
  "notify_enabled": False,
49
49
  "unattended": False,
50
50
  "statusline_ansi": True,
51
+ # Per-turn timestamp pane switch (issue #43). Listed here so
52
+ # `configure --show` (issue #49) always reports the effective value;
53
+ # turn_clock() has always treated a missing key as False, so this is
54
+ # value-identical for every existing code path.
55
+ "turn_clock": False,
51
56
  # Progress display (Phase 12): 0 = statusline shimmer (default, today's
52
57
  # look), 1 = separate tmux pane (true 50 ms), 2 = statusline
53
58
  # "breathing". Missing/invalid values degrade to 0 via progress_mode().
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cc-continuity
3
- Version: 0.3.30
3
+ Version: 0.3.32
4
4
  Summary: Zero-touch session rotation for Claude Code (local large-context model)
5
5
  Requires-Python: >=3.11
6
6
  License-File: LICENSE
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "cc-continuity"
7
- version = "0.3.30"
7
+ version = "0.3.32"
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)
@@ -686,6 +686,84 @@ def test_configure_without_flags_is_error(cc_home, capsys):
686
686
  assert "nothing to change" in capsys.readouterr().err
687
687
 
688
688
 
689
+ def _show_lines(capsys):
690
+ """Parse 'key value' lines of configure --show into a dict."""
691
+ return dict(line.split(" ", 1)
692
+ for line in capsys.readouterr().out.splitlines() if line)
693
+
694
+
695
+ def test_configure_show_defaults_only(cc_home, capsys):
696
+ # No config file at all: the view is the pure defaults.
697
+ assert cli.main(["configure", "--show"]) == 0
698
+ lines = _show_lines(capsys)
699
+ assert lines["warn_ratio"] == "0.55"
700
+ assert lines["rotate_ratio"] == "0.62"
701
+ assert lines["window_tokens"] == "262144"
702
+ assert lines["progress_type"] == "0"
703
+ assert lines["turn_clock"] == "false"
704
+
705
+
706
+ def test_configure_show_file_overlay(cc_home, capsys):
707
+ # File values win; keys the file omits still show their defaults;
708
+ # the installer stamp block never appears.
709
+ (cc_home / "config.json").write_text(json.dumps(
710
+ {"turn_clock": True, "progress_type": 1,
711
+ "install": {"version": "9.9.9", "installed_at": "x",
712
+ "settings_backup": "/tmp/y"}}),
713
+ encoding="utf-8")
714
+ assert cli.main(["configure", "--show"]) == 0
715
+ out = capsys.readouterr().out
716
+ lines = dict(line.split(" ", 1)
717
+ for line in out.splitlines() if line)
718
+ assert lines["turn_clock"] == "true"
719
+ assert lines["progress_type"] == "1"
720
+ assert lines["warn_ratio"] == "0.55" # default still filled in
721
+ assert "install" not in lines
722
+ assert "installed_at" not in out
723
+
724
+
725
+ def test_configure_show_json(cc_home, capsys):
726
+ (cc_home / "config.json").write_text(
727
+ json.dumps({"unattended": True, "install": {"version": "9.9.9"}}),
728
+ encoding="utf-8")
729
+ assert cli.main(["configure", "--show", "--json"]) == 0
730
+ data = json.loads(capsys.readouterr().out)
731
+ assert data["unattended"] is True
732
+ assert data["hard_ratio"] == 0.72 # defaulted in
733
+ assert "install" not in data
734
+ assert list(data) == sorted(data) # deterministic key order
735
+
736
+
737
+ def test_configure_show_missing_file_note(cc_home, capsys):
738
+ # Missing config file is not an error: defaults print, rc 0, and a
739
+ # one-line note goes to stderr (stdout stays pure data).
740
+ assert cli.main(["configure", "--show"]) == 0
741
+ cap = capsys.readouterr()
742
+ assert "warn_ratio 0.55" in cap.out
743
+ assert "no config file" in cap.err.lower()
744
+ assert not (cc_home / "config.json").exists()
745
+
746
+
747
+ def test_configure_show_never_writes(cc_home):
748
+ cfg_path = cc_home / "config.json"
749
+ cfg_path.write_text(json.dumps({"turn_clock": True}), encoding="utf-8")
750
+ before_bytes = cfg_path.read_bytes()
751
+ before_ns = cfg_path.stat().st_mtime_ns
752
+ assert cli.main(["configure", "--show"]) == 0
753
+ assert cfg_path.read_bytes() == before_bytes
754
+ assert cfg_path.stat().st_mtime_ns == before_ns
755
+ assert cli.main(["configure", "--show", "--json"]) == 0
756
+ assert cfg_path.read_bytes() == before_bytes
757
+ assert cfg_path.stat().st_mtime_ns == before_ns
758
+
759
+
760
+ def test_configure_show_conflict_with_change_flags(cc_home, capsys):
761
+ assert cli.main(["configure", "--show", "--ntfy",
762
+ "https://ntfy.sh/t"]) == 1
763
+ assert "--show" in capsys.readouterr().err
764
+ assert not (cc_home / "config.json").exists()
765
+
766
+
689
767
  def test_signal_needs_human_pushes_and_records(cc_home, tmp_path, monkeypatch):
690
768
  from cc_continuity import notify
691
769
  repo = make_repo(tmp_path)
@@ -1052,3 +1130,72 @@ def test_notify_claimed_passes_prev_and_handoff(cc_home, tmp_path,
1052
1130
  assert captured["prev"] == "proj-99"
1053
1131
  assert captured["handoff_path"].endswith(
1054
1132
  "sessions/099/checkpoint/handoff.md")
1133
+
1134
+
1135
+ # ------------------------------------------------------- completion (#50)
1136
+
1137
+
1138
+ def _registered_subcommands():
1139
+ """Top-level subcommand names from the live argparse tree."""
1140
+ sub = next(a for a in cli.build_parser()._actions
1141
+ if isinstance(a, argparse._SubParsersAction))
1142
+ return list(sub.choices)
1143
+
1144
+
1145
+ def test_completion_zsh_lists_every_subcommand(capsys):
1146
+ # The zsh script must offer every subcommand the CLI really registers.
1147
+ assert cli.main(["completion", "zsh"]) == 0
1148
+ out = capsys.readouterr().out
1149
+ assert "#compdef cc-continuity" in out
1150
+ for name in _registered_subcommands():
1151
+ assert name in out
1152
+
1153
+
1154
+ def test_completion_bash_lists_every_subcommand(capsys):
1155
+ assert cli.main(["completion", "bash"]) == 0
1156
+ out = capsys.readouterr().out
1157
+ assert "complete -F" in out
1158
+ for name in _registered_subcommands():
1159
+ assert name in out
1160
+
1161
+
1162
+ def test_completion_unknown_shell_exits_1(capsys):
1163
+ # Clear stderr line naming the bad shell and the supported ones; no
1164
+ # partial script on stdout; rc 1 (not argparse's rc 2).
1165
+ assert cli.main(["completion", "fish"]) == 1
1166
+ cap = capsys.readouterr()
1167
+ assert cap.out == ""
1168
+ assert "fish" in cap.err
1169
+ assert "bash" in cap.err and "zsh" in cap.err
1170
+
1171
+
1172
+ def test_completion_scripts_are_deterministic(capsys):
1173
+ # Same tree -> byte-identical script every run (no set/dict iteration
1174
+ # order leaking into the output).
1175
+ assert cli.main(["completion", "bash"]) == 0
1176
+ first = capsys.readouterr().out
1177
+ assert cli.main(["completion", "bash"]) == 0
1178
+ assert capsys.readouterr().out == first
1179
+ assert cli.main(["completion", "zsh"]) == 0
1180
+ zfirst = capsys.readouterr().out
1181
+ assert cli.main(["completion", "zsh"]) == 0
1182
+ assert capsys.readouterr().out == zfirst
1183
+
1184
+
1185
+ def test_completion_scripts_match_parse_args(capsys):
1186
+ # Generated from the same argparse tree the CLI builds: the level-1
1187
+ # token list in the bash script must equal the parser's real commands,
1188
+ # and each must parse without "invalid choice" (a rename in the tree
1189
+ # that a hardcoded script missed fails here).
1190
+ import re
1191
+ assert cli.main(["completion", "bash"]) == 0
1192
+ out = capsys.readouterr().out
1193
+ tokens = re.findall(r'compgen -W "([^"]*)"', out)[0].split()
1194
+ assert set(tokens) == set(_registered_subcommands())
1195
+ parser = cli.build_parser()
1196
+ for token in tokens:
1197
+ try:
1198
+ parser.parse_args([token])
1199
+ except SystemExit:
1200
+ err = capsys.readouterr().err
1201
+ assert "invalid choice" not in err
File without changes
File without changes