codigest 0.3.1__tar.gz → 0.3.3__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 (31) hide show
  1. {codigest-0.3.1 → codigest-0.3.3}/.github/workflows/publish.yml +3 -3
  2. codigest-0.3.3/PKG-INFO +199 -0
  3. codigest-0.3.3/README.md +174 -0
  4. {codigest-0.3.1 → codigest-0.3.3}/pyproject.toml +3 -2
  5. codigest-0.3.3/src/codigest/__main__.py +4 -0
  6. {codigest-0.3.1 → codigest-0.3.3}/src/codigest/commands/diff.py +13 -4
  7. {codigest-0.3.1 → codigest-0.3.3}/src/codigest/commands/digest.py +4 -8
  8. {codigest-0.3.1 → codigest-0.3.3}/src/codigest/commands/init.py +11 -1
  9. codigest-0.3.3/src/codigest/commands/scan.py +230 -0
  10. {codigest-0.3.1 → codigest-0.3.3}/src/codigest/commands/semdiff.py +24 -20
  11. {codigest-0.3.1 → codigest-0.3.3}/src/codigest/commands/tree.py +20 -22
  12. {codigest-0.3.1 → codigest-0.3.3}/src/codigest/core/prompts.py +89 -78
  13. codigest-0.3.3/src/codigest/core/resolver.py +107 -0
  14. {codigest-0.3.1 → codigest-0.3.3}/src/codigest/core/scanner.py +40 -8
  15. {codigest-0.3.1 → codigest-0.3.3}/src/codigest/core/semdiff.py +1 -1
  16. {codigest-0.3.1 → codigest-0.3.3}/src/codigest/core/shadow.py +39 -24
  17. codigest-0.3.3/src/codigest/core/tags.py +38 -0
  18. {codigest-0.3.1 → codigest-0.3.3}/src/codigest/main.py +1 -1
  19. {codigest-0.3.1 → codigest-0.3.3}/uv.lock +1 -1
  20. codigest-0.3.1/PKG-INFO +0 -176
  21. codigest-0.3.1/README.md +0 -151
  22. codigest-0.3.1/src/codigest/commands/scan.py +0 -142
  23. codigest-0.3.1/src/codigest/core/tags.py +0 -75
  24. {codigest-0.3.1 → codigest-0.3.3}/.gitignore +0 -0
  25. {codigest-0.3.1 → codigest-0.3.3}/.python-version +0 -0
  26. {codigest-0.3.1 → codigest-0.3.3}/src/codigest/__init__.py +0 -0
  27. {codigest-0.3.1 → codigest-0.3.3}/src/codigest/config.py +0 -0
  28. {codigest-0.3.1 → codigest-0.3.3}/src/codigest/core/git_ops.py +0 -0
  29. {codigest-0.3.1 → codigest-0.3.3}/src/codigest/core/processor.py +0 -0
  30. {codigest-0.3.1 → codigest-0.3.3}/src/codigest/core/structure.py +0 -0
  31. {codigest-0.3.1 → codigest-0.3.3}/src/codigest/core/tokenizer.py +0 -0
@@ -19,15 +19,15 @@ jobs:
19
19
  steps:
20
20
  - uses: actions/checkout@v4
21
21
 
22
- # [변경] uv 설치 (가장 빠르고 확실한 방법)
22
+ # uv 설치 (가장 빠르고 확실한 방법)
23
23
  - name: Install uv
24
24
  uses: astral-sh/setup-uv@v5
25
25
 
26
- # [변경] Python 3.14 설정 (uv 이용)
26
+ # Python 3.14 설정 (uv 이용)
27
27
  - name: Set up Python
28
28
  run: uv python install 3.14
29
29
 
30
- # [변경] 의존성 설치 및 빌드 (uv build 하나로 해결)
30
+ # 의존성 설치 및 빌드 (uv build 하나로 해결)
31
31
  - name: Build package
32
32
  run: uv build
33
33
 
