codigest 0.12.0__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.0 → codigest-0.12.2}/PKG-INFO +36 -7
  2. {codigest-0.12.0 → codigest-0.12.2}/README.md +35 -6
  3. {codigest-0.12.0 → codigest-0.12.2}/pyproject.toml +1 -1
  4. {codigest-0.12.0 → codigest-0.12.2}/pyproject.toml.orig +1 -1
  5. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/core/output.py +34 -0
  6. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/core/runner.py +2 -1
  7. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/shell/hook.ps1 +6 -0
  8. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/__init__.py +0 -0
  9. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/__main__.py +0 -0
  10. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/commands/cap.py +0 -0
  11. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/commands/clean.py +0 -0
  12. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/commands/diff.py +0 -0
  13. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/commands/digest.py +0 -0
  14. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/commands/init.py +0 -0
  15. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/commands/mark.py +0 -0
  16. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/commands/mcp.py +0 -0
  17. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/commands/pack.py +0 -0
  18. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/commands/scan.py +0 -0
  19. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/commands/semdiff.py +0 -0
  20. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/commands/shell_help.py +0 -0
  21. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/commands/status.py +0 -0
  22. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/commands/term.py +0 -0
  23. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/commands/tree.py +0 -0
  24. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/config.py +0 -0
  25. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/core/cache.py +0 -0
  26. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/core/callees.py +0 -0
  27. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/core/common.py +0 -0
  28. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/core/formats.py +0 -0
  29. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/core/git_ops.py +0 -0
  30. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/core/outline.py +0 -0
  31. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/core/presets.py +0 -0
  32. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/core/processor.py +0 -0
  33. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/core/prompts.py +0 -0
  34. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/core/redact.py +0 -0
  35. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/core/resolver.py +0 -0
  36. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/core/scanner.py +0 -0
  37. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/core/semdiff.py +0 -0
  38. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/core/shadow.py +0 -0
  39. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/core/shellhist.py +0 -0
  40. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/core/structure.py +0 -0
  41. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/core/tags.py +0 -0
  42. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/core/termstore.py +0 -0
  43. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/core/tokenizer.py +0 -0
  44. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/main.py +0 -0
  45. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/options.py +0 -0
  46. {codigest-0.12.0 → codigest-0.12.2}/src/codigest/shell/help.ps1 +0 -0
  47. {codigest-0.12.0 → 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.0
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>
@@ -80,8 +80,32 @@ your machine.
80
80
 
81
81
  ## Install
82
82
 
83
- Install it with [uv](https://docs.astral.sh/uv/), which also fetches the Python version Codigest
84
- needs (3.15) and keeps it apart from your projects:
83
+ Prebuilt binary, no Python needed. Windows (PowerShell):
84
+
85
+ ```powershell
86
+ irm https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.ps1 | iex
87
+ ```
88
+
89
+ Linux, macOS and Termux:
90
+
91
+ ```bash
92
+ curl -fsSL https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.sh | sh
93
+ ```
94
+
95
+ This installs `cdg` to `%LOCALAPPDATA%\Programs\codigest` (added to your user `PATH`) on Windows,
96
+ `~/.local/bin` on Linux and macOS, and `$PREFIX/bin` in Termux. Run the same line again to update.
97
+ `CDG_VERSION=0.12.1` pins a version and `CDG_INSTALL_DIR=...` picks the folder (then `PATH` is left
98
+ alone). Supported: Windows x64, Linux x64 and ARM64, macOS Intel and Apple Silicon, Android ARM64
99
+ (Termux; the tests also run inside Termux in CI). Archives for download by hand are on the
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.
104
+
105
+ ### Python package
106
+
107
+ The same commands are on PyPI as `codigest`. Install it with [uv](https://docs.astral.sh/uv/), which
108
+ also fetches the Python version it needs (3.15) and keeps it apart from your projects:
85
109
 
86
110
  ```bash
87
111
  winget install --id astral-sh.uv # Windows (skip if you have uv)
@@ -91,7 +115,12 @@ uv tool install codigest
91
115
  uv tool update-shell # then restart your terminal
92
116
  ```
93
117
 
94
- The command is `codigest`, or `cdg` for short. No setup is needed in your projects.
118
+ The command is `codigest`, or `cdg` for short. Both installs provide a command called `cdg`, so keep
119
+ only one of them on `PATH`. If the install fails with a syntax error on `lazy import`, run
120
+ `uv self update` and try again.
121
+
122
+ Next, `cdg term install` hooks your shell so the output of every command is kept for `cdg pack` and
123
+ `cdg term`. It is off until you run it; see [Terminal capture](#terminal-capture).
95
124
 
96
125
  On Windows, PowerShell's `help codigest` is a separate command from `codigest --help`.
97
126
  For optional native `Get-Help` integration **without automatic command capture**:
@@ -104,14 +133,14 @@ cdg shell-help uninstall # remove it when no longer needed
104
133
  ```
105
134
 
106
135
  This adds a small forwarding function to your PowerShell profile; other `help` commands are
107
- unchanged. The CLI's own full command reference is still available via `codigest --help`.
108
- If the install fails with a syntax error on `lazy import`, run `uv self update` and try again.
136
+ unchanged. The CLI's own full command reference is still available via `cdg --help`.
109
137
 
110
138
  In a terminal, every command below copies its result to the clipboard. Add `-s` to also print it,
111
139
  `-o FILE` to also write it to a file, `--no-copy` to leave the clipboard alone, and `-m "..."` to
112
140
  put your question or instruction in it. When the output goes to a pipe or a file instead
113
141
  (`cdg scan > ctx.xml`, `cdg digest | less`, a script, a coding agent's shell), it is printed and
114
- 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).
115
144
 
116
145
  ## 1. Share your project with an AI chat
117
146
 
@@ -54,8 +54,32 @@ your machine.
54
54
 
55
55
  ## Install
56
56
 
57
- Install it with [uv](https://docs.astral.sh/uv/), which also fetches the Python version Codigest
58
- needs (3.15) and keeps it apart from your projects:
57
+ Prebuilt binary, no Python needed. Windows (PowerShell):
58
+
59
+ ```powershell
60
+ irm https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.ps1 | iex
61
+ ```
62
+
63
+ Linux, macOS and Termux:
64
+
65
+ ```bash
66
+ curl -fsSL https://raw.githubusercontent.com/NaNIsaac/codigest/main/install.sh | sh
67
+ ```
68
+
69
+ This installs `cdg` to `%LOCALAPPDATA%\Programs\codigest` (added to your user `PATH`) on Windows,
70
+ `~/.local/bin` on Linux and macOS, and `$PREFIX/bin` in Termux. Run the same line again to update.
71
+ `CDG_VERSION=0.12.1` pins a version and `CDG_INSTALL_DIR=...` picks the folder (then `PATH` is left
72
+ alone). Supported: Windows x64, Linux x64 and ARM64, macOS Intel and Apple Silicon, Android ARM64
73
+ (Termux; the tests also run inside Termux in CI). Archives for download by hand are on the
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.
78
+
79
+ ### Python package
80
+
81
+ The same commands are on PyPI as `codigest`. Install it with [uv](https://docs.astral.sh/uv/), which
82
+ also fetches the Python version it needs (3.15) and keeps it apart from your projects:
59
83
 
60
84
  ```bash
61
85
  winget install --id astral-sh.uv # Windows (skip if you have uv)
@@ -65,7 +89,12 @@ uv tool install codigest
65
89
  uv tool update-shell # then restart your terminal
66
90
  ```
67
91
 
68
- The command is `codigest`, or `cdg` for short. No setup is needed in your projects.
92
+ The command is `codigest`, or `cdg` for short. Both installs provide a command called `cdg`, so keep
93
+ only one of them on `PATH`. If the install fails with a syntax error on `lazy import`, run
94
+ `uv self update` and try again.
95
+
96
+ Next, `cdg term install` hooks your shell so the output of every command is kept for `cdg pack` and
97
+ `cdg term`. It is off until you run it; see [Terminal capture](#terminal-capture).
69
98
 
70
99
  On Windows, PowerShell's `help codigest` is a separate command from `codigest --help`.
71
100
  For optional native `Get-Help` integration **without automatic command capture**:
@@ -78,14 +107,14 @@ cdg shell-help uninstall # remove it when no longer needed
78
107
  ```
79
108
 
80
109
  This adds a small forwarding function to your PowerShell profile; other `help` commands are
81
- unchanged. The CLI's own full command reference is still available via `codigest --help`.
82
- If the install fails with a syntax error on `lazy import`, run `uv self update` and try again.
110
+ unchanged. The CLI's own full command reference is still available via `cdg --help`.
83
111
 
84
112
  In a terminal, every command below copies its result to the clipboard. Add `-s` to also print it,
85
113
  `-o FILE` to also write it to a file, `--no-copy` to leave the clipboard alone, and `-m "..."` to
86
114
  put your question or instruction in it. When the output goes to a pipe or a file instead
87
115
  (`cdg scan > ctx.xml`, `cdg digest | less`, a script, a coding agent's shell), it is printed and
88
- 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).
89
118
 
90
119
  ## 1. Share your project with an AI chat
91
120
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "codigest"
3
- version = "0.12.0"
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.0"
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,