codigest 0.12.1__tar.gz → 0.12.2__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 (47) hide show
  1. {codigest-0.12.1 → codigest-0.12.2}/PKG-INFO +7 -3
  2. {codigest-0.12.1 → codigest-0.12.2}/README.md +6 -2
  3. {codigest-0.12.1 → codigest-0.12.2}/pyproject.toml +1 -1
  4. {codigest-0.12.1 → codigest-0.12.2}/pyproject.toml.orig +1 -1
  5. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/core/output.py +34 -0
  6. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/core/runner.py +2 -1
  7. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/shell/hook.ps1 +6 -0
  8. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/__init__.py +0 -0
  9. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/__main__.py +0 -0
  10. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/commands/cap.py +0 -0
  11. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/commands/clean.py +0 -0
  12. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/commands/diff.py +0 -0
  13. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/commands/digest.py +0 -0
  14. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/commands/init.py +0 -0
  15. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/commands/mark.py +0 -0
  16. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/commands/mcp.py +0 -0
  17. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/commands/pack.py +0 -0
  18. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/commands/scan.py +0 -0
  19. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/commands/semdiff.py +0 -0
  20. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/commands/shell_help.py +0 -0
  21. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/commands/status.py +0 -0
  22. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/commands/term.py +0 -0
  23. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/commands/tree.py +0 -0
  24. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/config.py +0 -0
  25. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/core/cache.py +0 -0
  26. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/core/callees.py +0 -0
  27. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/core/common.py +0 -0
  28. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/core/formats.py +0 -0
  29. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/core/git_ops.py +0 -0
  30. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/core/outline.py +0 -0
  31. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/core/presets.py +0 -0
  32. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/core/processor.py +0 -0
  33. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/core/prompts.py +0 -0
  34. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/core/redact.py +0 -0
  35. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/core/resolver.py +0 -0
  36. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/core/scanner.py +0 -0
  37. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/core/semdiff.py +0 -0
  38. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/core/shadow.py +0 -0
  39. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/core/shellhist.py +0 -0
  40. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/core/structure.py +0 -0
  41. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/core/tags.py +0 -0
  42. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/core/termstore.py +0 -0
  43. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/core/tokenizer.py +0 -0
  44. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/main.py +0 -0
  45. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/options.py +0 -0
  46. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/shell/help.ps1 +0 -0
  47. {codigest-0.12.1 → codigest-0.12.2}/src/codigest/shell/hook.sh +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: codigest
3
- Version: 0.12.1
3
+ Version: 0.12.2
4
4
  Summary: Human-Centered Codebase Context Manager for LLMs
5
5
  Author: Isaac Yong
6
6
  Author-email: Isaac Yong <isaacyong@naver.com>