@@ -0,0 +1,199 @@
1
+ Metadata-Version: 2.4
2
+ Name: codigest
3
+ Version: 0.3.3
4
+ Summary: Human-Centered Codebase Context Manager for LLMs
5
+ Project-URL: Homepage, https://github.com/SJB777/codigest
6
+ Project-URL: Repository, https://github.com/SJB777/codigest
7
+ Project-URL: Issues, https://github.com/SJB777/codigest/issues
8
+ Author-email: Codigest Team <sngd024@google.com>
9
+ License: MIT
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.14
15
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Classifier: Topic :: Utilities
17
+ Requires-Python: >=3.14
18
+ Requires-Dist: loguru
19
+ Requires-Dist: pathspec
20
+ Requires-Dist: pyperclip
21
+ Requires-Dist: rich
22
+ Requires-Dist: tomli-w
23
+ Requires-Dist: typer
24
+ Description-Content-Type: text/markdown
25
+
26
+ # Codigest
27
+
28
+ **Codigest** is a standalone CLI tool designed to extract, structure, and track the context of your codebase for Large Language Models (LLMs).
29
+
30
+ Unlike simple copy-paste tools, Codigest employs a **Context Anchor** system (Shadow Git) to track changes locally without polluting your main version control history. It also features **Semantic Analysis** to detect structural changes in your code.
31
+
32
+ > **Note:** You can use the short alias **`cdg`** instead of `codigest` for faster typing.
33
+
34
+ ## Core Philosophy
35
+
36
+ * **Read-Only & Safe**: Codigest never modifies your source code. It only reads, analyzes, and formats context.
37
+ * **Context-Aware**: Instead of dumping raw text, it structures code into XML snapshots designed for LLM comprehension.
38
+ * **Session-Based Tracking**: It maintains an internal anchor to track "work-in-progress" changes independently of your Git commits.
39
+ * **Environment Isolated**: Runs in its own isolated Python 3.14 environment via `uv`, ensuring it never conflicts with your project's dependencies.
40
+
41
+ ## Installation
42
+
43
+ Codigest runs as a global tool. You don't need to add it to your project's `requirements.txt`.
44
+ We strongly recommend using **uv** for the best experience.
45
+
46
+ ### Step 1: Install `uv`
47
+
48
+ If you don't have `uv` installed, use **Winget** (Windows) or curl (macOS/Linux).
49
+
50
+ ```powershell
51
+ # Windows (via Winget)
52
+ winget install --id astral-sh.uv
53
+
54
+ # macOS/Linux
55
+ curl -LsSf [https://astral.sh/uv/install.sh](https://astral.sh/uv/install.sh) | sh
56
+
57
+ ```
58
+
59
+ ### Step 2: Install `codigest`
60
+
61
+ Install Codigest globally. `uv` will automatically manage the required Python 3.14 environment for you.
62
+
63
+ ```bash
64
+ uv tool install codigest
65
+ ```
66
+
67
+ ### Step 3: Update Path (Important!)
68
+
69
+ To run `codigest` (or `cdg`) from any terminal, ensure your tools directory is in your PATH.
70
+
71
+ ```bash
72
+ uv tool update-shell
73
+ ```
74
+
75
+ *> **Note:** Restart your terminal (or VS Code) after this step to apply changes.*
76
+
77
+ ---
78
+
79
+ ## Workflow & Commands
80
+
81
+ Once installed, use the **`cdg`** command anywhere.
82
+
83
+ ### 1. Initialization
84
+
85
+ Sets up the `.codigest` directory and captures the initial baseline anchor.
86
+
87
+ ```bash
88
+ cdg init
89
+ ```
90
+
91
+ ### 2. Full Context Snapshot (`scan`)
92
+
93
+ Scans the codebase and generates a structured XML snapshot. Includes a **Pre-flight Check** to prevent accidental token overflow.
94
+
95
+ * **Output:** `.codigest/snapshot.xml`
96
+ * **Features:**
97
+ * **Smart Confirmation:** Automatically skips confirmation for small contexts, but warns you for large ones (>30k tokens).
98
+ * **Dependency Resolution (`-r`):** Automatically finds and includes local files imported by your target files.
99
+ * **Scope Control:** You can specify folders or files to scan.
100
+
101
+
102
+
103
+ ```bash
104
+ # Basic scan (Interactive confirmation if large)
105
+ cdg scan
106
+
107
+ # Scan specific folder with dependency resolution (Smart Context)
108
+ cdg scan src/main.py -r
109
+
110
+ # Force execution without confirmation (Good for CI/CD)
111
+ cdg scan -y --message "Automated snapshot"
112
+ ```
113
+
114
+ ### 3. Incremental Changes (`diff`)
115
+
116
+ Tracks text-based changes between the last `scan` and the current working tree.
117
+
118
+ * **Output:** `.codigest/changes.diff`
119
+ * **Use Case:** "I modified 3 files. Here is exactly what changed since the last snapshot."
120
+ * **Note:** Checks against the internal Shadow Git, enabling tracking without committing to the real Git.
121
+
122
+ ```bash
123
+ cdg diff
124
+ ```
125
+
126
+ ### 4. Semantic Analysis (`semdiff`)
127
+
128
+ Analyzes **structural changes** (AST-based) rather than line-by-line text differences.
129
+
130
+ * **Output:** `.codigest/semdiff.xml`
131
+ * **Use Case:** "I refactored the API. Show me added/removed functions or signature changes."
132
+ * **Benefit:** Reduces token usage by ignoring formatting/comment changes.
133
+
134
+ ```bash
135
+ cdg semdiff
136
+ ```
137
+
138
+ ### 5. Project Tree (`tree`)
139
+
140
+ Visualizes the project structure. Respects `.gitignore`.
141
+
142
+ * **Style:** Professional, cleaner output without emojis for better readability.
143
+ * **Use Case:** Quickly verifying which files are being tracked.
144
+
145
+ ```bash
146
+ cdg tree
147
+ ```
148
+
149
+ ### 6. Architecture Digest (`digest`)
150
+
151
+ Generates a high-level outline of the project structure (Classes, Functions, Methods only).
152
+
153
+ * **Output:** `.codigest/digest.xml`
154
+ * **Use Case:** "Don't read the implementation details. Just understand the class hierarchy."
155
+
156
+ ```bash
157
+ cdg digest
158
+ ```
159
+
160
+ ---
161
+
162
+ ## Configuration
163
+
164
+ You can customize behavior in `.codigest/config.toml`.
165
+
166
+ ```toml
167
+ [filter]
168
+ # Target extensions
169
+ extensions = [".py", ".ts", ".rs", ".md", ".json"]
170
+
171
+ # Exclude patterns (Gitignore syntax)
172
+ exclude_patterns = [
173
+ "*.lock",
174
+ "tests/data/",
175
+ "legacy_code/"
176
+ ]
177
+
178
+ [output]
179
+ format = "xml"
180
+ ```
181
+
182
+ ## Architecture Details
183
+
184
+ **Context Anchor (Shadow Git)**
185
+ Codigest maintains a hidden, lightweight Git repository inside `.codigest/anchor/.shadow_git`.
186
+
187
+ * It is renamed to `.shadow_git` to prevent VS Code and other IDEs from confusing it with your project's actual repository.
188
+ * When you run `scan`, the current state is committed to this anchor.
189
+ * When you run `diff`, the tool compares your working directory against this anchor.
190
+
191
+ **Safety Mechanisms**
192
+
193
+ * **Pre-flight Check:** Calculates estimated token count before processing to prevent context overflow errors.
194
+ * **Structure-Aware Dedent:** Ensures XML tags are perfectly aligned (flush-left) to prevent indentation artifacts in LLM prompts.
195
+ * **XML Injection Protection:** Automatically escapes content within XML tags.
196
+
197
+ ## License
198
+
199
+ MIT License
@@ -0,0 +1,174 @@
1
+ # Codigest
2
+
3
+ **Codigest** is a standalone CLI tool designed to extract, structure, and track the context of your codebase for Large Language Models (LLMs).
4
+
5
+ Unlike simple copy-paste tools, Codigest employs a **Context Anchor** system (Shadow Git) to track changes locally without polluting your main version control history. It also features **Semantic Analysis** to detect structural changes in your code.
6
+
7
+ > **Note:** You can use the short alias **`cdg`** instead of `codigest` for faster typing.
8
+
9
+ ## Core Philosophy
10
+
11
+ * **Read-Only & Safe**: Codigest never modifies your source code. It only reads, analyzes, and formats context.
12
+ * **Context-Aware**: Instead of dumping raw text, it structures code into XML snapshots designed for LLM comprehension.
13
+ * **Session-Based Tracking**: It maintains an internal anchor to track "work-in-progress" changes independently of your Git commits.
14
+ * **Environment Isolated**: Runs in its own isolated Python 3.14 environment via `uv`, ensuring it never conflicts with your project's dependencies.
15
+
16
+ ## Installation
17
+
18
+ Codigest runs as a global tool. You don't need to add it to your project's `requirements.txt`.
19
+ We strongly recommend using **uv** for the best experience.
20
+
21
+ ### Step 1: Install `uv`
22
+
23
+ If you don't have `uv` installed, use **Winget** (Windows) or curl (macOS/Linux).
24
+
25
+ ```powershell
26
+ # Windows (via Winget)
27
+ winget install --id astral-sh.uv
28
+
29
+ # macOS/Linux
30
+ curl -LsSf [https://astral.sh/uv/install.sh](https://astral.sh/uv/install.sh) | sh
31
+
32
+ ```
33
+
34
+ ### Step 2: Install `codigest`
35
+
36
+ Install Codigest globally. `uv` will automatically manage the required Python 3.14 environment for you.
37
+
38
+ ```bash
39
+ uv tool install codigest
40
+ ```
41
+
42
+ ### Step 3: Update Path (Important!)
43
+
44
+ To run `codigest` (or `cdg`) from any terminal, ensure your tools directory is in your PATH.
45
+
46
+ ```bash
47
+ uv tool update-shell
48
+ ```
49
+
50
+ *> **Note:** Restart your terminal (or VS Code) after this step to apply changes.*
51
+
52
+ ---
53
+
54
+ ## Workflow & Commands
55
+
56
+ Once installed, use the **`cdg`** command anywhere.
57
+
58
+ ### 1. Initialization
59
+
60
+ Sets up the `.codigest` directory and captures the initial baseline anchor.
61
+
62
+ ```bash
63
+ cdg init
64
+ ```
65
+
66
+ ### 2. Full Context Snapshot (`scan`)
67
+
68
+ Scans the codebase and generates a structured XML snapshot. Includes a **Pre-flight Check** to prevent accidental token overflow.
69
+
70
+ * **Output:** `.codigest/snapshot.xml`
71
+ * **Features:**
72
+ * **Smart Confirmation:** Automatically skips confirmation for small contexts, but warns you for large ones (>30k tokens).
73
+ * **Dependency Resolution (`-r`):** Automatically finds and includes local files imported by your target files.
74
+ * **Scope Control:** You can specify folders or files to scan.
75
+
76
+
77
+
78
+ ```bash
79
+ # Basic scan (Interactive confirmation if large)
80
+ cdg scan
81
+
82
+ # Scan specific folder with dependency resolution (Smart Context)
83
+ cdg scan src/main.py -r
84
+
85
+ # Force execution without confirmation (Good for CI/CD)
86
+ cdg scan -y --message "Automated snapshot"
87
+ ```
88
+
89
+ ### 3. Incremental Changes (`diff`)
90
+
91
+ Tracks text-based changes between the last `scan` and the current working tree.
92
+
93
+ * **Output:** `.codigest/changes.diff`
94
+ * **Use Case:** "I modified 3 files. Here is exactly what changed since the last snapshot."
95
+ * **Note:** Checks against the internal Shadow Git, enabling tracking without committing to the real Git.
96
+
97
+ ```bash
98
+ cdg diff
99
+ ```
100
+
101
+ ### 4. Semantic Analysis (`semdiff`)
102
+
103
+ Analyzes **structural changes** (AST-based) rather than line-by-line text differences.
104
+
105
+ * **Output:** `.codigest/semdiff.xml`
106
+ * **Use Case:** "I refactored the API. Show me added/removed functions or signature changes."
107
+ * **Benefit:** Reduces token usage by ignoring formatting/comment changes.
108
+
109
+ ```bash
110
+ cdg semdiff
111
+ ```
112
+
113
+ ### 5. Project Tree (`tree`)
114
+
115
+ Visualizes the project structure. Respects `.gitignore`.
116
+
117
+ * **Style:** Professional, cleaner output without emojis for better readability.
118
+ * **Use Case:** Quickly verifying which files are being tracked.
119
+
120
+ ```bash
121
+ cdg tree
122
+ ```
123
+
124
+ ### 6. Architecture Digest (`digest`)
125
+
126
+ Generates a high-level outline of the project structure (Classes, Functions, Methods only).
127
+
128
+ * **Output:** `.codigest/digest.xml`
129
+ * **Use Case:** "Don't read the implementation details. Just understand the class hierarchy."
130
+
131
+ ```bash
132
+ cdg digest
133
+ ```
134
+
135
+ ---
136
+
137
+ ## Configuration
138
+
139
+ You can customize behavior in `.codigest/config.toml`.
140
+
141
+ ```toml
142
+ [filter]
143
+ # Target extensions
144
+ extensions = [".py", ".ts", ".rs", ".md", ".json"]
145
+
146
+ # Exclude patterns (Gitignore syntax)
147
+ exclude_patterns = [
148
+ "*.lock",
149
+ "tests/data/",
150
+ "legacy_code/"
151
+ ]
152
+
153
+ [output]
154
+ format = "xml"
155
+ ```
156
+
157
+ ## Architecture Details
158
+
159
+ **Context Anchor (Shadow Git)**
160
+ Codigest maintains a hidden, lightweight Git repository inside `.codigest/anchor/.shadow_git`.
161
+
162
+ * It is renamed to `.shadow_git` to prevent VS Code and other IDEs from confusing it with your project's actual repository.
163
+ * When you run `scan`, the current state is committed to this anchor.
164
+ * When you run `diff`, the tool compares your working directory against this anchor.
165
+
166
+ **Safety Mechanisms**
167
+
168
+ * **Pre-flight Check:** Calculates estimated token count before processing to prevent context overflow errors.
169
+ * **Structure-Aware Dedent:** Ensures XML tags are perfectly aligned (flush-left) to prevent indentation artifacts in LLM prompts.
170
+ * **XML Injection Protection:** Automatically escapes content within XML tags.
171
+
172
+ ## License
173
+
174
+ MIT License
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "codigest"
3
- version = "0.3.1"
3
+ version = "0.3.3"
4
4
  description = "Human-Centered Codebase Context Manager for LLMs"
