codiff 0.1.1__tar.gz → 0.1.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 (66) hide show
  1. {codiff-0.1.1 → codiff-0.1.3}/PKG-INFO +113 -47
  2. {codiff-0.1.1 → codiff-0.1.3}/README.md +112 -46
  3. {codiff-0.1.1 → codiff-0.1.3}/codiff/cli.py +33 -0
  4. {codiff-0.1.1 → codiff-0.1.3}/codiff/diff/engine.py +1 -1
  5. {codiff-0.1.1 → codiff-0.1.3}/codiff/diff/indexer.py +9 -1
  6. {codiff-0.1.1 → codiff-0.1.3}/codiff/export/mermaid.py +14 -1
  7. {codiff-0.1.1 → codiff-0.1.3}/codiff/utils/args.py +1 -1
  8. {codiff-0.1.1 → codiff-0.1.3}/codiff.egg-info/PKG-INFO +113 -47
  9. {codiff-0.1.1 → codiff-0.1.3}/pyproject.toml +1 -1
  10. {codiff-0.1.1 → codiff-0.1.3}/tests/test_cli.py +2 -2
  11. {codiff-0.1.1 → codiff-0.1.3}/LICENSE +0 -0
  12. {codiff-0.1.1 → codiff-0.1.3}/codiff/__init__.py +0 -0
  13. {codiff-0.1.1 → codiff-0.1.3}/codiff/__main__.py +0 -0
  14. {codiff-0.1.1 → codiff-0.1.3}/codiff/db/__init__.py +0 -0
  15. {codiff-0.1.1 → codiff-0.1.3}/codiff/db/engine.py +0 -0
  16. {codiff-0.1.1 → codiff-0.1.3}/codiff/db/models.py +0 -0
  17. {codiff-0.1.1 → codiff-0.1.3}/codiff/db/operations.py +0 -0
  18. {codiff-0.1.1 → codiff-0.1.3}/codiff/diff/__init__.py +0 -0
  19. {codiff-0.1.1 → codiff-0.1.3}/codiff/diff/analysis.py +0 -0
  20. {codiff-0.1.1 → codiff-0.1.3}/codiff/diff/differ.py +0 -0
  21. {codiff-0.1.1 → codiff-0.1.3}/codiff/diff/snapshot.py +0 -0
  22. {codiff-0.1.1 → codiff-0.1.3}/codiff/export/__init__.py +0 -0
  23. {codiff-0.1.1 → codiff-0.1.3}/codiff/export/json.py +0 -0
  24. {codiff-0.1.1 → codiff-0.1.3}/codiff/export/terminal.py +0 -0
  25. {codiff-0.1.1 → codiff-0.1.3}/codiff/languages/__init__.py +0 -0
  26. {codiff-0.1.1 → codiff-0.1.3}/codiff/languages/parser.py +0 -0
  27. {codiff-0.1.1 → codiff-0.1.3}/codiff/languages/python/__init__.py +0 -0
  28. {codiff-0.1.1 → codiff-0.1.3}/codiff/languages/python/parser.py +0 -0
  29. {codiff-0.1.1 → codiff-0.1.3}/codiff/languages/python/resolver.py +0 -0
  30. {codiff-0.1.1 → codiff-0.1.3}/codiff/languages/repository.py +0 -0
  31. {codiff-0.1.1 → codiff-0.1.3}/codiff/languages/resolver.py +0 -0
  32. {codiff-0.1.1 → codiff-0.1.3}/codiff/languages/typescript/__init__.py +0 -0
  33. {codiff-0.1.1 → codiff-0.1.3}/codiff/languages/typescript/parser.py +0 -0
  34. {codiff-0.1.1 → codiff-0.1.3}/codiff/languages/typescript/resolver.py +0 -0
  35. {codiff-0.1.1 → codiff-0.1.3}/codiff/mcp_server.py +0 -0
  36. {codiff-0.1.1 → codiff-0.1.3}/codiff/schema/__init__.py +0 -0
  37. {codiff-0.1.1 → codiff-0.1.3}/codiff/schema/diff.py +0 -0
  38. {codiff-0.1.1 → codiff-0.1.3}/codiff/schema/parsing.py +0 -0
  39. {codiff-0.1.1 → codiff-0.1.3}/codiff/setup.py +0 -0
  40. {codiff-0.1.1 → codiff-0.1.3}/codiff/utils/__init__.py +0 -0
  41. {codiff-0.1.1 → codiff-0.1.3}/codiff/utils/files.py +0 -0
  42. {codiff-0.1.1 → codiff-0.1.3}/codiff/utils/git.py +0 -0
  43. {codiff-0.1.1 → codiff-0.1.3}/codiff/utils/instructions.py +0 -0
  44. {codiff-0.1.1 → codiff-0.1.3}/codiff/utils/instructions.yaml +0 -0
  45. {codiff-0.1.1 → codiff-0.1.3}/codiff/utils/terminal.py +0 -0
  46. {codiff-0.1.1 → codiff-0.1.3}/codiff.egg-info/SOURCES.txt +0 -0
  47. {codiff-0.1.1 → codiff-0.1.3}/codiff.egg-info/dependency_links.txt +0 -0
  48. {codiff-0.1.1 → codiff-0.1.3}/codiff.egg-info/entry_points.txt +0 -0
  49. {codiff-0.1.1 → codiff-0.1.3}/codiff.egg-info/requires.txt +0 -0
  50. {codiff-0.1.1 → codiff-0.1.3}/codiff.egg-info/top_level.txt +0 -0
  51. {codiff-0.1.1 → codiff-0.1.3}/setup.cfg +0 -0
  52. {codiff-0.1.1 → codiff-0.1.3}/tests/test_call_patterns.py +0 -0
  53. {codiff-0.1.1 → codiff-0.1.3}/tests/test_call_resolver.py +0 -0
  54. {codiff-0.1.1 → codiff-0.1.3}/tests/test_code_parser.py +0 -0
  55. {codiff-0.1.1 → codiff-0.1.3}/tests/test_db.py +0 -0
  56. {codiff-0.1.1 → codiff-0.1.3}/tests/test_diff.py +0 -0
  57. {codiff-0.1.1 → codiff-0.1.3}/tests/test_export_json.py +0 -0
  58. {codiff-0.1.1 → codiff-0.1.3}/tests/test_export_mermaid.py +0 -0
  59. {codiff-0.1.1 → codiff-0.1.3}/tests/test_export_terminal.py +0 -0
  60. {codiff-0.1.1 → codiff-0.1.3}/tests/test_indexer.py +0 -0
  61. {codiff-0.1.1 → codiff-0.1.3}/tests/test_setup.py +0 -0
  62. {codiff-0.1.1 → codiff-0.1.3}/tests/test_snapshot.py +0 -0
  63. {codiff-0.1.1 → codiff-0.1.3}/tests/test_ts_integration.py +0 -0
  64. {codiff-0.1.1 → codiff-0.1.3}/tests/test_ts_parser.py +0 -0
  65. {codiff-0.1.1 → codiff-0.1.3}/tests/test_ts_resolver.py +0 -0
  66. {codiff-0.1.1 → codiff-0.1.3}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codiff
