고른 코드를 묶습니다
프로젝트 전체, 지정한 파일과 폴더, 또는 그 파일이 import하는 프로젝트 파일(Python, JS/TS)을 파일 트리와 함께 하나로 묶습니다.
Codigest는 AI 모델을 호출하지 않습니다. 모델에게 보낼 자료를 준비할 뿐입니다. 모든 작업은 내 컴퓨터 안에서 이루어집니다.
아래는 작은 프로젝트에서 실제로 실행한 결과입니다. prices.py와, 실패하는 테스트 test_prices.py로 이루어진 프로젝트입니다. 예시 사이에 프로젝트가 조금씩 자랍니다. prices.py에 Cart 클래스가 생기고, MATLAB 파일이 든 legacy/ 폴더가 생깁니다.
$ cdg scan -s<project_snapshot project="project">
<project_structure>
├── .gitignore
├── prices.py
└── test_prices.py
</project_structure>
<source_code>
<file path=".gitignore">
.venv/
__pycache__/
.pytest_cache/
</file>
<file path="prices.py">
def apply_discount(price, percent):
return price * (1 - percent)
</file>
<file path="test_prices.py">
from prices import apply_discount
def test_ten_percent():
assert apply_discount(200, 10) == 180
</file>
</source_code>
</project_snapshot>터미널에서 실행하면 결과가 클립보드에 복사됩니다. -s를 붙이면 화면에도 출력합니다.
digest는 함수, 클래스, 최상위 변수를 시작 줄 번호와 docstring 첫 줄과 함께 나열하고, 본문은 뺍니다.
$ cdg digest -s<code_digest project="project" contents="signatures and docstrings, no bodies">
<project_structure>
├── .gitignore
├── legacy
│ └── discount.m
├── prices.py
└── test_prices.py
</project_structure>
<file path="legacy/discount.m">
1: function p = discount(price, percent)
Price after taking off percent percent.
5: %% Apply
</file>
<file path="prices.py">
1: TAX_RATE = 0.1
4: def apply_discount(price: float, percent: float) -> float
Price after taking off `percent` percent.
9: class Cart
Items and the discount that applies to all of them.
12: def __init__(self, percent: float=0)
16: def total(self) -> float
Sum after discount and tax.
</file>
<file path="test_prices.py">
4: def test_ten_percent()
</file>
</code_digest>$ cdg cap -- pytest -q
F [100%]
================================== FAILURES ===================================
______________________________ test_ten_percent _______________________________
def test_ten_percent():
> assert apply_discount(200, 10) == 180
E assert -1800 == 180
E + where -1800 = apply_discount(200, 10)
test_prices.py:5: AssertionError
=========================== short test summary info ===========================
FAILED test_prices.py::test_ten_percent - assert -1800 == 180
1 failed in 0.04s
$ cdg pack
Packed ~689 / 30,000 tokens
failed pytest -q (exit 1, just now)
changes uncommitted changes (git)
+ test_prices.py line 5 in failing output
+ prices.py called from failing test test_prices.py
+ legacy/discount.m changedpack에는 위에서부터 실패한 명령과 그 출력, Git에서 아직 커밋하지 않은 변경, 오류가 5번째 줄을 가리킨 test_prices.py, 그 테스트가 호출하는 prices.py, 내가 고친 legacy/discount.m이 들어갑니다. 전체 내용은 출력 형식에서 볼 수 있습니다.