codigest 0.9.0__tar.gz → 0.10.0__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.
- {codigest-0.9.0 → codigest-0.10.0}/PKG-INFO +128 -32
- {codigest-0.9.0 → codigest-0.10.0}/README.md +116 -20
- codigest-0.10.0/pyproject.toml +160 -0
- codigest-0.10.0/pyproject.toml.orig +77 -0
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/commands/diff.py +1 -1
- codigest-0.10.0/src/codigest/commands/digest.py +79 -0
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/commands/pack.py +1 -1
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/commands/scan.py +44 -7
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/commands/semdiff.py +1 -1
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/commands/term.py +1 -1
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/commands/tree.py +10 -3
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/core/cache.py +6 -11
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/core/common.py +9 -4
- codigest-0.10.0/src/codigest/core/outline.py +70 -0
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/core/output.py +13 -1
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/core/processor.py +20 -5
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/core/prompts.py +3 -4
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/core/semdiff.py +68 -42
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/core/structure.py +11 -6
- codigest-0.10.0/src/codigest/core/tags.py +45 -0
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/options.py +7 -3
- codigest-0.9.0/.gitattributes +0 -1
- codigest-0.9.0/.github/workflows/publish.yml +0 -51
- codigest-0.9.0/.github/workflows/tests.yml +0 -15
- codigest-0.9.0/.gitignore +0 -87
- codigest-0.9.0/.python-version +0 -1
- codigest-0.9.0/CITATION.cff +0 -24
- codigest-0.9.0/LICENSE +0 -21
- codigest-0.9.0/README.ko.md +0 -417
- codigest-0.9.0/docs/demo/demo.gif +0 -0
- codigest-0.9.0/docs/demo/make_gif.py +0 -134
- codigest-0.9.0/docs/dogfood.md +0 -64
- codigest-0.9.0/pyproject.toml +0 -39
- codigest-0.9.0/server.json +0 -28
- codigest-0.9.0/src/codigest/commands/digest.py +0 -87
- codigest-0.9.0/src/codigest/core/tags.py +0 -38
- codigest-0.9.0/tests/test_output.py +0 -23
- codigest-0.9.0/tests/test_pack.py +0 -141
- codigest-0.9.0/tests/test_secrets.py +0 -72
- codigest-0.9.0/tests/test_shadow.py +0 -14
- codigest-0.9.0/tests/test_structure.py +0 -11
- codigest-0.9.0/tests/test_term_install.py +0 -61
- codigest-0.9.0/tests/test_termstore.py +0 -97
- codigest-0.9.0/uv.lock +0 -172
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/__init__.py +0 -0
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/__main__.py +0 -0
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/commands/cap.py +0 -0
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/commands/clean.py +0 -0
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/commands/init.py +0 -0
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/commands/mark.py +0 -0
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/commands/mcp.py +0 -0
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/commands/status.py +0 -0
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/config.py +0 -0
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/core/git_ops.py +0 -0
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/core/redact.py +0 -0
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/core/resolver.py +0 -0
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/core/runner.py +0 -0
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/core/scanner.py +0 -0
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/core/shadow.py +0 -0
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/core/shellhist.py +0 -0
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/core/termstore.py +0 -0
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/core/tokenizer.py +0 -0
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/main.py +0 -0
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/shell/hook.ps1 +0 -0
- {codigest-0.9.0 → codigest-0.10.0}/src/codigest/shell/hook.sh +0 -0
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: codigest
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.10.0
|
|
4
4
|
Summary: Human-Centered Codebase Context Manager for LLMs
|
|
5
|
-
|
|
6
|
-
Project-URL: Repository, https://github.com/NaNIsaac/codigest
|
|
7
|
-
Project-URL: Issues, https://github.com/NaNIsaac/codigest/issues
|
|
5
|
+
Author: Isaac Yong
|
|
8
6
|
Author-email: Isaac Yong <isaacyong@naver.com>
|
|
9
7
|
License: MIT
|
|
10
|
-
License-File: LICENSE
|
|
11
|
-
Classifier: Intended Audience :: Developers
|
|
12
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
-
Classifier: Operating System :: OS Independent
|
|
14
8
|
Classifier: Programming Language :: Python :: 3
|
|
15
9
|
Classifier: Programming Language :: Python :: 3.15
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
16
12
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
17
13
|
Classifier: Topic :: Utilities
|
|
18
|
-
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Requires-Dist: typer
|
|
16
|
+
Requires-Dist: rich
|
|
19
17
|
Requires-Dist: loguru
|
|
20
18
|
Requires-Dist: pathspec
|
|
21
19
|
Requires-Dist: pyperclip
|
|
22
|
-
Requires-Dist: rich
|
|
23
20
|
Requires-Dist: tomli-w
|
|
24
|
-
Requires-
|
|
21
|
+
Requires-Python: >=3.15.0b1
|
|
22
|
+
Project-URL: Homepage, https://github.com/NaNIsaac/codigest
|
|
23
|
+
Project-URL: Repository, https://github.com/NaNIsaac/codigest
|
|
24
|
+
Project-URL: Issues, https://github.com/NaNIsaac/codigest/issues
|
|
25
25
|
Description-Content-Type: text/markdown
|
|
26
26
|
|
|
27
27
|
# Codigest
|
|
28
28
|
|
|
29
|
-
[](https://pypi.org/project/codigest/) [](https://pypi.org/project/codigest/) [](https://github.com/NaNIsaac/codigest/actions/workflows/ci.yml) [](LICENSE)
|
|
30
30
|
|
|
31
31
|
<!-- mcp-name: io.github.NaNIsaac/codigest -->
|
|
32
32
|
|
|
@@ -59,7 +59,7 @@ at.
|
|
|
59
59
|
- **Works with agents.** Claude Code, Cursor and other MCP clients can request the same output.
|
|
60
60
|
|
|
61
61
|
Codigest does not call any AI model; it only prepares what you send to one. Everything runs on
|
|
62
|
-
your machine
|
|
62
|
+
your machine.
|
|
63
63
|
|
|
64
64
|
<p align="center">
|
|
65
65
|
<img src="docs/demo/demo.gif" alt="cdg cap runs a failing pytest, then cdg pack bundles the failure, the test file it names and the changed file" width="760">
|
|
@@ -83,9 +83,11 @@ uv tool update-shell # then restart your terminal
|
|
|
83
83
|
The command is `codigest`, or `cdg` for short. No setup is needed in your projects.
|
|
84
84
|
If the install fails with a syntax error on `lazy import`, run `uv self update` and try again.
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
In a terminal, every command below copies its result to the clipboard. Add `-s` to also print it,
|
|
87
|
+
`-o FILE` to also write it to a file, `--no-copy` to leave the clipboard alone, and `-m "..."` to
|
|
88
|
+
put your question or instruction in it. When the output goes to a pipe or a file instead
|
|
89
|
+
(`cdg scan > ctx.xml`, `cdg digest | less`, a script, a coding agent's shell), it is printed and
|
|
90
|
+
the clipboard is left alone; add `--copy` to copy it anyway.
|
|
89
91
|
|
|
90
92
|
## 1. Share your project with an AI chat
|
|
91
93
|
|
|
@@ -140,9 +142,80 @@ the next section.
|
|
|
140
142
|
|
|
141
143
|
```bash
|
|
142
144
|
cdg scan src/app.py -r # one file and the local files it imports, recursively
|
|
143
|
-
cdg scan src/billing/
|
|
144
|
-
cdg
|
|
145
|
-
cdg
|
|
145
|
+
cdg scan src/billing/ docs/ # folders, files, or both
|
|
146
|
+
cdg scan src/app.py -l # with line numbers, so answers can say "line 42"
|
|
147
|
+
cdg scan src/app.py:40-80 # only lines 40 to 80, numbered (src/app.py:42 for one line)
|
|
148
|
+
cdg digest # signatures and docstrings only, much smaller
|
|
149
|
+
cdg digest src/billing/ # the same for one folder
|
|
150
|
+
cdg tree -L 2 # the file tree, two levels deep
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
`digest` is the overview to start a conversation with. It lists every function, class and
|
|
154
|
+
top-level variable of Python files, and the functions and `%%` sections of MATLAB files, in the
|
|
155
|
+
order they appear, with the line they start on and the first line of their docstring (or, in
|
|
156
|
+
MATLAB, of their help comment). Class attributes and dataclass fields are listed with their
|
|
157
|
+
values, shortened when long:
|
|
158
|
+
|
|
159
|
+
```console
|
|
160
|
+
$ cdg digest -s
|
|
161
|
+
<code_digest project="project" contents="signatures and docstrings, no bodies">
|
|
162
|
+
<project_structure>
|
|
163
|
+
├── .gitignore
|
|
164
|
+
├── legacy
|
|
165
|
+
│ └── discount.m
|
|
166
|
+
├── prices.py
|
|
167
|
+
└── test_prices.py
|
|
168
|
+
</project_structure>
|
|
169
|
+
<file path="legacy/discount.m">
|
|
170
|
+
1: function p = discount(price, percent)
|
|
171
|
+
Price after taking off percent percent.
|
|
172
|
+
3: %% Apply
|
|
173
|
+
</file>
|
|
174
|
+
<file path="prices.py">
|
|
175
|
+
1: TAX_RATE = 0.1
|
|
176
|
+
4: def apply_discount(price: float, percent: float) -> float
|
|
177
|
+
Price after taking off `percent` percent.
|
|
178
|
+
9: class Cart
|
|
179
|
+
Items and the discount that applies to all of them.
|
|
180
|
+
12: def __init__(self, percent: float=0)
|
|
181
|
+
16: def total(self) -> float
|
|
182
|
+
Sum after discount and tax.
|
|
183
|
+
</file>
|
|
184
|
+
<file path="test_prices.py">
|
|
185
|
+
4: def test_ten_percent()
|
|
186
|
+
</file>
|
|
187
|
+
</code_digest>
|
|
188
|
+
Digest 3 files, ~192 tokens
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
A model that has seen this can ask for exactly what it needs ("show me `Cart.total`"), and
|
|
192
|
+
`cdg scan prices.py:16-19` gives it just that method, numbered the same way:
|
|
193
|
+
|
|
194
|
+
```console
|
|
195
|
+
$ cdg scan prices.py:16-19 -s
|
|
196
|
+
<project_snapshot project="project">
|
|
197
|
+
<project_structure>
|
|
198
|
+
└── prices.py
|
|
199
|
+
</project_structure>
|
|
200
|
+
<source_code>
|
|
201
|
+
<file path="prices.py" lines="16-19">
|
|
202
|
+
16: def total(self) -> float:
|
|
203
|
+
17: """Sum after discount and tax."""
|
|
204
|
+
18: subtotal = sum(apply_discount(p, self.percent) for p in self.items)
|
|
205
|
+
19: return subtotal * (1 + TAX_RATE)
|
|
206
|
+
</file>
|
|
207
|
+
</source_code>
|
|
208
|
+
</project_snapshot>
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
`tree -L` keeps a large or vendored folder from flooding the output:
|
|
212
|
+
|
|
213
|
+
```console
|
|
214
|
+
$ cdg tree -L 1
|
|
215
|
+
├── .gitignore
|
|
216
|
+
├── legacy/ (1 file)
|
|
217
|
+
├── prices.py
|
|
218
|
+
└── test_prices.py
|
|
146
219
|
```
|
|
147
220
|
|
|
148
221
|
To share what changed while you work, set a baseline first:
|
|
@@ -192,7 +265,7 @@ F [100%]
|
|
|
192
265
|
_____________________________ test_ten_percent ______________________________
|
|
193
266
|
|
|
194
267
|
def test_ten_percent():
|
|
195
|
-
|
|
268
|
+
> assert apply_discount(200, 10) == 180
|
|
196
269
|
E assert -1800 == 180
|
|
197
270
|
E + where -1800 = apply_discount(200, 10)
|
|
198
271
|
|
|
@@ -275,6 +348,22 @@ claude mcp add --scope user codigest -- cdg mcp # Claude Code
|
|
|
275
348
|
Other clients (Cursor, VS Code, Claude Desktop): add a stdio server with command `cdg` and args
|
|
276
349
|
`["mcp"]`. The tools are listed under [MCP tools](#mcp-tools).
|
|
277
350
|
|
|
351
|
+
An agent that can run shell commands needs no setup at all. Its shell is not a terminal, so `cdg`
|
|
352
|
+
prints the result for it and never touches your clipboard. A way of working that suits agents:
|
|
353
|
+
|
|
354
|
+
```bash
|
|
355
|
+
cdg tree -L 2 # where things are
|
|
356
|
+
cdg digest src/ # what is defined where, with line numbers
|
|
357
|
+
cdg scan src/prices.py:16-19 # read the parts that matter, numbered the same way
|
|
358
|
+
cdg mark # before editing
|
|
359
|
+
cdg semdiff # afterwards: which functions it changed
|
|
360
|
+
cdg cap -- pytest -q && cdg pack # run the tests; on failure, the pack has what to fix
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
The code in every block is exactly as written in the file (`->`, `<`, `&` are not escaped), so
|
|
364
|
+
code copied out of it can be pasted back. A large `scan` with nobody to answer the size question
|
|
365
|
+
stops with a hint instead of waiting; `-y` takes it all.
|
|
366
|
+
|
|
278
367
|
## Reference
|
|
279
368
|
|
|
280
369
|
- [All commands](#all-commands)
|
|
@@ -282,7 +371,7 @@ Other clients (Cursor, VS Code, Claude Desktop): add a stdio server with command
|
|
|
282
371
|
- [MCP tools](#mcp-tools)
|
|
283
372
|
- [Configuration](#configuration)
|
|
284
373
|
- [Privacy and safety](#privacy-and-safety)
|
|
285
|
-
- [Upgrading from 0.
|
|
374
|
+
- [Upgrading from 0.9](#upgrading-from-09)
|
|
286
375
|
- [How it works](#how-it-works)
|
|
287
376
|
- [Development](#development)
|
|
288
377
|
|
|
@@ -293,8 +382,8 @@ Other clients (Cursor, VS Code, Claude Desktop): add a stdio server with command
|
|
|
293
382
|
| Command | What it gives you | Writes to your project |
|
|
294
383
|
| --- | --- | --- |
|
|
295
384
|
| `scan` | The whole project, or chosen paths, as one block | nothing |
|
|
296
|
-
| `digest` |
|
|
297
|
-
| `tree` | Project tree | nothing |
|
|
385
|
+
| `digest` | Numbered signatures and docstrings, no bodies (Python, MATLAB) | nothing |
|
|
386
|
+
| `tree` | Project tree (`-L N` limits the depth) | nothing |
|
|
298
387
|
| `mark` | Sets the baseline | `.codigest/` |
|
|
299
388
|
| `diff` | Text diff since the baseline | nothing |
|
|
300
389
|
| `semdiff` | Function and class level changes since the baseline (Python) | nothing |
|
|
@@ -306,8 +395,9 @@ Other clients (Cursor, VS Code, Claude Desktop): add a stdio server with command
|
|
|
306
395
|
| `init` | `.codigest/config.toml` for [file filters](#configuration) | `.codigest/`, `.gitignore` |
|
|
307
396
|
| `clean` | Deletes `.codigest/` (asks first, `-y` to skip) | removes `.codigest/` |
|
|
308
397
|
|
|
309
|
-
Shared options: `-s` / `--stdout` also prints the result (status messages go to stderr
|
|
310
|
-
`--no-copy`
|
|
398
|
+
Shared options: `-s` / `--stdout` also prints the result (status messages go to stderr; on by
|
|
399
|
+
default when piped), `--copy` / `--no-copy` overrides the clipboard default (copy in a terminal,
|
|
400
|
+
not when piped), `-o FILE` also writes it to a file, `-m` / `--message` adds an
|
|
311
401
|
instruction.
|
|
312
402
|
`scan -l` adds line numbers, `scan -a` ignores the config filters, `scan -y` skips the
|
|
313
403
|
confirmation (CI). `-r` / `--resolve` on `scan`, `diff`, `semdiff` and `digest` also pulls in
|
|
@@ -410,6 +500,14 @@ skipped.
|
|
|
410
500
|
- **Nothing leaves your machine.** Codigest makes no network requests. Context goes where you
|
|
411
501
|
paste it, or to the MCP client you connected.
|
|
412
502
|
|
|
503
|
+
### Upgrading from 0.9
|
|
504
|
+
|
|
505
|
+
- Piped or redirected output is printed without `-s` and no longer copied; add `--copy` if a
|
|
506
|
+
script relied on the clipboard.
|
|
507
|
+
- `<file>` blocks hold the code verbatim instead of XML-escaped. A custom template in
|
|
508
|
+
`.codigest/prompts.toml` now receives the blocks unescaped too; only `{instruction}` is escaped.
|
|
509
|
+
- `digest` output is numbered, in source order, with docstrings, and takes several paths.
|
|
510
|
+
|
|
413
511
|
### Upgrading from 0.8
|
|
414
512
|
|
|
415
513
|
- `scan`, `diff`, `semdiff` and `digest` no longer save into `.codigest/*.txt`; use `-o FILE`.
|
|
@@ -423,13 +521,14 @@ skipped.
|
|
|
423
521
|
### How it works
|
|
424
522
|
|
|
425
523
|
- **Baseline.** A Git repository at `.codigest/anchor/.shadow_git`, separate from your project's
|
|
426
|
-
repository.
|
|
524
|
+
repository. `mark`
|
|
427
525
|
commits the current state to it; `diff`, `semdiff`, `status` and `pack` compare the working tree
|
|
428
526
|
against it.
|
|
429
527
|
- **Captures.** One newline-delimited JSON file holds the last 200 commands; each output is capped
|
|
430
528
|
at 64 KB, keeping the head and tail.
|
|
431
|
-
- **Output.** File contents
|
|
432
|
-
|
|
529
|
+
- **Output.** File contents go into `<file>` blocks verbatim. Only a closing tag of one of
|
|
530
|
+
Codigest's own blocks inside a file (a literal `</file>`) is written as `</file>`, so it
|
|
531
|
+
cannot end the block early.
|
|
433
532
|
- **MCP.** The server is a small JSON-RPC loop over stdio. Each tool runs the regular CLI with
|
|
434
533
|
`-s --no-copy`, so an agent sees exactly what you would paste.
|
|
435
534
|
|
|
@@ -442,9 +541,6 @@ uv run cdg --help # run from the checkout
|
|
|
442
541
|
uv run --with pytest pytest -q # tests
|
|
443
542
|
```
|
|
444
543
|
|
|
445
|
-
The demo GIF is rendered from recorded output by
|
|
446
|
-
[`docs/demo/make_gif.py`](docs/demo/make_gif.py); its docstring explains how to record a new one.
|
|
447
|
-
|
|
448
544
|
## License
|
|
449
545
|
|
|
450
546
|
MIT. See [LICENSE](LICENSE).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Codigest
|
|
2
2
|
|
|
3
|
-
[](https://pypi.org/project/codigest/) [](https://pypi.org/project/codigest/) [](https://github.com/NaNIsaac/codigest/actions/workflows/ci.yml) [](LICENSE)
|
|
4
4
|
|
|
5
5
|
<!-- mcp-name: io.github.NaNIsaac/codigest -->
|
|
6
6
|
|
|
@@ -33,7 +33,7 @@ at.
|
|
|
33
33
|
- **Works with agents.** Claude Code, Cursor and other MCP clients can request the same output.
|
|
34
34
|
|
|
35
35
|
Codigest does not call any AI model; it only prepares what you send to one. Everything runs on
|
|
36
|
-
your machine
|
|
36
|
+
your machine.
|
|
37
37
|
|
|
38
38
|
<p align="center">
|
|
39
39
|
<img src="docs/demo/demo.gif" alt="cdg cap runs a failing pytest, then cdg pack bundles the failure, the test file it names and the changed file" width="760">
|
|
@@ -57,9 +57,11 @@ uv tool update-shell # then restart your terminal
|
|
|
57
57
|
The command is `codigest`, or `cdg` for short. No setup is needed in your projects.
|
|
58
58
|
If the install fails with a syntax error on `lazy import`, run `uv self update` and try again.
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
In a terminal, every command below copies its result to the clipboard. Add `-s` to also print it,
|
|
61
|
+
`-o FILE` to also write it to a file, `--no-copy` to leave the clipboard alone, and `-m "..."` to
|
|
62
|
+
put your question or instruction in it. When the output goes to a pipe or a file instead
|
|
63
|
+
(`cdg scan > ctx.xml`, `cdg digest | less`, a script, a coding agent's shell), it is printed and
|
|
64
|
+
the clipboard is left alone; add `--copy` to copy it anyway.
|
|
63
65
|
|
|
64
66
|
## 1. Share your project with an AI chat
|
|
65
67
|
|
|
@@ -114,9 +116,80 @@ the next section.
|
|
|
114
116
|
|
|
115
117
|
```bash
|
|
116
118
|
cdg scan src/app.py -r # one file and the local files it imports, recursively
|
|
117
|
-
cdg scan src/billing/
|
|
118
|
-
cdg
|
|
119
|
-
cdg
|
|
119
|
+
cdg scan src/billing/ docs/ # folders, files, or both
|
|
120
|
+
cdg scan src/app.py -l # with line numbers, so answers can say "line 42"
|
|
121
|
+
cdg scan src/app.py:40-80 # only lines 40 to 80, numbered (src/app.py:42 for one line)
|
|
122
|
+
cdg digest # signatures and docstrings only, much smaller
|
|
123
|
+
cdg digest src/billing/ # the same for one folder
|
|
124
|
+
cdg tree -L 2 # the file tree, two levels deep
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
`digest` is the overview to start a conversation with. It lists every function, class and
|
|
128
|
+
top-level variable of Python files, and the functions and `%%` sections of MATLAB files, in the
|
|
129
|
+
order they appear, with the line they start on and the first line of their docstring (or, in
|
|
130
|
+
MATLAB, of their help comment). Class attributes and dataclass fields are listed with their
|
|
131
|
+
values, shortened when long:
|
|
132
|
+
|
|
133
|
+
```console
|
|
134
|
+
$ cdg digest -s
|
|
135
|
+
<code_digest project="project" contents="signatures and docstrings, no bodies">
|
|
136
|
+
<project_structure>
|
|
137
|
+
├── .gitignore
|
|
138
|
+
├── legacy
|
|
139
|
+
│ └── discount.m
|
|
140
|
+
├── prices.py
|
|
141
|
+
└── test_prices.py
|
|
142
|
+
</project_structure>
|
|
143
|
+
<file path="legacy/discount.m">
|
|
144
|
+
1: function p = discount(price, percent)
|
|
145
|
+
Price after taking off percent percent.
|
|
146
|
+
3: %% Apply
|
|
147
|
+
</file>
|
|
148
|
+
<file path="prices.py">
|
|
149
|
+
1: TAX_RATE = 0.1
|
|
150
|
+
4: def apply_discount(price: float, percent: float) -> float
|
|
151
|
+
Price after taking off `percent` percent.
|
|
152
|
+
9: class Cart
|
|
153
|
+
Items and the discount that applies to all of them.
|
|
154
|
+
12: def __init__(self, percent: float=0)
|
|
155
|
+
16: def total(self) -> float
|
|
156
|
+
Sum after discount and tax.
|
|
157
|
+
</file>
|
|
158
|
+
<file path="test_prices.py">
|
|
159
|
+
4: def test_ten_percent()
|
|
160
|
+
</file>
|
|
161
|
+
</code_digest>
|
|
162
|
+
Digest 3 files, ~192 tokens
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
A model that has seen this can ask for exactly what it needs ("show me `Cart.total`"), and
|
|
166
|
+
`cdg scan prices.py:16-19` gives it just that method, numbered the same way:
|
|
167
|
+
|
|
168
|
+
```console
|
|
169
|
+
$ cdg scan prices.py:16-19 -s
|
|
170
|
+
<project_snapshot project="project">
|
|
171
|
+
<project_structure>
|
|
172
|
+
└── prices.py
|
|
173
|
+
</project_structure>
|
|
174
|
+
<source_code>
|
|
175
|
+
<file path="prices.py" lines="16-19">
|
|
176
|
+
16: def total(self) -> float:
|
|
177
|
+
17: """Sum after discount and tax."""
|
|
178
|
+
18: subtotal = sum(apply_discount(p, self.percent) for p in self.items)
|
|
179
|
+
19: return subtotal * (1 + TAX_RATE)
|
|
180
|
+
</file>
|
|
181
|
+
</source_code>
|
|
182
|
+
</project_snapshot>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
`tree -L` keeps a large or vendored folder from flooding the output:
|
|
186
|
+
|
|
187
|
+
```console
|
|
188
|
+
$ cdg tree -L 1
|
|
189
|
+
├── .gitignore
|
|
190
|
+
├── legacy/ (1 file)
|
|
191
|
+
├── prices.py
|
|
192
|
+
└── test_prices.py
|
|
120
193
|
```
|
|
121
194
|
|
|
122
195
|
To share what changed while you work, set a baseline first:
|
|
@@ -166,7 +239,7 @@ F [100%]
|
|
|
166
239
|
_____________________________ test_ten_percent ______________________________
|
|
167
240
|
|
|
168
241
|
def test_ten_percent():
|
|
169
|
-
|
|
242
|
+
> assert apply_discount(200, 10) == 180
|
|
170
243
|
E assert -1800 == 180
|
|
171
244
|
E + where -1800 = apply_discount(200, 10)
|
|
172
245
|
|
|
@@ -249,6 +322,22 @@ claude mcp add --scope user codigest -- cdg mcp # Claude Code
|
|
|
249
322
|
Other clients (Cursor, VS Code, Claude Desktop): add a stdio server with command `cdg` and args
|
|
250
323
|
`["mcp"]`. The tools are listed under [MCP tools](#mcp-tools).
|
|
251
324
|
|
|
325
|
+
An agent that can run shell commands needs no setup at all. Its shell is not a terminal, so `cdg`
|
|
326
|
+
prints the result for it and never touches your clipboard. A way of working that suits agents:
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
cdg tree -L 2 # where things are
|
|
330
|
+
cdg digest src/ # what is defined where, with line numbers
|
|
331
|
+
cdg scan src/prices.py:16-19 # read the parts that matter, numbered the same way
|
|
332
|
+
cdg mark # before editing
|
|
333
|
+
cdg semdiff # afterwards: which functions it changed
|
|
334
|
+
cdg cap -- pytest -q && cdg pack # run the tests; on failure, the pack has what to fix
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
The code in every block is exactly as written in the file (`->`, `<`, `&` are not escaped), so
|
|
338
|
+
code copied out of it can be pasted back. A large `scan` with nobody to answer the size question
|
|
339
|
+
stops with a hint instead of waiting; `-y` takes it all.
|
|
340
|
+
|
|
252
341
|
## Reference
|
|
253
342
|
|
|
254
343
|
- [All commands](#all-commands)
|
|
@@ -256,7 +345,7 @@ Other clients (Cursor, VS Code, Claude Desktop): add a stdio server with command
|
|
|
256
345
|
- [MCP tools](#mcp-tools)
|
|
257
346
|
- [Configuration](#configuration)
|
|
258
347
|
- [Privacy and safety](#privacy-and-safety)
|
|
259
|
-
- [Upgrading from 0.
|
|
348
|
+
- [Upgrading from 0.9](#upgrading-from-09)
|
|
260
349
|
- [How it works](#how-it-works)
|
|
261
350
|
- [Development](#development)
|
|
262
351
|
|
|
@@ -267,8 +356,8 @@ Other clients (Cursor, VS Code, Claude Desktop): add a stdio server with command
|
|
|
267
356
|
| Command | What it gives you | Writes to your project |
|
|
268
357
|
| --- | --- | --- |
|
|
269
358
|
| `scan` | The whole project, or chosen paths, as one block | nothing |
|
|
270
|
-
| `digest` |
|
|
271
|
-
| `tree` | Project tree | nothing |
|
|
359
|
+
| `digest` | Numbered signatures and docstrings, no bodies (Python, MATLAB) | nothing |
|
|
360
|
+
| `tree` | Project tree (`-L N` limits the depth) | nothing |
|
|
272
361
|
| `mark` | Sets the baseline | `.codigest/` |
|
|
273
362
|
| `diff` | Text diff since the baseline | nothing |
|
|
274
363
|
| `semdiff` | Function and class level changes since the baseline (Python) | nothing |
|
|
@@ -280,8 +369,9 @@ Other clients (Cursor, VS Code, Claude Desktop): add a stdio server with command
|
|
|
280
369
|
| `init` | `.codigest/config.toml` for [file filters](#configuration) | `.codigest/`, `.gitignore` |
|
|
281
370
|
| `clean` | Deletes `.codigest/` (asks first, `-y` to skip) | removes `.codigest/` |
|
|
282
371
|
|
|
283
|
-
Shared options: `-s` / `--stdout` also prints the result (status messages go to stderr
|
|
284
|
-
`--no-copy`
|
|
372
|
+
Shared options: `-s` / `--stdout` also prints the result (status messages go to stderr; on by
|
|
373
|
+
default when piped), `--copy` / `--no-copy` overrides the clipboard default (copy in a terminal,
|
|
374
|
+
not when piped), `-o FILE` also writes it to a file, `-m` / `--message` adds an
|
|
285
375
|
instruction.
|
|
286
376
|
`scan -l` adds line numbers, `scan -a` ignores the config filters, `scan -y` skips the
|
|
287
377
|
confirmation (CI). `-r` / `--resolve` on `scan`, `diff`, `semdiff` and `digest` also pulls in
|
|
@@ -384,6 +474,14 @@ skipped.
|
|
|
384
474
|
- **Nothing leaves your machine.** Codigest makes no network requests. Context goes where you
|
|
385
475
|
paste it, or to the MCP client you connected.
|
|
386
476
|
|
|
477
|
+
### Upgrading from 0.9
|
|
478
|
+
|
|
479
|
+
- Piped or redirected output is printed without `-s` and no longer copied; add `--copy` if a
|
|
480
|
+
script relied on the clipboard.
|
|
481
|
+
- `<file>` blocks hold the code verbatim instead of XML-escaped. A custom template in
|
|
482
|
+
`.codigest/prompts.toml` now receives the blocks unescaped too; only `{instruction}` is escaped.
|
|
483
|
+
- `digest` output is numbered, in source order, with docstrings, and takes several paths.
|
|
484
|
+
|
|
387
485
|
### Upgrading from 0.8
|
|
388
486
|
|
|
389
487
|
- `scan`, `diff`, `semdiff` and `digest` no longer save into `.codigest/*.txt`; use `-o FILE`.
|
|
@@ -397,13 +495,14 @@ skipped.
|
|
|
397
495
|
### How it works
|
|
398
496
|
|
|
399
497
|
- **Baseline.** A Git repository at `.codigest/anchor/.shadow_git`, separate from your project's
|
|
400
|
-
repository.
|
|
498
|
+
repository. `mark`
|
|
401
499
|
commits the current state to it; `diff`, `semdiff`, `status` and `pack` compare the working tree
|
|
402
500
|
against it.
|
|
403
501
|
- **Captures.** One newline-delimited JSON file holds the last 200 commands; each output is capped
|
|
404
502
|
at 64 KB, keeping the head and tail.
|
|
405
|
-
- **Output.** File contents
|
|
406
|
-
|
|
503
|
+
- **Output.** File contents go into `<file>` blocks verbatim. Only a closing tag of one of
|
|
504
|
+
Codigest's own blocks inside a file (a literal `</file>`) is written as `</file>`, so it
|
|
505
|
+
cannot end the block early.
|
|
407
506
|
- **MCP.** The server is a small JSON-RPC loop over stdio. Each tool runs the regular CLI with
|
|
408
507
|
`-s --no-copy`, so an agent sees exactly what you would paste.
|
|
409
508
|
|
|
@@ -416,9 +515,6 @@ uv run cdg --help # run from the checkout
|
|
|
416
515
|
uv run --with pytest pytest -q # tests
|
|
417
516
|
```
|
|
418
517
|
|
|
419
|
-
The demo GIF is rendered from recorded output by
|
|
420
|
-
[`docs/demo/make_gif.py`](docs/demo/make_gif.py); its docstring explains how to record a new one.
|
|
421
|
-
|
|
422
518
|
## License
|
|
423
519
|
|
|
424
520
|
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "codigest"
|
|
3
|
+
version = "0.10.0"
|
|
4
|
+
description = "Human-Centered Codebase Context Manager for LLMs"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.15.0b1"
|
|
7
|
+
dependencies = [
|
|
8
|
+
"typer",
|
|
9
|
+
"rich",
|
|
10
|
+
"loguru",
|
|
11
|
+
"pathspec",
|
|
12
|
+
"pyperclip",
|
|
13
|
+
"tomli-w",
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Programming Language :: Python :: 3.15",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
21
|
+
"Topic :: Utilities",
|
|
22
|
+
"Intended Audience :: Developers",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[[project.authors]]
|
|
26
|
+
name = "Isaac Yong"
|
|
27
|
+
email = "isaacyong@naver.com"
|
|
28
|
+
|
|
29
|
+
[project.license]
|
|
30
|
+
text = "MIT"
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
Homepage = "https://github.com/NaNIsaac/codigest"
|
|
34
|
+
Repository = "https://github.com/NaNIsaac/codigest"
|
|
35
|
+
Issues = "https://github.com/NaNIsaac/codigest/issues"
|
|
36
|
+
|
|
37
|
+
[project.scripts]
|
|
38
|
+
codigest = "codigest.main:app"
|
|
39
|
+
cdg = "codigest.main:app"
|
|
40
|
+
|
|
41
|
+
[build-system]
|
|
42
|
+
requires = ["uv_build>=0.12.7,<0.13"]
|
|
43
|
+
build-backend = "uv_build"
|
|
44
|
+
|
|
45
|
+
[tool.ruff]
|
|
46
|
+
line-length = 100
|
|
47
|
+
|
|
48
|
+
[tool.ruff.lint.extend-per-file-ignores]
|
|
49
|
+
"src/codigest/commands/cap.py" = ["I001"]
|
|
50
|
+
"src/codigest/commands/clean.py" = ["B008"]
|
|
51
|
+
"src/codigest/commands/diff.py" = [
|
|
52
|
+
"B008",
|
|
53
|
+
"BLE001",
|
|
54
|
+
"I001",
|
|
55
|
+
]
|
|
56
|
+
"src/codigest/commands/digest.py" = [
|
|
57
|
+
"B008",
|
|
58
|
+
"BLE001",
|
|
59
|
+
"I001",
|
|
60
|
+
"S112",
|
|
61
|
+
]
|
|
62
|
+
"src/codigest/commands/init.py" = ["B008"]
|
|
63
|
+
"src/codigest/commands/mark.py" = ["B008"]
|
|
64
|
+
"src/codigest/commands/mcp.py" = [
|
|
65
|
+
"BLE001",
|
|
66
|
+
"I001",
|
|
67
|
+
"PLW1510",
|
|
68
|
+
"SIM115",
|
|
69
|
+
]
|
|
70
|
+
"src/codigest/commands/pack.py" = [
|
|
71
|
+
"B008",
|
|
72
|
+
"I001",
|
|
73
|
+
"UP017",
|
|
74
|
+
]
|
|
75
|
+
"src/codigest/commands/scan.py" = [
|
|
76
|
+
"B008",
|
|
77
|
+
"BLE001",
|
|
78
|
+
"I001",
|
|
79
|
+
"S112",
|
|
80
|
+
]
|
|
81
|
+
"src/codigest/commands/semdiff.py" = [
|
|
82
|
+
"B008",
|
|
83
|
+
"BLE001",
|
|
84
|
+
"I001",
|
|
85
|
+
]
|
|
86
|
+
"src/codigest/commands/status.py" = [
|
|
87
|
+
"B008",
|
|
88
|
+
"RUF059",
|
|
89
|
+
]
|
|
90
|
+
"src/codigest/commands/term.py" = [
|
|
91
|
+
"BLE001",
|
|
92
|
+
"I001",
|
|
93
|
+
"PLW1510",
|
|
94
|
+
]
|
|
95
|
+
"src/codigest/commands/tree.py" = [
|
|
96
|
+
"B008",
|
|
97
|
+
"I001",
|
|
98
|
+
]
|
|
99
|
+
"src/codigest/core/cache.py" = [
|
|
100
|
+
"BLE001",
|
|
101
|
+
"I001",
|
|
102
|
+
"S110",
|
|
103
|
+
"SIM102",
|
|
104
|
+
"UP012",
|
|
105
|
+
]
|
|
106
|
+
"src/codigest/core/common.py" = [
|
|
107
|
+
"BLE001",
|
|
108
|
+
"I001",
|
|
109
|
+
"S110",
|
|
110
|
+
]
|
|
111
|
+
"src/codigest/core/git_ops.py" = ["I001"]
|
|
112
|
+
"src/codigest/core/output.py" = [
|
|
113
|
+
"BLE001",
|
|
114
|
+
"I001",
|
|
115
|
+
]
|
|
116
|
+
"src/codigest/core/processor.py" = [
|
|
117
|
+
"BLE001",
|
|
118
|
+
"I001",
|
|
119
|
+
]
|
|
120
|
+
"src/codigest/core/prompts.py" = [
|
|
121
|
+
"BLE001",
|
|
122
|
+
"I001",
|
|
123
|
+
]
|
|
124
|
+
"src/codigest/core/redact.py" = ["RUF007"]
|
|
125
|
+
"src/codigest/core/resolver.py" = [
|
|
126
|
+
"BLE001",
|
|
127
|
+
"I001",
|
|
128
|
+
"S112",
|
|
129
|
+
"SIM102",
|
|
130
|
+
]
|
|
131
|
+
"src/codigest/core/runner.py" = ["I001"]
|
|
132
|
+
"src/codigest/core/scanner.py" = [
|
|
133
|
+
"BLE001",
|
|
134
|
+
"I001",
|
|
135
|
+
"SIM102",
|
|
136
|
+
]
|
|
137
|
+
"src/codigest/core/semdiff.py" = [
|
|
138
|
+
"BLE001",
|
|
139
|
+
"I001",
|
|
140
|
+
"S110",
|
|
141
|
+
]
|
|
142
|
+
"src/codigest/core/shadow.py" = [
|
|
143
|
+
"BLE001",
|
|
144
|
+
"I001",
|
|
145
|
+
"PLW1510",
|
|
146
|
+
"S112",
|
|
147
|
+
]
|
|
148
|
+
"src/codigest/core/structure.py" = ["I001"]
|
|
149
|
+
"src/codigest/core/tags.py" = ["I001"]
|
|
150
|
+
"src/codigest/core/termstore.py" = ["I001"]
|
|
151
|
+
"src/codigest/core/tokenizer.py" = ["I001"]
|
|
152
|
+
"src/codigest/main.py" = [
|
|
153
|
+
"BLE001",
|
|
154
|
+
"I001",
|
|
155
|
+
]
|
|
156
|
+
"src/codigest/options.py" = ["I001"]
|
|
157
|
+
"tests/test_term_install.py" = [
|
|
158
|
+
"PIE807",
|
|
159
|
+
"UP012",
|
|
160
|
+
]
|