3
- Version: 0.1.1
3
+ Version: 0.1.3
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,116 @@ 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. Instead of a line diff, it 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.
241
+ [![PyPI](https://img.shields.io/pypi/v/codiff)](https://pypi.org/project/codiff/)
242
+ [![GitHub Marketplace](https://img.shields.io/badge/GitHub%20Marketplace-codiff%20action-blue?logo=github)](https://github.com/marketplace/actions/codiff-action)
242
243
 
243
- Here's the output of `codiff diff --base main --format mermaid` run on codiff's own codebase:
244
+ A structural call-graph diff tool for multi-language codebases, built to work with coding agents.
245
+
246
+ 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.
247
+
248
+ No LLM, no embeddings, fully offline.
249
+
250
+ ## Supported languages
251
+
252
+ | Language | Extensions |
253
+ |---|---|
254
+ | Python | `.py` |
255
+ | TypeScript | `.ts`, `.tsx` |
256
+
257
+ ## Installation
258
+
259
+ ```bash
260
+ pip install codiff
261
+ ```
262
+
263
+ ## Quickstart
264
+
265
+ ```bash
266
+ # Run from inside any git repository
267
+ codiff diff
268
+ ```
269
+
270
+ This compares your working tree against `HEAD`. If everything is already committed, use `--base` and `--head` to compare two refs explicitly:
271
+
272
+ ```bash
273
+ # Diff between two branches
274
+ codiff diff --base main --head my-feature
275
+
276
+ # Diff introduced by the last commit only
277
+ codiff diff --base HEAD~1 --head HEAD
278
+
279
+ # Diff between two arbitrary commits
280
+ codiff diff --base a1b2c3d --head e4f5g6h
281
+ ```
282
+
283
+ To get a Mermaid diagram (useful for PR descriptions):
284
+
285
+ ```bash
286
+ codiff diff --base main --format mermaid
287
+ ```
288
+
289
+ To save the diagram to a file and preview it:
290
+
291
+ ```bash
292
+ codiff diff --base main --format mermaid > mermaid.md
293
+ ```
294
+
295
+ Open `mermaid.md` in any Markdown previewer (VS Code, GitHub, etc.) to visualise the diagram.
296
+
297
+ ## GitHub Action
298
+
299
+ codiff is available as a GitHub Action that posts a structural diff comment on every pull request — no AI coding agent required. The comment is created when the PR opens and updated on every subsequent push.
300
+
301
+ Run once in your repository to set it up:
302
+
303
+ ```bash
304
+ codiff init --agent github-actions
305
+ ```
306
+
307
+ This creates `.github/workflows/codiff.yml`:
308
+
309
+ ```yaml
310
+ name: codiff
311
+
312
+ on:
313
+ pull_request:
314
+ types: [opened, synchronize, reopened]
315
+
316
+ jobs:
317
+ codiff:
318
+ runs-on: ubuntu-latest
319
+ permissions:
320
+ pull-requests: write
321
+ steps:
322
+ - uses: issahammoud/codiff-action@v1
323
+ ```
324
+
325
+ Commit and push the file to activate the action.
326
+
327
+ > **Note:** Use either the GitHub Action or an AI coding agent integration, 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.
328
+
329
+ ## Agent integration (MCP)
330
+
331
+ Run once per project to wire codiff into your coding agent:
332
+
333
+ ```bash
334
+ codiff init --agent claude # Claude Code
335
+ codiff init --agent codex # OpenAI Codex CLI
336
+ codiff init --agent gemini # Gemini CLI
337
+ codiff init --agent vibe # Mistral Vibe
338
+ ```
339
+
340
+ 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.
341
+
342
+ | Agent | MCP config | Instructions file |
343
+ |---|---|---|
344
+ | `claude` | `.mcp.json` | `CLAUDE.md` |
345
+ | `codex` | `.codex/config.toml` | `AGENTS.md` |
346
+ | `gemini` | `~/.gemini/settings.json` | `GEMINI.md` |
347
+ | `vibe` | `~/.vibe/config.toml` | — |
348
+
349
+
350
+ Here's the output of `codiff diff --base b8dde67 --head d25c385 --format mermaid` run on codiff's own codebase:
244
351
 
245
352
  ```mermaid
246
353
  %%{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 +428,18 @@ classDiagram
321
428
 
322
429
  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
430
 
324
- ## Supported languages
325
-
326
- | Language | Extensions |
327
- |---|---|
328
- | Python | `.py` |
329
- | TypeScript | `.ts`, `.tsx` |
330
-
331
431
  ## How it works
332
432
 
333
433
  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
434
 
335
- The graph delta — added, modified, removed functions — is computed deterministically from the resolved call graph. No LLM, no embeddings, fully offline.
435
+ The graph delta — added, modified, removed functions — is computed deterministically from the resolved call graph.
336
436
 
337
437
  ## Requirements
338
438
 
339
439
  - Python 3.11+
340
440
  - Git
341
441
 
342
- ## Installation
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
442
+ ## CLI reference
376
443
 
377
444
  ```bash
378
445
  # Index a repository (writes .codiff.db — runs automatically on first diff)
@@ -390,7 +457,7 @@ codiff diff --include-deleted # include deleted functions (hidden by defa
390
457
  codiff diff --workers 8 # set parallel worker count (default: cpu_count // 2)
391
458
  codiff diff --debug # print timing breakdown for each processing step
392
459
 
393
- # Configure a coding agent (see Agent integration below)
460
+ # Configure a coding agent
394
461
  codiff init --agent <agent>
395
462
  ```
396
463
 
@@ -402,7 +469,6 @@ codiff init --agent <agent>
402
469
  | `mermaid` | Two Mermaid `classDiagram` blocks — paste into any Markdown file or PR description |
403
470
  | `json` | Structured JSON — consumed by editor integrations (e.g. the VS Code extension) |
404
471
 
405
-
406
472
  ## Reading the terminal output
407
473
 
408
474
  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,115 @@
1
1
  # codiff
2
2
 
3
- A structural call-graph diff tool for multi-language codebases, built to work with coding agents. Instead of a line diff, it 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.
3
+ [![PyPI](https://img.shields.io/pypi/v/codiff)](https://pypi.org/project/codiff/)
4
+ [![GitHub Marketplace](https://img.shields.io/badge/GitHub%20Marketplace-codiff%20action-blue?logo=github)](https://github.com/marketplace/actions/codiff-action)
4
5
 
5
- Here's the output of `codiff diff --base main --format mermaid` run on codiff's own codebase:
6
+ A structural call-graph diff tool for multi-language codebases, built to work with coding agents.
7
+
8
+ 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.
9
+
10
+ No LLM, no embeddings, fully offline.
11
+
12
+ ## Supported languages
13
+
14
+ | Language | Extensions |
15
+ |---|---|
16
+ | Python | `.py` |
17
+ | TypeScript | `.ts`, `.tsx` |
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ pip install codiff
23
+ ```
24
+
25
+ ## Quickstart
26
+
27
+ ```bash
28
+ # Run from inside any git repository
29
+ codiff diff
30
+ ```
31
+
32
+ This compares your working tree against `HEAD`. If everything is already committed, use `--base` and `--head` to compare two refs explicitly:
33
+
34
+ ```bash
35
+ # Diff between two branches
36
+ codiff diff --base main --head my-feature
37
+
38
+ # Diff introduced by the last commit only
39
+ codiff diff --base HEAD~1 --head HEAD
40
+
41
+ # Diff between two arbitrary commits
42
+ codiff diff --base a1b2c3d --head e4f5g6h
43
+ ```
44
+
45
+ To get a Mermaid diagram (useful for PR descriptions):
46
+
47
+ ```bash
48
+ codiff diff --base main --format mermaid
49
+ ```
50
+
51
+ To save the diagram to a file and preview it:
52
+
53
+ ```bash
54
+ codiff diff --base main --format mermaid > mermaid.md
55
+ ```
56
+
57
+ Open `mermaid.md` in any Markdown previewer (VS Code, GitHub, etc.) to visualise the diagram.
58
+
59
+ ## GitHub Action
60
+
61
+ codiff is available as a GitHub Action that posts a structural diff comment on every pull request — no AI coding agent required. The comment is created when the PR opens and updated on every subsequent push.
62
+
63
+ Run once in your repository to set it up:
64
+
65
+ ```bash
66
+ codiff init --agent github-actions
67
+ ```
68
+
69
+ This creates `.github/workflows/codiff.yml`:
70
+
71
+ ```yaml
72
+ name: codiff
73
+
74
+ on:
75
+ pull_request:
76
+ types: [opened, synchronize, reopened]
77
+
78
+ jobs:
79
+ codiff:
80
+ runs-on: ubuntu-latest
81
+ permissions:
82
+ pull-requests: write
83
+ steps:
84
+ - uses: issahammoud/codiff-action@v1
85
+ ```
86
+
87
+ Commit and push the file to activate the action.
88
+
89
+ > **Note:** Use either the GitHub Action or an AI coding agent integration, 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.
90
+
91
+ ## Agent integration (MCP)
92
+
93
+ Run once per project to wire codiff into your coding agent:
94
+
95
+ ```bash
96
+ codiff init --agent claude # Claude Code
97
+ codiff init --agent codex # OpenAI Codex CLI
98
+ codiff init --agent gemini # Gemini CLI
99
+ codiff init --agent vibe # Mistral Vibe
100
+ ```
101
+
102
+ 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.
103
+
104
+ | Agent | MCP config | Instructions file |
105
+ |---|---|---|
106
+ | `claude` | `.mcp.json` | `CLAUDE.md` |
107
+ | `codex` | `.codex/config.toml` | `AGENTS.md` |
108
+ | `gemini` | `~/.gemini/settings.json` | `GEMINI.md` |
109
+ | `vibe` | `~/.vibe/config.toml` | — |
110
+
111
+
112
+ Here's the output of `codiff diff --base b8dde67 --head d25c385 --format mermaid` run on codiff's own codebase:
6
113
 
7
114
  ```mermaid
8
115
  %%{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 +190,18 @@ classDiagram
83
190
 
84
191
  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
192
 
86
- ## Supported languages
87
-
88
- | Language | Extensions |
89
- |---|---|
90
- | Python | `.py` |
91
- | TypeScript | `.ts`, `.tsx` |
92
-
93
193
  ## How it works
94
194
 
95
195
  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
196
 
97
- The graph delta — added, modified, removed functions — is computed deterministically from the resolved call graph. No LLM, no embeddings, fully offline.
197
+ The graph delta — added, modified, removed functions — is computed deterministically from the resolved call graph.
98
198
 
99
199
  ## Requirements
100
200
 
101
201
  - Python 3.11+
102
202
  - Git
103
203
 
104
- ## Installation
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
204
+ ## CLI reference
138
205
 
139
206
  ```bash
140
207
  # Index a repository (writes .codiff.db — runs automatically on first diff)
@@ -152,7 +219,7 @@ codiff diff --include-deleted # include deleted functions (hidden by defa
152
219
  codiff diff --workers 8 # set parallel worker count (default: cpu_count // 2)
153
220
  codiff diff --debug # print timing breakdown for each processing step
154
221
 
155
- # Configure a coding agent (see Agent integration below)
222
+ # Configure a coding agent
156
223
  codiff init --agent <agent>
157
224
  ```
158
225
 
@@ -164,7 +231,6 @@ codiff init --agent <agent>
164
231
  | `mermaid` | Two Mermaid `classDiagram` blocks — paste into any Markdown file or PR description |
165
232
  | `json` | Structured JSON — consumed by editor integrations (e.g. the VS Code extension) |
166
233
 
167
-
168
234
  ## Reading the terminal output
169
235
 
170
236
  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
 
@@ -27,7 +27,7 @@ def compute_diff(
27
27
  log.info("Diffing %s → %s", base_ref, head_ref or "working tree")
28
28
 
29
29
  t = time.perf_counter()
30
- db_sha = ensure_indexed(repo_path, "HEAD", max_workers=max_workers)
30
+ db_sha = ensure_indexed(repo_path, base_ref, max_workers=max_workers)
31
31
  log.debug("[timing] ensure_indexed: %.2fs", time.perf_counter() - t)
32
32
 
33
33
  db = get_db_path(repo_path)
@@ -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
- _incremental_update_db(repo_path, db_path, current, sha, max_workers=max_workers)
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
- return "\n\n".join(d for d in diagrams if d is not None)
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.1
3
+ Version: 0.1.3
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,116 @@ 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. Instead of a line diff, it 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.
241
+ [![PyPI](https://img.shields.io/pypi/v/codiff)](https://pypi.org/project/codiff/)
242
+ [![GitHub Marketplace](https://img.shields.io/badge/GitHub%20Marketplace-codiff%20action-blue?logo=github)](https://github.com/marketplace/actions/codiff-action)
242
243
 
243
- Here's the output of `codiff diff --base main --format mermaid` run on codiff's own codebase:
244
+ A structural call-graph diff tool for multi-language codebases, built to work with coding agents.
245
+
246
+ 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.
247
+
248
+ No LLM, no embeddings, fully offline.
249
+
250
+ ## Supported languages
251
+
252
+ | Language | Extensions |
253
+ |---|---|
254
+ | Python | `.py` |
255
+ | TypeScript | `.ts`, `.tsx` |
256
+
257
+ ## Installation
258
+
259
+ ```bash
260
+ pip install codiff
261
+ ```
262
+
263
+ ## Quickstart
264
+
265
+ ```bash
266
+ # Run from inside any git repository
267
+ codiff diff
268
+ ```
269
+
270
+ This compares your working tree against `HEAD`. If everything is already committed, use `--base` and `--head` to compare two refs explicitly:
271
+
272
+ ```bash
273
+ # Diff between two branches
274
+ codiff diff --base main --head my-feature
275
+
276
+ # Diff introduced by the last commit only
277
+ codiff diff --base HEAD~1 --head HEAD
278
+
279
+ # Diff between two arbitrary commits
280
+ codiff diff --base a1b2c3d --head e4f5g6h
281
+ ```
282
+
283
+ To get a Mermaid diagram (useful for PR descriptions):
284
+
285
+ ```bash
286
+ codiff diff --base main --format mermaid
287
+ ```
288
+
289
+ To save the diagram to a file and preview it:
290
+
291
+ ```bash
292
+ codiff diff --base main --format mermaid > mermaid.md
293
+ ```
294
+
295
+ Open `mermaid.md` in any Markdown previewer (VS Code, GitHub, etc.) to visualise the diagram.
296
+
297
+ ## GitHub Action
298
+
299
+ codiff is available as a GitHub Action that posts a structural diff comment on every pull request — no AI coding agent required. The comment is created when the PR opens and updated on every subsequent push.
300
+
301
+ Run once in your repository to set it up:
302
+
303
+ ```bash
304
+ codiff init --agent github-actions
305
+ ```
306
+
307
+ This creates `.github/workflows/codiff.yml`:
308
+
309
+ ```yaml
310
+ name: codiff
311
+
312
+ on:
313
+ pull_request:
314
+ types: [opened, synchronize, reopened]
315
+
316
+ jobs:
317
+ codiff:
318
+ runs-on: ubuntu-latest
319
+ permissions:
320
+ pull-requests: write
321
+ steps:
322
+ - uses: issahammoud/codiff-action@v1
323
+ ```
324
+
325
+ Commit and push the file to activate the action.
326
+
327
+ > **Note:** Use either the GitHub Action or an AI coding agent integration, 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.
328
+
329
+ ## Agent integration (MCP)
330
+
331
+ Run once per project to wire codiff into your coding agent:
332
+
333
+ ```bash
334
+ codiff init --agent claude # Claude Code
335
+ codiff init --agent codex # OpenAI Codex CLI
336
+ codiff init --agent gemini # Gemini CLI
337
+ codiff init --agent vibe # Mistral Vibe
338
+ ```
339
+
340
+ 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.
341
+
342
+ | Agent | MCP config | Instructions file |
343
+ |---|---|---|
344
+ | `claude` | `.mcp.json` | `CLAUDE.md` |
345
+ | `codex` | `.codex/config.toml` | `AGENTS.md` |
346
+ | `gemini` | `~/.gemini/settings.json` | `GEMINI.md` |
347
+ | `vibe` | `~/.vibe/config.toml` | — |
348
+
349
+
350
+ Here's the output of `codiff diff --base b8dde67 --head d25c385 --format mermaid` run on codiff's own codebase:
244
351
 
245
352
  ```mermaid
246
353
  %%{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 +428,18 @@ classDiagram
321
428
 
322
429
  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
430
 
324
- ## Supported languages
325
-
326
- | Language | Extensions |
327
- |---|---|
328
- | Python | `.py` |
329
- | TypeScript | `.ts`, `.tsx` |
330
-
331
431
  ## How it works
332
432
 
333
433
  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
434
 
335
- The graph delta — added, modified, removed functions — is computed deterministically from the resolved call graph. No LLM, no embeddings, fully offline.
435
+ The graph delta — added, modified, removed functions — is computed deterministically from the resolved call graph.
336
436
 
337
437
  ## Requirements
338
438
 
339
439
  - Python 3.11+
340
440
  - Git
341
441
 
342
- ## Installation
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
442
+ ## CLI reference
376
443
 
377
444
  ```bash
378
445
  # Index a repository (writes .codiff.db — runs automatically on first diff)
@@ -390,7 +457,7 @@ codiff diff --include-deleted # include deleted functions (hidden by defa
390
457
  codiff diff --workers 8 # set parallel worker count (default: cpu_count // 2)
391
458
  codiff diff --debug # print timing breakdown for each processing step
392
459
 
393
- # Configure a coding agent (see Agent integration below)
460
+ # Configure a coding agent
394
461
  codiff init --agent <agent>
395
462
  ```
396
463
 
@@ -402,7 +469,6 @@ codiff init --agent <agent>
402
469
  | `mermaid` | Two Mermaid `classDiagram` blocks — paste into any Markdown file or PR description |
403
470
  | `json` | Structured JSON — consumed by editor integrations (e.g. the VS Code extension) |
404
471
 
405
-
406
472
  ## Reading the terminal output
407
473
 
408
474
  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.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "codiff"
7
- version = "0.1.1"
7
+ version = "0.1.3"
8
8
  description = "Structural call-graph diff for codebases, built for coding agents"
9
9
  readme = "README.md"
10
10
  license = { file = "LICENSE" }
@@ -454,7 +454,7 @@ class TestRunDiff:
454
454
  mock_ensure.assert_called_once()
455
455
  assert mock_ensure.call_args.args[1] == "HEAD"
456
456
 
457
- def test_two_ref_path_anchors_db_at_head(self, tmp_path):
457
+ def test_two_ref_path_anchors_db_at_base(self, tmp_path):
458
458
  with (
459
459
  patch("codiff.diff.indexer.ensure_indexed", return_value="abc" * 13) as mock_ensure,
460
460
  patch("codiff.db.get_db_path", return_value=":memory:"),
@@ -467,7 +467,7 @@ class TestRunDiff:
467
467
  patch("codiff.export.render_terminal"),
468
468
  ):
469
469
  _run_diff(str(tmp_path), "v1", head_ref="v2")
470
- assert mock_ensure.call_args.args[1] == "HEAD"
470
+ assert mock_ensure.call_args.args[1] == "v1"
471
471
  assert mock_build.call_count == 2 # once for base, once for head
472
472
 
473
473
  def test_fmt_json_prints_output(self, tmp_path, capsys):
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