@@ -96,8 +96,11 @@ This installs `cdg` to `%LOCALAPPDATA%\Programs\codigest` (added to your user `P
96
96
  `~/.local/bin` on Linux and macOS, and `$PREFIX/bin` in Termux. Run the same line again to update.
97
97
  `CDG_VERSION=0.12.1` pins a version and `CDG_INSTALL_DIR=...` picks the folder (then `PATH` is left
98
98
  alone). Supported: Windows x64, Linux x64 and ARM64, macOS Intel and Apple Silicon, Android ARM64
99
- (Termux). Archives for download by hand are on the
99
+ (Termux; the tests also run inside Termux in CI). Archives for download by hand are on the
100
100
  [releases page](https://github.com/NaNIsaac/codigest/releases). No setup is needed in your projects.
101
+ Both scripts check the archive against the SHA-256 GitHub records for it. On Linux and macOS,
102
+ `install.sh` will not replace a `cdg` from the Python package in the same folder unless
103
+ `CDG_FORCE=1` is set.
101
104
 
102
105
  ### Python package
103
106
 
@@ -136,7 +139,8 @@ In a terminal, every command below copies its result to the clipboard. Add `-s`
136
139
  `-o FILE` to also write it to a file, `--no-copy` to leave the clipboard alone, and `-m "..."` to
137
140
  put your question or instruction in it. When the output goes to a pipe or a file instead
138
141
  (`cdg scan > ctx.xml`, `cdg digest | less`, a script, a coding agent's shell), it is printed and
139
- the clipboard is left alone; add `--copy` to copy it anyway.
142
+ the clipboard is left alone; add `--copy` to copy it anyway. Over SSH the copy goes to the clipboard of the machine you
143
+ type on (OSC 52), not the remote one; see [output options](https://nanisaac.github.io/codigest/commands#output-options).
140
144
 
141
145
  ## 1. Share your project with an AI chat
142
146
 
@@ -70,8 +70,11 @@ This installs `cdg` to `%LOCALAPPDATA%\Programs\codigest` (added to your user `P
70
70
  `~/.local/bin` on Linux and macOS, and `$PREFIX/bin` in Termux. Run the same line again to update.
71
71
  `CDG_VERSION=0.12.1` pins a version and `CDG_INSTALL_DIR=...` picks the folder (then `PATH` is left
72
72
  alone). Supported: Windows x64, Linux x64 and ARM64, macOS Intel and Apple Silicon, Android ARM64
73
- (Termux). Archives for download by hand are on the
73
+ (Termux; the tests also run inside Termux in CI). Archives for download by hand are on the
74
74
  [releases page](https://github.com/NaNIsaac/codigest/releases). No setup is needed in your projects.
75
+ Both scripts check the archive against the SHA-256 GitHub records for it. On Linux and macOS,
76
+ `install.sh` will not replace a `cdg` from the Python package in the same folder unless
77
+ `CDG_FORCE=1` is set.
75
78
 
76
79
  ### Python package
77
80
 
@@ -110,7 +113,8 @@ In a terminal, every command below copies its result to the clipboard. Add `-s`
110
113
  `-o FILE` to also write it to a file, `--no-copy` to leave the clipboard alone, and `-m "..."` to
111
114
  put your question or instruction in it. When the output goes to a pipe or a file instead
112
115
  (`cdg scan > ctx.xml`, `cdg digest | less`, a script, a coding agent's shell), it is printed and
113
- the clipboard is left alone; add `--copy` to copy it anyway.
116
+ the clipboard is left alone; add `--copy` to copy it anyway. Over SSH the copy goes to the clipboard of the machine you
117
+ type on (OSC 52), not the remote one; see [output options](https://nanisaac.github.io/codigest/commands#output-options).
114
118
 
115
119
  ## 1. Share your project with an AI chat
116
120
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "codigest"
3
- version = "0.12.1"
3
+ version = "0.12.2"
4
4
  description = "Human-Centered Codebase Context Manager for LLMs"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.15.0b1"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "codigest"
3
- version = "0.12.1"
3
+ version = "0.12.2"
4
4
  description = "Human-Centered Codebase Context Manager for LLMs"
5
5
  authors = [{ name = "Isaac Yong", email = "isaacyong@naver.com" }]
6
6
  readme = "README.md"
@@ -2,7 +2,9 @@
2
2
  Unified Output Handler for CLI commands.
3
3
  Manages stderr log console, clipboard copying, and file vs stdout output.
4
4
  """
5
+ import base64
5
6
  import contextlib
7
+ import os
6
8
  import sys
7
9
  from collections.abc import Callable, Iterator
8
10
  from dataclasses import dataclass
@@ -29,6 +31,29 @@ def spinner(log: Console, text: str) -> Iterator[None]:
29
31
  progress.add_task(text, total=None)
30
32
  yield
31
33
 
34
+
35
+ def use_osc52() -> bool:
36
+ """Over SSH the system clipboard is the remote machine's, not the one of the person typing.
37
+ `CODIGEST_CLIPBOARD=osc52` or `=system` overrides the guess."""
38
+ match os.environ.get("CODIGEST_CLIPBOARD"):
39
+ case "osc52":
40
+ return True
41
+ case "system":
42
+ return False
43
+ return any(name in os.environ for name in ("SSH_CONNECTION", "SSH_CLIENT", "SSH_TTY"))
44
+
45
+
46
+ def osc52(text: str) -> str:
47
+ """The sequence that asks the terminal to put `text` on its own clipboard."""
48
+ return f"\x1b]52;c;{base64.b64encode(text.encode()).decode()}\x07"
49
+
50
+
51
+ def send_osc52(text: str) -> None:
52
+ # Written to the terminal itself, so it arrives even when stdout is a pipe.
53
+ with open("CONOUT$" if os.name == "nt" else "/dev/tty", "w", encoding="ascii") as tty:
54
+ tty.write(osc52(text))
55
+
56
+
32
57
  @dataclass(slots=True)
33
58
  class OutputHandler:
34
59
  stdout: bool = False
@@ -58,6 +83,15 @@ class OutputHandler:
58
83
  """Copies content to clipboard safely."""
59
84
  if not self.copy:
60
85
  return
86
+ if use_osc52():
87
+ try:
88
+ send_osc52(content)
89
+ self.log_console.print(f"[dim]Sent {item_name} to the terminal clipboard (OSC 52)[/dim]")
90
+ except OSError:
91
+ self.log_console.print(
92
+ "[yellow]No terminal to send the clipboard to; use -s to print instead[/yellow]"
93
+ )
94
+ return
61
95
  try:
62
96
  pyperclip.copy(content)
63
97
  self.log_console.print(f"[dim]Copied {item_name} to clipboard[/dim]")
@@ -60,7 +60,8 @@ def resolve_shell() -> list[str] | None:
60
60
  comspec = os.environ.get("COMSPEC")
61
61
  return [comspec, "/c"] if comspec else None
62
62
 
63
- shell = os.environ.get("SHELL") or shutil.which("bash") or "/bin/sh"
63
+ # Termux has no /bin/sh; its sh lives under $PREFIX/bin.
64
+ shell = os.environ.get("SHELL") or shutil.which("bash") or shutil.which("sh") or "/bin/sh"
64
65
  return [shell, "-c"]
65
66
 
66
67
 
@@ -38,6 +38,12 @@ function global:__cdg {
38
38
  # Advanced function so a failed command can surface as `$? -eq $false` for prompt themes.
39
39
  [CmdletBinding()]
40
40
  param([scriptblock]$__cdgBlock)
41
+ # A wrapped line run again from inside a captured one (history recall, `hf` from
42
+ # hanfix): the outer call already records it, and a second one would clear its buffers.
43
+ if ($null -ne $global:__cdgHead) {
44
+ . $__cdgBlock
45
+ return
46
+ }
41
47
  # Dot-sourced: these locals live in the caller's scope, hence the prefix and cleanup.
42
48
  $__cdgLine = $global:__cdgLine
43
49
  # Left as is so the line can read it; a native command stores a new boxed int,