codiff 0.1.1__tar.gz → 0.1.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.
- {codiff-0.1.1 → codiff-0.1.2}/PKG-INFO +84 -47
- {codiff-0.1.1 → codiff-0.1.2}/README.md +83 -46
- {codiff-0.1.1 → codiff-0.1.2}/codiff/cli.py +33 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/diff/indexer.py +9 -1
- {codiff-0.1.1 → codiff-0.1.2}/codiff/export/mermaid.py +14 -1
- {codiff-0.1.1 → codiff-0.1.2}/codiff/utils/args.py +1 -1
- {codiff-0.1.1 → codiff-0.1.2}/codiff.egg-info/PKG-INFO +84 -47
- {codiff-0.1.1 → codiff-0.1.2}/pyproject.toml +1 -1
- {codiff-0.1.1 → codiff-0.1.2}/LICENSE +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/__init__.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/__main__.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/db/__init__.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/db/engine.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/db/models.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/db/operations.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/diff/__init__.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/diff/analysis.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/diff/differ.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/diff/engine.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/diff/snapshot.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/export/__init__.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/export/json.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/export/terminal.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/languages/__init__.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/languages/parser.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/languages/python/__init__.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/languages/python/parser.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/languages/python/resolver.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/languages/repository.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/languages/resolver.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/languages/typescript/__init__.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/languages/typescript/parser.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/languages/typescript/resolver.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/mcp_server.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/schema/__init__.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/schema/diff.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/schema/parsing.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/setup.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/utils/__init__.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/utils/files.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/utils/git.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/utils/instructions.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/utils/instructions.yaml +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff/utils/terminal.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff.egg-info/SOURCES.txt +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff.egg-info/dependency_links.txt +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff.egg-info/entry_points.txt +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff.egg-info/requires.txt +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/codiff.egg-info/top_level.txt +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/setup.cfg +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/tests/test_call_patterns.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/tests/test_call_resolver.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/tests/test_cli.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/tests/test_code_parser.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/tests/test_db.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/tests/test_diff.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/tests/test_export_json.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/tests/test_export_mermaid.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/tests/test_export_terminal.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/tests/test_indexer.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/tests/test_setup.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/tests/test_snapshot.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/tests/test_ts_integration.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/tests/test_ts_parser.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/tests/test_ts_resolver.py +0 -0
- {codiff-0.1.1 → codiff-0.1.2}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codiff
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Structural call-graph diff for codebases, built for coding agents
|
|
5
5
|
Author-email: Issa Hammoud <issa.hammoud@outlook.com>
|
|
6
6
|
License: Apache License
|
|
@@ -238,9 +238,87 @@ Dynamic: license-file
|
|
|
238
238
|
|
|
239
239
|
# codiff
|
|
240
240
|
|
|
241
|
-
A structural call-graph diff tool for multi-language codebases, built to work with coding agents.
|
|
241
|
+
A structural call-graph diff tool for multi-language codebases, built to work with coding agents.
|
|
242
242
|
|
|
243
|
-
|
|
243
|
+
Instead of a line diff, codiff shows what changed **at the function level**: which functions were added and where they hook into existing code, which were modified, which were removed — with call relationships mapped across files.
|
|
244
|
+
|
|
245
|
+
No LLM, no embeddings, fully offline.
|
|
246
|
+
|
|
247
|
+
## Supported languages
|
|
248
|
+
|
|
249
|
+
| Language | Extensions |
|
|
250
|
+
|---|---|
|
|
251
|
+
| Python | `.py` |
|
|
252
|
+
| TypeScript | `.ts`, `.tsx` |
|
|
253
|
+
|
|
254
|
+
## Installation
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
pip install codiff
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Quickstart
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
# Run from inside any git repository
|
|
264
|
+
codiff diff
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
This compares your working tree against `HEAD`. If everything is already committed, use `--base` and `--head` to compare two refs explicitly:
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
# Diff between two branches
|
|
271
|
+
codiff diff --base main --head my-feature
|
|
272
|
+
|
|
273
|
+
# Diff introduced by the last commit only
|
|
274
|
+
codiff diff --base HEAD~1 --head HEAD
|
|
275
|
+
|
|
276
|
+
# Diff between two arbitrary commits
|
|
277
|
+
codiff diff --base a1b2c3d --head e4f5g6h
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
To get a Mermaid diagram (useful for PR descriptions):
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
codiff diff --base main --format mermaid
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
To save the diagram to a file and preview it:
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
codiff diff --base main --format mermaid > mermaid.md
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
Open `mermaid.md` in any Markdown previewer (VS Code, GitHub, etc.) to visualise the diagram.
|
|
293
|
+
|
|
294
|
+
## Agent integration (MCP)
|
|
295
|
+
|
|
296
|
+
Run once per project to wire codiff into your coding agent:
|
|
297
|
+
|
|
298
|
+
```bash
|
|
299
|
+
codiff init --agent claude # Claude Code
|
|
300
|
+
codiff init --agent codex # OpenAI Codex CLI
|
|
301
|
+
codiff init --agent gemini # Gemini CLI
|
|
302
|
+
codiff init --agent vibe # Mistral Vibe
|
|
303
|
+
codiff init --agent github-actions # GitHub Actions
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
This writes the MCP server config and a project instructions file that tells the agent to call `codiff_diff` when creating pull requests. The agent then automatically embeds a structural diagram in every PR description.
|
|
307
|
+
|
|
308
|
+
The `github-actions` option creates `.github/workflows/codiff.yml`, which posts the diagram as a PR comment on every pull request — no AI coding agent required.
|
|
309
|
+
|
|
310
|
+
> **Note:** Use either an agent integration or the GitHub Action, not both. If both are active, codiff detects the redundancy automatically and the action stays silent when the agent has already embedded a diagram in the PR description.
|
|
311
|
+
|
|
312
|
+
| Agent | MCP config | Instructions file |
|
|
313
|
+
|---|---|---|
|
|
314
|
+
| `claude` | `.mcp.json` | `CLAUDE.md` |
|
|
315
|
+
| `codex` | `.codex/config.toml` | `AGENTS.md` |
|
|
316
|
+
| `gemini` | `~/.gemini/settings.json` | `GEMINI.md` |
|
|
317
|
+
| `vibe` | `~/.vibe/config.toml` | — |
|
|
318
|
+
| `github-actions` | — | `.github/workflows/codiff.yml` |
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
Here's the output of `codiff diff --base b8dde67 --head d25c385 --format mermaid` run on codiff's own codebase:
|
|
244
322
|
|
|
245
323
|
```mermaid
|
|
246
324
|
%%{init: {'layout': 'elk', 'elk': {'direction': 'RIGHT'}, 'maxTextSize': 999999, 'theme': 'base', 'themeVariables': {'background': '#ffffff', 'clusterBkg': '#f8fafc', 'clusterBorder': '#94a3b8', 'primaryColor': '#f8fafc', 'primaryBorderColor': '#94a3b8', 'primaryTextColor': '#1e293b', 'lineColor': '#64748b', 'fontSize': '13px', 'fontFamily': 'ui-monospace, SFMono-Regular, Menlo, monospace'}}}%%
|
|
@@ -321,58 +399,18 @@ classDiagram
|
|
|
321
399
|
|
|
322
400
|
Each box is a file or class. **Green** = only additions, **yellow** = at least one modification. Inside each box: `+` added function, `~` modified. Annotations: `sig` = signature changed, `calls +N−N` = now calls N more / N fewer functions. Arrows show which files call into which.
|
|
323
401
|
|
|
324
|
-
## Supported languages
|
|
325
|
-
|
|
326
|
-
| Language | Extensions |
|
|
327
|
-
|---|---|
|
|
328
|
-
| Python | `.py` |
|
|
329
|
-
| TypeScript | `.ts`, `.tsx` |
|
|
330
|
-
|
|
331
402
|
## How it works
|
|
332
403
|
|
|
333
404
|
codiff maintains a SQLite call-graph index (`.codiff.db`) at the repo root. On first run it does a full parse; on subsequent runs it re-parses only the files changed since the last indexed commit, then detects stale callers (functions whose callees were renamed or deleted) and re-parses those too. Both the base and head snapshots are built incrementally from this index, so diffs stay fast even on large codebases.
|
|
334
405
|
|
|
335
|
-
The graph delta — added, modified, removed functions — is computed deterministically from the resolved call graph.
|
|
406
|
+
The graph delta — added, modified, removed functions — is computed deterministically from the resolved call graph.
|
|
336
407
|
|
|
337
408
|
## Requirements
|
|
338
409
|
|
|
339
410
|
- Python 3.11+
|
|
340
411
|
- Git
|
|
341
412
|
|
|
342
|
-
##
|
|
343
|
-
|
|
344
|
-
```bash
|
|
345
|
-
pip install codiff
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
## Usage
|
|
349
|
-
|
|
350
|
-
### Agent integration (MCP + project instructions)
|
|
351
|
-
|
|
352
|
-
Run once per project to configure your coding agent:
|
|
353
|
-
|
|
354
|
-
```bash
|
|
355
|
-
codiff init --agent claude # Claude Code
|
|
356
|
-
codiff init --agent codex # OpenAI Codex CLI
|
|
357
|
-
codiff init --agent gemini # Gemini CLI
|
|
358
|
-
codiff init --agent vibe # Mistral Vibe
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
Each command writes the MCP server config and a project instructions file telling the agent to use the `codiff_diff` MCP tool when creating pull requests:
|
|
362
|
-
|
|
363
|
-
| Agent | MCP config | Instructions file |
|
|
364
|
-
|---|---|---|
|
|
365
|
-
| `claude` | `.mcp.json` | `CLAUDE.md` |
|
|
366
|
-
| `codex` | `.codex/config.toml` | `AGENTS.md` |
|
|
367
|
-
| `gemini` | `~/.gemini/settings.json` ¹ | `GEMINI.md` |
|
|
368
|
-
| `vibe` | `~/.vibe/config.toml` ² | — |
|
|
369
|
-
|
|
370
|
-
¹ Gemini CLI MCP config is global (not project-scoped). Restart Gemini CLI after running.
|
|
371
|
-
² Mistral Vibe MCP config is global (not project-scoped). Restart Vibe after running.
|
|
372
|
-
|
|
373
|
-
When creating a pull request, the agent calls `codiff_diff(base_ref="main", head_ref="HEAD", format="mermaid")` and embeds the returned diagram in the PR description. GitHub renders Mermaid natively — no plugin needed.
|
|
374
|
-
|
|
375
|
-
### CLI
|
|
413
|
+
## CLI reference
|
|
376
414
|
|
|
377
415
|
```bash
|
|
378
416
|
# Index a repository (writes .codiff.db — runs automatically on first diff)
|
|
@@ -390,7 +428,7 @@ codiff diff --include-deleted # include deleted functions (hidden by defa
|
|
|
390
428
|
codiff diff --workers 8 # set parallel worker count (default: cpu_count // 2)
|
|
391
429
|
codiff diff --debug # print timing breakdown for each processing step
|
|
392
430
|
|
|
393
|
-
# Configure a coding agent
|
|
431
|
+
# Configure a coding agent
|
|
394
432
|
codiff init --agent <agent>
|
|
395
433
|
```
|
|
396
434
|
|
|
@@ -402,7 +440,6 @@ codiff init --agent <agent>
|
|
|
402
440
|
| `mermaid` | Two Mermaid `classDiagram` blocks — paste into any Markdown file or PR description |
|
|
403
441
|
| `json` | Structured JSON — consumed by editor integrations (e.g. the VS Code extension) |
|
|
404
442
|
|
|
405
|
-
|
|
406
443
|
## Reading the terminal output
|
|
407
444
|
|
|
408
445
|
The output shows one box per changed file. Boxes are laid out side by side when they fit the terminal width, with labeled arrows between adjacent connected boxes.
|
|
@@ -1,8 +1,86 @@
|
|
|
1
1
|
# codiff
|
|
2
2
|
|
|
3
|
-
A structural call-graph diff tool for multi-language codebases, built to work with coding agents.
|
|
3
|
+
A structural call-graph diff tool for multi-language codebases, built to work with coding agents.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Instead of a line diff, codiff shows what changed **at the function level**: which functions were added and where they hook into existing code, which were modified, which were removed — with call relationships mapped across files.
|
|
6
|
+
|
|
7
|
+
No LLM, no embeddings, fully offline.
|
|
8
|
+
|
|
9
|
+
## Supported languages
|
|
10
|
+
|
|
11
|
+
| Language | Extensions |
|
|
12
|
+
|---|---|
|
|
13
|
+
| Python | `.py` |
|
|
14
|
+
| TypeScript | `.ts`, `.tsx` |
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install codiff
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quickstart
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Run from inside any git repository
|
|
26
|
+
codiff diff
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
This compares your working tree against `HEAD`. If everything is already committed, use `--base` and `--head` to compare two refs explicitly:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Diff between two branches
|
|
33
|
+
codiff diff --base main --head my-feature
|
|
34
|
+
|
|
35
|
+
# Diff introduced by the last commit only
|
|
36
|
+
codiff diff --base HEAD~1 --head HEAD
|
|
37
|
+
|
|
38
|
+
# Diff between two arbitrary commits
|
|
39
|
+
codiff diff --base a1b2c3d --head e4f5g6h
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
To get a Mermaid diagram (useful for PR descriptions):
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
codiff diff --base main --format mermaid
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
To save the diagram to a file and preview it:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
codiff diff --base main --format mermaid > mermaid.md
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Open `mermaid.md` in any Markdown previewer (VS Code, GitHub, etc.) to visualise the diagram.
|
|
55
|
+
|
|
56
|
+
## Agent integration (MCP)
|
|
57
|
+
|
|
58
|
+
Run once per project to wire codiff into your coding agent:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
codiff init --agent claude # Claude Code
|
|
62
|
+
codiff init --agent codex # OpenAI Codex CLI
|
|
63
|
+
codiff init --agent gemini # Gemini CLI
|
|
64
|
+
codiff init --agent vibe # Mistral Vibe
|
|
65
|
+
codiff init --agent github-actions # GitHub Actions
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
This writes the MCP server config and a project instructions file that tells the agent to call `codiff_diff` when creating pull requests. The agent then automatically embeds a structural diagram in every PR description.
|
|
69
|
+
|
|
70
|
+
The `github-actions` option creates `.github/workflows/codiff.yml`, which posts the diagram as a PR comment on every pull request — no AI coding agent required.
|
|
71
|
+
|
|
72
|
+
> **Note:** Use either an agent integration or the GitHub Action, not both. If both are active, codiff detects the redundancy automatically and the action stays silent when the agent has already embedded a diagram in the PR description.
|
|
73
|
+
|
|
74
|
+
| Agent | MCP config | Instructions file |
|
|
75
|
+
|---|---|---|
|
|
76
|
+
| `claude` | `.mcp.json` | `CLAUDE.md` |
|
|
77
|
+
| `codex` | `.codex/config.toml` | `AGENTS.md` |
|
|
78
|
+
| `gemini` | `~/.gemini/settings.json` | `GEMINI.md` |
|
|
79
|
+
| `vibe` | `~/.vibe/config.toml` | — |
|
|
80
|
+
| `github-actions` | — | `.github/workflows/codiff.yml` |
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
Here's the output of `codiff diff --base b8dde67 --head d25c385 --format mermaid` run on codiff's own codebase:
|
|
6
84
|
|
|
7
85
|
```mermaid
|
|
8
86
|
%%{init: {'layout': 'elk', 'elk': {'direction': 'RIGHT'}, 'maxTextSize': 999999, 'theme': 'base', 'themeVariables': {'background': '#ffffff', 'clusterBkg': '#f8fafc', 'clusterBorder': '#94a3b8', 'primaryColor': '#f8fafc', 'primaryBorderColor': '#94a3b8', 'primaryTextColor': '#1e293b', 'lineColor': '#64748b', 'fontSize': '13px', 'fontFamily': 'ui-monospace, SFMono-Regular, Menlo, monospace'}}}%%
|
|
@@ -83,58 +161,18 @@ classDiagram
|
|
|
83
161
|
|
|
84
162
|
Each box is a file or class. **Green** = only additions, **yellow** = at least one modification. Inside each box: `+` added function, `~` modified. Annotations: `sig` = signature changed, `calls +N−N` = now calls N more / N fewer functions. Arrows show which files call into which.
|
|
85
163
|
|
|
86
|
-
## Supported languages
|
|
87
|
-
|
|
88
|
-
| Language | Extensions |
|
|
89
|
-
|---|---|
|
|
90
|
-
| Python | `.py` |
|
|
91
|
-
| TypeScript | `.ts`, `.tsx` |
|
|
92
|
-
|
|
93
164
|
## How it works
|
|
94
165
|
|
|
95
166
|
codiff maintains a SQLite call-graph index (`.codiff.db`) at the repo root. On first run it does a full parse; on subsequent runs it re-parses only the files changed since the last indexed commit, then detects stale callers (functions whose callees were renamed or deleted) and re-parses those too. Both the base and head snapshots are built incrementally from this index, so diffs stay fast even on large codebases.
|
|
96
167
|
|
|
97
|
-
The graph delta — added, modified, removed functions — is computed deterministically from the resolved call graph.
|
|
168
|
+
The graph delta — added, modified, removed functions — is computed deterministically from the resolved call graph.
|
|
98
169
|
|
|
99
170
|
## Requirements
|
|
100
171
|
|
|
101
172
|
- Python 3.11+
|
|
102
173
|
- Git
|
|
103
174
|
|
|
104
|
-
##
|
|
105
|
-
|
|
106
|
-
```bash
|
|
107
|
-
pip install codiff
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
## Usage
|
|
111
|
-
|
|
112
|
-
### Agent integration (MCP + project instructions)
|
|
113
|
-
|
|
114
|
-
Run once per project to configure your coding agent:
|
|
115
|
-
|
|
116
|
-
```bash
|
|
117
|
-
codiff init --agent claude # Claude Code
|
|
118
|
-
codiff init --agent codex # OpenAI Codex CLI
|
|
119
|
-
codiff init --agent gemini # Gemini CLI
|
|
120
|
-
codiff init --agent vibe # Mistral Vibe
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
Each command writes the MCP server config and a project instructions file telling the agent to use the `codiff_diff` MCP tool when creating pull requests:
|
|
124
|
-
|
|
125
|
-
| Agent | MCP config | Instructions file |
|
|
126
|
-
|---|---|---|
|
|
127
|
-
| `claude` | `.mcp.json` | `CLAUDE.md` |
|
|
128
|
-
| `codex` | `.codex/config.toml` | `AGENTS.md` |
|
|
129
|
-
| `gemini` | `~/.gemini/settings.json` ¹ | `GEMINI.md` |
|
|
130
|
-
| `vibe` | `~/.vibe/config.toml` ² | — |
|
|
131
|
-
|
|
132
|
-
¹ Gemini CLI MCP config is global (not project-scoped). Restart Gemini CLI after running.
|
|
133
|
-
² Mistral Vibe MCP config is global (not project-scoped). Restart Vibe after running.
|
|
134
|
-
|
|
135
|
-
When creating a pull request, the agent calls `codiff_diff(base_ref="main", head_ref="HEAD", format="mermaid")` and embeds the returned diagram in the PR description. GitHub renders Mermaid natively — no plugin needed.
|
|
136
|
-
|
|
137
|
-
### CLI
|
|
175
|
+
## CLI reference
|
|
138
176
|
|
|
139
177
|
```bash
|
|
140
178
|
# Index a repository (writes .codiff.db — runs automatically on first diff)
|
|
@@ -152,7 +190,7 @@ codiff diff --include-deleted # include deleted functions (hidden by defa
|
|
|
152
190
|
codiff diff --workers 8 # set parallel worker count (default: cpu_count // 2)
|
|
153
191
|
codiff diff --debug # print timing breakdown for each processing step
|
|
154
192
|
|
|
155
|
-
# Configure a coding agent
|
|
193
|
+
# Configure a coding agent
|
|
156
194
|
codiff init --agent <agent>
|
|
157
195
|
```
|
|
158
196
|
|
|
@@ -164,7 +202,6 @@ codiff init --agent <agent>
|
|
|
164
202
|
| `mermaid` | Two Mermaid `classDiagram` blocks — paste into any Markdown file or PR description |
|
|
165
203
|
| `json` | Structured JSON — consumed by editor integrations (e.g. the VS Code extension) |
|
|
166
204
|
|
|
167
|
-
|
|
168
205
|
## Reading the terminal output
|
|
169
206
|
|
|
170
207
|
The output shows one box per changed file. Boxes are laid out side by side when they fit the terminal width, with labeled arrows between adjacent connected boxes.
|
|
@@ -200,11 +200,44 @@ def _init_vibe(repo_path: str) -> None:
|
|
|
200
200
|
print("\n Restart Vibe to load the new MCP server.\n")
|
|
201
201
|
|
|
202
202
|
|
|
203
|
+
_GITHUB_ACTIONS_WORKFLOW = """\
|
|
204
|
+
name: codiff
|
|
205
|
+
|
|
206
|
+
on:
|
|
207
|
+
pull_request:
|
|
208
|
+
types: [opened, synchronize, reopened]
|
|
209
|
+
|
|
210
|
+
jobs:
|
|
211
|
+
codiff:
|
|
212
|
+
runs-on: ubuntu-latest
|
|
213
|
+
permissions:
|
|
214
|
+
pull-requests: write
|
|
215
|
+
steps:
|
|
216
|
+
- uses: issahammoud/codiff-action@v1
|
|
217
|
+
"""
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def _init_github_actions(repo_path: str) -> None:
|
|
221
|
+
"""GitHub Actions: .github/workflows/codiff.yml"""
|
|
222
|
+
workflow_path = Path(repo_path) / ".github" / "workflows" / "codiff.yml"
|
|
223
|
+
label = ".github/workflows/codiff.yml"
|
|
224
|
+
|
|
225
|
+
if workflow_path.exists():
|
|
226
|
+
print(f" ~ {label:<30} codiff workflow already exists, skipped")
|
|
227
|
+
else:
|
|
228
|
+
workflow_path.parent.mkdir(parents=True, exist_ok=True)
|
|
229
|
+
workflow_path.write_text(_GITHUB_ACTIONS_WORKFLOW)
|
|
230
|
+
print(f" + {label:<30} created codiff workflow")
|
|
231
|
+
|
|
232
|
+
print("\n Commit and push .github/workflows/codiff.yml to activate the action.\n")
|
|
233
|
+
|
|
234
|
+
|
|
203
235
|
_INIT_AGENTS = {
|
|
204
236
|
"claude": _init_claude,
|
|
205
237
|
"codex": _init_codex,
|
|
206
238
|
"gemini": _init_gemini,
|
|
207
239
|
"vibe": _init_vibe,
|
|
240
|
+
"github-actions": _init_github_actions,
|
|
208
241
|
}
|
|
209
242
|
|
|
210
243
|
|
|
@@ -9,6 +9,7 @@ The only responsibilities here are:
|
|
|
9
9
|
|
|
10
10
|
import logging
|
|
11
11
|
import os
|
|
12
|
+
import subprocess
|
|
12
13
|
import tarfile
|
|
13
14
|
import tempfile
|
|
14
15
|
|
|
@@ -50,7 +51,14 @@ def ensure_indexed(repo_path: str, ref: str = "HEAD", max_workers: int = 4) -> s
|
|
|
50
51
|
_full_index(repo_path, db_path, ref, sha, max_workers=max_workers)
|
|
51
52
|
else:
|
|
52
53
|
logger.info("DB at %s — incremental update to %s", current[:8], sha[:8])
|
|
53
|
-
|
|
54
|
+
try:
|
|
55
|
+
_incremental_update_db(repo_path, db_path, current, sha, max_workers=max_workers)
|
|
56
|
+
except subprocess.CalledProcessError:
|
|
57
|
+
logger.warning(
|
|
58
|
+
"Incremental update failed (SHA %s unreachable) — falling back to full re-index",
|
|
59
|
+
current[:8],
|
|
60
|
+
)
|
|
61
|
+
_full_index(repo_path, db_path, ref, sha, max_workers=max_workers)
|
|
54
62
|
|
|
55
63
|
return sha
|
|
56
64
|
|
|
@@ -472,4 +472,17 @@ def render_mermaid(result: AnalysisResult) -> str:
|
|
|
472
472
|
_build_diagram(d1_body, d1_styles, d1_del, d1_del_styles, edge_lines),
|
|
473
473
|
_build_diagram(d2_body, d2_styles, d2_del, d2_del_styles, init=_INIT_GRID),
|
|
474
474
|
]
|
|
475
|
-
|
|
475
|
+
output = "\n\n".join(d for d in diagrams if d is not None)
|
|
476
|
+
if not output:
|
|
477
|
+
return output
|
|
478
|
+
|
|
479
|
+
s = result.summary
|
|
480
|
+
parts = (
|
|
481
|
+
([f"{s.added_functions} added"] if s.added_functions else [])
|
|
482
|
+
+ ([f"{s.modified_functions} modified"] if s.modified_functions else [])
|
|
483
|
+
+ ([f"{s.removed_functions} removed"] if s.removed_functions else [])
|
|
484
|
+
)
|
|
485
|
+
n = len(s.modules_touched)
|
|
486
|
+
summary = " · ".join(parts) + f" functions across {n} file{'s' if n != 1 else ''}"
|
|
487
|
+
output = f"{summary}\n\n{output}\n\n<!-- codiff-mermaid -->"
|
|
488
|
+
return output
|
|
@@ -5,7 +5,7 @@ import os
|
|
|
5
5
|
|
|
6
6
|
DEFAULT_WORKERS: int = max(1, (os.cpu_count() or 2) // 2)
|
|
7
7
|
|
|
8
|
-
SUPPORTED_AGENTS: list[str] = ["claude", "codex", "gemini", "vibe"]
|
|
8
|
+
SUPPORTED_AGENTS: list[str] = ["claude", "codex", "gemini", "vibe", "github-actions"]
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
def build_parser() -> argparse.ArgumentParser:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codiff
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Structural call-graph diff for codebases, built for coding agents
|
|
5
5
|
Author-email: Issa Hammoud <issa.hammoud@outlook.com>
|
|
6
6
|
License: Apache License
|
|
@@ -238,9 +238,87 @@ Dynamic: license-file
|
|
|
238
238
|
|
|
239
239
|
# codiff
|
|
240
240
|
|
|
241
|
-
A structural call-graph diff tool for multi-language codebases, built to work with coding agents.
|
|
241
|
+
A structural call-graph diff tool for multi-language codebases, built to work with coding agents.
|
|
242
242
|
|
|
243
|
-
|
|
243
|
+
Instead of a line diff, codiff shows what changed **at the function level**: which functions were added and where they hook into existing code, which were modified, which were removed — with call relationships mapped across files.
|
|
244
|
+
|
|
245
|
+
No LLM, no embeddings, fully offline.
|
|
246
|
+
|
|
247
|
+
## Supported languages
|
|
248
|
+
|
|
249
|
+
| Language | Extensions |
|
|
250
|
+
|---|---|
|
|
251
|
+
| Python | `.py` |
|
|
252
|
+
| TypeScript | `.ts`, `.tsx` |
|
|
253
|
+
|
|
254
|
+
## Installation
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
pip install codiff
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Quickstart
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
# Run from inside any git repository
|
|
264
|
+
codiff diff
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
This compares your working tree against `HEAD`. If everything is already committed, use `--base` and `--head` to compare two refs explicitly:
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
# Diff between two branches
|
|
271
|
+
codiff diff --base main --head my-feature
|
|
272
|
+
|
|
273
|
+
# Diff introduced by the last commit only
|
|
274
|
+
codiff diff --base HEAD~1 --head HEAD
|
|
275
|
+
|
|
276
|
+
# Diff between two arbitrary commits
|
|
277
|
+
codiff diff --base a1b2c3d --head e4f5g6h
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
To get a Mermaid diagram (useful for PR descriptions):
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
codiff diff --base main --format mermaid
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
To save the diagram to a file and preview it:
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
codiff diff --base main --format mermaid > mermaid.md
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
Open `mermaid.md` in any Markdown previewer (VS Code, GitHub, etc.) to visualise the diagram.
|
|
293
|
+
|
|
294
|
+
## Agent integration (MCP)
|
|
295
|
+
|
|
296
|
+
Run once per project to wire codiff into your coding agent:
|
|
297
|
+
|
|
298
|
+
```bash
|
|
299
|
+
codiff init --agent claude # Claude Code
|
|
300
|
+
codiff init --agent codex # OpenAI Codex CLI
|
|
301
|
+
codiff init --agent gemini # Gemini CLI
|
|
302
|
+
codiff init --agent vibe # Mistral Vibe
|
|
303
|
+
codiff init --agent github-actions # GitHub Actions
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
This writes the MCP server config and a project instructions file that tells the agent to call `codiff_diff` when creating pull requests. The agent then automatically embeds a structural diagram in every PR description.
|
|
307
|
+
|
|
308
|
+
The `github-actions` option creates `.github/workflows/codiff.yml`, which posts the diagram as a PR comment on every pull request — no AI coding agent required.
|
|
309
|
+
|
|
310
|
+
> **Note:** Use either an agent integration or the GitHub Action, not both. If both are active, codiff detects the redundancy automatically and the action stays silent when the agent has already embedded a diagram in the PR description.
|
|
311
|
+
|
|
312
|
+
| Agent | MCP config | Instructions file |
|
|
313
|
+
|---|---|---|
|
|
314
|
+
| `claude` | `.mcp.json` | `CLAUDE.md` |
|
|
315
|
+
| `codex` | `.codex/config.toml` | `AGENTS.md` |
|
|
316
|
+
| `gemini` | `~/.gemini/settings.json` | `GEMINI.md` |
|
|
317
|
+
| `vibe` | `~/.vibe/config.toml` | — |
|
|
318
|
+
| `github-actions` | — | `.github/workflows/codiff.yml` |
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
Here's the output of `codiff diff --base b8dde67 --head d25c385 --format mermaid` run on codiff's own codebase:
|
|
244
322
|
|
|
245
323
|
```mermaid
|
|
246
324
|
%%{init: {'layout': 'elk', 'elk': {'direction': 'RIGHT'}, 'maxTextSize': 999999, 'theme': 'base', 'themeVariables': {'background': '#ffffff', 'clusterBkg': '#f8fafc', 'clusterBorder': '#94a3b8', 'primaryColor': '#f8fafc', 'primaryBorderColor': '#94a3b8', 'primaryTextColor': '#1e293b', 'lineColor': '#64748b', 'fontSize': '13px', 'fontFamily': 'ui-monospace, SFMono-Regular, Menlo, monospace'}}}%%
|
|
@@ -321,58 +399,18 @@ classDiagram
|
|
|
321
399
|
|
|
322
400
|
Each box is a file or class. **Green** = only additions, **yellow** = at least one modification. Inside each box: `+` added function, `~` modified. Annotations: `sig` = signature changed, `calls +N−N` = now calls N more / N fewer functions. Arrows show which files call into which.
|
|
323
401
|
|
|
324
|
-
## Supported languages
|
|
325
|
-
|
|
326
|
-
| Language | Extensions |
|
|
327
|
-
|---|---|
|
|
328
|
-
| Python | `.py` |
|
|
329
|
-
| TypeScript | `.ts`, `.tsx` |
|
|
330
|
-
|
|
331
402
|
## How it works
|
|
332
403
|
|
|
333
404
|
codiff maintains a SQLite call-graph index (`.codiff.db`) at the repo root. On first run it does a full parse; on subsequent runs it re-parses only the files changed since the last indexed commit, then detects stale callers (functions whose callees were renamed or deleted) and re-parses those too. Both the base and head snapshots are built incrementally from this index, so diffs stay fast even on large codebases.
|
|
334
405
|
|
|
335
|
-
The graph delta — added, modified, removed functions — is computed deterministically from the resolved call graph.
|
|
406
|
+
The graph delta — added, modified, removed functions — is computed deterministically from the resolved call graph.
|
|
336
407
|
|
|
337
408
|
## Requirements
|
|
338
409
|
|
|
339
410
|
- Python 3.11+
|
|
340
411
|
- Git
|
|
341
412
|
|
|
342
|
-
##
|
|
343
|
-
|
|
344
|
-
```bash
|
|
345
|
-
pip install codiff
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
## Usage
|
|
349
|
-
|
|
350
|
-
### Agent integration (MCP + project instructions)
|
|
351
|
-
|
|
352
|
-
Run once per project to configure your coding agent:
|
|
353
|
-
|
|
354
|
-
```bash
|
|
355
|
-
codiff init --agent claude # Claude Code
|
|
356
|
-
codiff init --agent codex # OpenAI Codex CLI
|
|
357
|
-
codiff init --agent gemini # Gemini CLI
|
|
358
|
-
codiff init --agent vibe # Mistral Vibe
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
Each command writes the MCP server config and a project instructions file telling the agent to use the `codiff_diff` MCP tool when creating pull requests:
|
|
362
|
-
|
|
363
|
-
| Agent | MCP config | Instructions file |
|
|
364
|
-
|---|---|---|
|
|
365
|
-
| `claude` | `.mcp.json` | `CLAUDE.md` |
|
|
366
|
-
| `codex` | `.codex/config.toml` | `AGENTS.md` |
|
|
367
|
-
| `gemini` | `~/.gemini/settings.json` ¹ | `GEMINI.md` |
|
|
368
|
-
| `vibe` | `~/.vibe/config.toml` ² | — |
|
|
369
|
-
|
|
370
|
-
¹ Gemini CLI MCP config is global (not project-scoped). Restart Gemini CLI after running.
|
|
371
|
-
² Mistral Vibe MCP config is global (not project-scoped). Restart Vibe after running.
|
|
372
|
-
|
|
373
|
-
When creating a pull request, the agent calls `codiff_diff(base_ref="main", head_ref="HEAD", format="mermaid")` and embeds the returned diagram in the PR description. GitHub renders Mermaid natively — no plugin needed.
|
|
374
|
-
|
|
375
|
-
### CLI
|
|
413
|
+
## CLI reference
|
|
376
414
|
|
|
377
415
|
```bash
|
|
378
416
|
# Index a repository (writes .codiff.db — runs automatically on first diff)
|
|
@@ -390,7 +428,7 @@ codiff diff --include-deleted # include deleted functions (hidden by defa
|
|
|
390
428
|
codiff diff --workers 8 # set parallel worker count (default: cpu_count // 2)
|
|
391
429
|
codiff diff --debug # print timing breakdown for each processing step
|
|
392
430
|
|
|
393
|
-
# Configure a coding agent
|
|
431
|
+
# Configure a coding agent
|
|
394
432
|
codiff init --agent <agent>
|
|
395
433
|
```
|
|
396
434
|
|
|
@@ -402,7 +440,6 @@ codiff init --agent <agent>
|
|
|
402
440
|
| `mermaid` | Two Mermaid `classDiagram` blocks — paste into any Markdown file or PR description |
|
|
403
441
|
| `json` | Structured JSON — consumed by editor integrations (e.g. the VS Code extension) |
|
|
404
442
|
|
|
405
|
-
|
|
406
443
|
## Reading the terminal output
|
|
407
444
|
|
|
408
445
|
The output shows one box per changed file. Boxes are laid out side by side when they fit the terminal width, with labeled arrows between adjacent connected boxes.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|