5
5
  authors = [{name = "Codigest Team", email = "sngd024@google.com"}]
6
6
  readme = "README.md"
@@ -32,7 +32,8 @@ Issues = "https://github.com/SJB777/codigest/issues"
32
32
 
33
33
  [project.scripts]
34
34
  codigest = "codigest.main:app"
35
+ cdg = "codigest.main:app"
35
36
 
36
37
  [build-system]
37
38
  requires = ["hatchling"]
38
- build-backend = "hatchling.build"
39
+ build-backend = "hatchling.build"
@@ -0,0 +1,4 @@
1
+ from .main import main
2
+
3
+ if __name__ == "__main__":
4
+ main()
@@ -12,6 +12,15 @@ console = Console()
12
12
 
13
13
  @app.callback(invoke_without_command=True)
14
14
  def handle(
15
+ # target 인자 추가
16
+ target: Path = typer.Argument(
17
+ Path.cwd(),
18
+ help="Target directory to check diff",
19
+ exists=True,
20
+ file_okay=False,
21
+ dir_okay=True,
22
+ resolve_path=True
23
+ ),
15
24
  copy: bool = typer.Option(True, help="Auto-copy to clipboard"),
16
25
  save: bool = typer.Option(True, help="Save to .codigest/changes.diff"),
17
26
  message: str = typer.Option("", "--message", "-m", help="Add specific instruction context"),
@@ -20,13 +29,13 @@ def handle(
20
29
  [Context Update] Shows changes since the last 'codigest scan'.
21
30
  Useful for updating LLM context without re-uploading everything.
22
31
  """
23
- root_path = Path.cwd()
32
+ root_path = target
24
33
  anchor = shadow.ContextAnchor(root_path)
25
34
 
26
35
  # 1. Check Baseline Existence
27
36
  last_update = anchor.get_last_update_time()
28
37
  if last_update == "Never":
29
- console.print("[yellow]⚠️ No scan history found.[/yellow]")
38
+ console.print("[yellow]No scan history found.[/yellow]")
30
39
  console.print(" Run [bold cyan]codigest scan[/bold cyan] first to establish a baseline.")
31
40
  raise typer.Exit(1)
32
41
 
@@ -75,10 +84,10 @@ def handle(
75
84
 
76
85
  if copy:
77
86
  pyperclip.copy(formatted_diff)
78
- console.print("[dim]📋 Copied to clipboard[/dim]")
87
+ console.print("[dim]Copied to clipboard[/dim]")
79
88
 
80
89
  if save:
81
90
  out_path = root_path / ".codigest" / "changes.diff"
82
91
  out_path.parent.mkdir(exist_ok=True)
83
92
  out_path.write_text(formatted_diff, encoding="utf-8")
84
- console.print(f"[dim]💾 Saved to {out_path}[/dim]")
93
+ console.print(f"[dim]Saved to {out_path}[/dim]")
@@ -49,11 +49,7 @@ def handle(
49
49
 
50
50
  if summary:
51
51
  rel_path = file_path.relative_to(root_path).as_posix()
52
- block = tags.xml(t"""
53
- <file path="{rel_path}">
54
- {summary}
55
- </file>
56
- """)
52
+ block = tags.file(rel_path, summary)
57
53
  summary_blocks.append(block)
58
54
  except Exception:
59
55
  continue
@@ -69,7 +65,7 @@ def handle(
69
65
  instruction=message
70
66
  )
71
67
  except Exception as e:
72
- console.print(f"[red]❌ Rendering Failed:[/red] {e}")
68
+ console.print(f"[red]Rendering Failed:[/red] {e}")
73
69
  raise typer.Exit(1)
74
70
 
75
71
  progress.update(task, completed=100)
@@ -79,10 +75,10 @@ def handle(
79
75
 
80
76
  if copy:
81
77
  pyperclip.copy(digest_content)
82
- console.print("[dim]📋 Copied to clipboard[/dim]")
78
+ console.print("[dim]Copied to clipboard[/dim]")
83
79
 
84
80
  if save:
85
81
  out_path = root_path / ".codigest" / "digest.xml"
86
82
  out_path.parent.mkdir(exist_ok=True)
87
83
  out_path.write_text(digest_content, encoding="utf-8")
88
- console.print(f"[dim]💾 Saved to {out_path}[/dim]")
84
+ console.print(f"[dim]Saved to {out_path}[/dim]")
@@ -35,12 +35,22 @@ structure = "toon"
35
35
 
36
36
  @app.callback(invoke_without_command=True)
37
37
  def handle(
38
+ # target 인자 추가 (기본값: 현재 위치)
39
+ target: Path = typer.Argument(
40
+ Path.cwd(),
41
+ help="Target directory to initialize",
42
+ exists=True,
43
+ file_okay=False,
44
+ dir_okay=True,
45
+ resolve_path=True
46
+ ),
38
47
  force: bool = typer.Option(False, "--force", "-f", help="Overwrite existing config"),
39
48
  ):
40
49
  """
41
50
  Initialize the .codigest environment and capture the initial state.
42
51
  """
43
- root_path = Path.cwd()
52
+ root_path = target # Typer가 이미 resolve_path=True로 절대경로 변환해줌
53
+
44
54
  config_dir = root_path / ".codigest"
45
55
  config_file = config_dir / "config.toml"
46
56
  gitignore_file = root_path / ".gitignore"