grokmap 0.2.0__py3-none-any.whl
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.
- grokmap/__init__.py +3 -0
- grokmap/__main__.py +3 -0
- grokmap/badge.py +42 -0
- grokmap/cli.py +397 -0
- grokmap/config.py +167 -0
- grokmap/detect.py +74 -0
- grokmap/gitutil.py +158 -0
- grokmap/ledger.py +97 -0
- grokmap/prdiff.py +144 -0
- grokmap/quiz.py +334 -0
- grokmap/report.py +60 -0
- grokmap/report_template.html +474 -0
- grokmap/scan.py +212 -0
- grokmap/score.py +158 -0
- grokmap/trend.py +151 -0
- grokmap-0.2.0.dist-info/METADATA +266 -0
- grokmap-0.2.0.dist-info/RECORD +20 -0
- grokmap-0.2.0.dist-info/WHEEL +4 -0
- grokmap-0.2.0.dist-info/entry_points.txt +2 -0
- grokmap-0.2.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: grokmap
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Measure comprehension debt: the AI-written code in your repo that nobody understands.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Aadithya-kl/grokmap
|
|
6
|
+
Project-URL: Issues, https://github.com/Aadithya-kl/grokmap/issues
|
|
7
|
+
Author: K. L. Aadithya
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: agent-skills,ai,claude-code,code-review,codex,comprehension-debt,copilot,git
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
17
|
+
Classifier: Topic :: Software Development :: Version Control :: Git
|
|
18
|
+
Requires-Python: >=3.11
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
21
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
<div align="center">
|
|
25
|
+
|
|
26
|
+
# grokmap
|
|
27
|
+
|
|
28
|
+
**Find the AI-written code nobody on your team understands, and pay it down one short quiz at a time.**
|
|
29
|
+
|
|
30
|
+
[](https://github.com/Aadithya-kl/grokmap/actions/workflows/ci.yml)
|
|
31
|
+

|
|
32
|
+

|
|
33
|
+

|
|
34
|
+
|
|
35
|
+
**[▶ Open the live demo](https://aadithya-kl.github.io/grokmap/)** · [Install](#install) · [Agent skill](#add-the-skill-to-your-coding-agent) · [CI and PR comments](#in-ci)
|
|
36
|
+
|
|
37
|
+
<picture>
|
|
38
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/report-dark.png">
|
|
39
|
+
<img src="docs/report-light.png" alt="grokmap report: 35% comprehension debt, a bar of every line by who understands it, a weekly chart of who wrote the code, and a treemap of files colored by debt" width="900">
|
|
40
|
+
</picture>
|
|
41
|
+
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
Coding agents now write a large share of the code we ship. The tests pass, the diff looks clean, it gets merged. A month later something breaks at 2am, and nobody on the team can explain how that module works.
|
|
47
|
+
|
|
48
|
+
That gap has a name: **comprehension debt**, the difference between how much code is in your system and how much of it any person actually understands. It doesn't show up in linters, coverage or code review dashboards.
|
|
49
|
+
|
|
50
|
+
**grokmap measures it.** It traces every line in your repo to the commit that wrote it, recognises commits made by AI agents (Claude Code, Copilot, Cursor, Codex, Aider, Devin, Gemini…), and checks them against a shared ledger of who has *shown* they understand that code. Then it draws you a map.
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
$ grokmap status
|
|
54
|
+
grokmap · shopcart @ c3088b29ff
|
|
55
|
+
|
|
56
|
+
Comprehension debt 34.5%
|
|
57
|
+
Lines scanned 255 in 12 files
|
|
58
|
+
Written by AI 218 lines (85.5%) — claude 141, copilot 56, cursor 21
|
|
59
|
+
understood 83 (38%)
|
|
60
|
+
fading 21
|
|
61
|
+
skimmed 73
|
|
62
|
+
nobody checked 41
|
|
63
|
+
Critical paths 40.7% debt over 86 lines
|
|
64
|
+
Understood by alex@example.com (53), priya@example.com (51)
|
|
65
|
+
|
|
66
|
+
Riskiest files lines AI unread debt
|
|
67
|
+
src/shopcart/payments/client.py 64 64 33 52%
|
|
68
|
+
src/shopcart/api/routes.py 33 33 0 50%
|
|
69
|
+
src/shopcart/api/auth.py 23 23 0 50%
|
|
70
|
+
|
|
71
|
+
Pay it down: ask your coding agent to run `grokmap quiz <file>` and quiz you.
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## How you pay it down: your agent quizzes you
|
|
75
|
+
|
|
76
|
+
grokmap ships an **agent skill**. After your coding agent writes something substantial, it offers a two-minute quiz on exactly the lines you haven't shown you understand, grades you honestly, and records the result:
|
|
77
|
+
|
|
78
|
+
```text
|
|
79
|
+
you > yes, quiz me before I commit
|
|
80
|
+
agent > (runs: grokmap quiz --uncommitted)
|
|
81
|
+
Q1 of 3. A charge request times out after the provider already took the money.
|
|
82
|
+
What stops the retry from charging the customer twice?
|
|
83
|
+
you > the idempotency key — it's a hash of order id and amount, so the retry reuses it
|
|
84
|
+
agent > Correct (1/1). The provider sees the same Idempotency-Key and returns the first charge.
|
|
85
|
+
Q2 of 3. A card is declined with HTTP 402. How many times do we call the API, and why?
|
|
86
|
+
you > three times? because of the retry decorator
|
|
87
|
+
agent > Not quite (0/1). 4xx errors are raised with retryable=False, and the decorator re-raises
|
|
88
|
+
those immediately, so it's one call. Only 5xx and network errors are retried.
|
|
89
|
+
...
|
|
90
|
+
agent > Score 0.67. Recorded (grokmap mark … --score 0.67 --method quiz).
|
|
91
|
+
Worth rereading the error handling in charge() — that's where the retry rules live.
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Understanding is tracked **per line**. If the agent later rewrites a line you were quizzed on, that line counts as new, not-yet-understood code again. Understanding older than 180 days shows as *fading*.
|
|
95
|
+
|
|
96
|
+
## Install
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
pipx install git+https://github.com/Aadithya-kl/grokmap
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Or try it without installing: `uvx --from git+https://github.com/Aadithya-kl/grokmap grokmap status`
|
|
103
|
+
|
|
104
|
+
Python 3.11+ and git. No other dependencies, no network calls, nothing leaves your machine.
|
|
105
|
+
|
|
106
|
+
### Add the skill to your coding agent
|
|
107
|
+
|
|
108
|
+
**Claude Code:**
|
|
109
|
+
|
|
110
|
+
```text
|
|
111
|
+
/plugin install grokmap --marketplace Aadithya-kl/grokmap
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
(or `/plugin marketplace add Aadithya-kl/grokmap`, then `/plugin install grokmap@grokmap`)
|
|
115
|
+
|
|
116
|
+
**Any agent that reads `SKILL.md` files** (Codex, Cursor, Gemini CLI, OpenCode…):
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
npx skills add Aadithya-kl/grokmap
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
or copy [`skills/grokmap/`](skills/grokmap/SKILL.md) into your agent's skills folder.
|
|
123
|
+
|
|
124
|
+
Then just say **"quiz me on the payments module"**, or let the agent offer after it finishes a change.
|
|
125
|
+
|
|
126
|
+
## Quick start
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
cd your-repo
|
|
130
|
+
grokmap init # .grokmap.toml + ledger + a merge rule for it
|
|
131
|
+
grokmap status # the numbers
|
|
132
|
+
grokmap report --open # the interactive heatmap
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Commit `.grokmap/ledger.jsonl` so your whole team shares one map. It's one JSON object per line with a `merge=union` git rule, so merges don't conflict.
|
|
136
|
+
|
|
137
|
+
## Commands
|
|
138
|
+
|
|
139
|
+
| Command | What it does |
|
|
140
|
+
|---|---|
|
|
141
|
+
| `grokmap status` | Debt, AI share, who understands what, riskiest files. `--json` and `--markdown` for scripts and PR comments. |
|
|
142
|
+
| `grokmap report [-o file] [--open]` | Self-contained HTML heatmap: a zoomable treemap, hover details, filterable file table, light and dark themes. |
|
|
143
|
+
| `grokmap quiz [paths] [--uncommitted \| --staged \| --diff main]` | A quiz brief for your agent: the exact lines you haven't shown you understand, plus grading rules. |
|
|
144
|
+
| `grokmap mark <files…> --score 0.8 [--method quiz\|explain\|review]` | Record understanding. `path:10-40` or `--lines` for line ranges, folders expand to their files. |
|
|
145
|
+
| `grokmap diff [--base origin/main]` | The AI-written lines a branch adds and how many are understood. `--markdown` for a PR comment, `--max-unread N` to gate merges. |
|
|
146
|
+
| `grokmap trend [--by week\|month]` | How much of the code added over time was written by each agent. |
|
|
147
|
+
| `grokmap who <path>` | Who understands the AI-written code in a file or folder. |
|
|
148
|
+
| `grokmap check [--max-debt 40] [--critical]` | Exits 1 above the limit. For CI. |
|
|
149
|
+
| `grokmap badge` | An SVG badge for your README:  |
|
|
150
|
+
| `grokmap init` | Adds config, ledger and `.gitattributes`. |
|
|
151
|
+
|
|
152
|
+
## In CI
|
|
153
|
+
|
|
154
|
+
```yaml
|
|
155
|
+
# .github/workflows/grokmap.yml
|
|
156
|
+
on: [pull_request]
|
|
157
|
+
permissions:
|
|
158
|
+
contents: read
|
|
159
|
+
pull-requests: write # for the PR comment
|
|
160
|
+
jobs:
|
|
161
|
+
grokmap:
|
|
162
|
+
runs-on: ubuntu-latest
|
|
163
|
+
steps:
|
|
164
|
+
- uses: actions/checkout@v4
|
|
165
|
+
with:
|
|
166
|
+
fetch-depth: 0 # blame needs full history
|
|
167
|
+
- uses: Aadithya-kl/grokmap@main
|
|
168
|
+
with:
|
|
169
|
+
max-debt: 40 # optional: fail above 40% debt
|
|
170
|
+
max-unread: 200 # optional: fail if the PR adds >200 unchecked AI lines
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
On every pull request it posts **one comment** (and keeps it up to date) like this:
|
|
174
|
+
|
|
175
|
+
> ### grokmap: comprehension check
|
|
176
|
+
>
|
|
177
|
+
> This change adds **5 AI-written lines** (claude 5) and 1 human-written line. **4 of the AI lines (80%)** have been understood by someone on the team.
|
|
178
|
+
>
|
|
179
|
+
> | File | AI lines | Understood | Not checked |
|
|
180
|
+
> |---|---:|---:|---:|
|
|
181
|
+
> | `src/shopcart/pricing.py` | 1 | 0 | 1 |
|
|
182
|
+
> | `src/shopcart/loyalty.py` | 4 | 4 | 0 |
|
|
183
|
+
>
|
|
184
|
+
> Before merging, the author can ask their coding agent to run `grokmap quiz --diff origin/main` for a 2-minute quiz on the unchecked lines.
|
|
185
|
+
|
|
186
|
+
It also writes the repo summary to the job page, uploads the heatmap as an artifact, and exposes `debt` and `ai-lines` as outputs. Everything is report-only unless you set a limit.
|
|
187
|
+
|
|
188
|
+
## How it works
|
|
189
|
+
|
|
190
|
+
1. **Attribution.** For every tracked text file, `git blame -w` maps each line at `HEAD` to the commit that last changed it. Blank lines and lone brackets are ignored.
|
|
191
|
+
2. **AI detection.** A commit counts as AI-written only when it carries evidence the tools themselves leave behind:
|
|
192
|
+
|
|
193
|
+
| Agent | Signals |
|
|
194
|
+
|---|---|
|
|
195
|
+
| Claude / Claude Code | `Co-Authored-By: Claude`, "Generated with Claude Code", `Claude-Session:`, `claude[bot]` |
|
|
196
|
+
| GitHub Copilot | Copilot coding agent as author, `Co-authored-by: Copilot` |
|
|
197
|
+
| Cursor | `cursoragent@cursor.com` author or co-author |
|
|
198
|
+
| OpenAI Codex | `chatgpt-codex` / `codex[bot]`, Codex co-author |
|
|
199
|
+
| Aider | `aider:` message prefix, `(aider)` author suffix |
|
|
200
|
+
| Devin, Gemini / Jules, Amazon Q, Windsurf | their bot authors or co-author trailers |
|
|
201
|
+
| Your own | any regex in `[grokmap.ai_patterns]`, or specific commits in `[grokmap.ai_commits]` |
|
|
202
|
+
|
|
203
|
+
Squash merges keep co-author trailers, so detection survives the usual GitHub workflow.
|
|
204
|
+
3. **Understanding.** Each ledger record stores short hashes of the lines a person was quizzed on. A line is *understood* when someone passed a quiz on its current content, *skimmed* for a low score or a `review`, *fading* when the pass is older than `decay_days`.
|
|
205
|
+
4. **Debt** = unread AI lines + ½ × (skimmed + fading) AI lines, divided by all meaningful lines.
|
|
206
|
+
|
|
207
|
+
`grokmap trend` uses `git log --numstat` with the same detection, so you can see when AI started writing most of your code.
|
|
208
|
+
|
|
209
|
+
Results are cached per file blob in `.grokmap/cache.json`. A 318,000-line repo with 3,000 files takes about 17 seconds the first time and about a second after that.
|
|
210
|
+
|
|
211
|
+
## Configuration
|
|
212
|
+
|
|
213
|
+
`.grokmap.toml` (or `[tool.grokmap]` in `pyproject.toml`):
|
|
214
|
+
|
|
215
|
+
```toml
|
|
216
|
+
[grokmap]
|
|
217
|
+
pass_score = 0.7 # quiz score that counts as understood
|
|
218
|
+
decay_days = 180 # 0 = understanding never fades
|
|
219
|
+
max_debt = 40 # default limit for `grokmap check`
|
|
220
|
+
exclude = ["docs/**", "examples/**"]
|
|
221
|
+
critical = ["src/payments/**", "src/auth/**"]
|
|
222
|
+
|
|
223
|
+
[grokmap.ai_patterns]
|
|
224
|
+
internal-bot = "^co-authored-by:.*internal-bot"
|
|
225
|
+
render-farm = "author:render-farm"
|
|
226
|
+
|
|
227
|
+
[grokmap.ai_commits]
|
|
228
|
+
"3f2a9c1" = "claude" # before your team added trailers
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Lock files, build output, vendored code, minified files, media and binaries are skipped by default.
|
|
232
|
+
|
|
233
|
+
## FAQ
|
|
234
|
+
|
|
235
|
+
**Is this surveillance?** No. grokmap measures *code*, not people. Nobody is quizzed unless they ask, the ledger only holds what people chose to record, and the main number is about the codebase. If your team would use it to rank people, don't adopt it.
|
|
236
|
+
|
|
237
|
+
**What about AI code pasted from a chat window?** grokmap can't see it, so it counts as human-written. Detection is deliberately conservative: it only flags commits with real evidence and never guesses from code style. Adding an `AI-Assisted:` trailer (or your own pattern) fixes this going forward.
|
|
238
|
+
|
|
239
|
+
**Can I game it?** You can mark code as understood without a quiz, the same way you can approve a PR without reading it. The point is an honest map for your own team, and the skill is written to never record a score the person didn't earn.
|
|
240
|
+
|
|
241
|
+
**Does the quiz send my code anywhere?** grokmap itself makes no network calls. Your coding agent reads the brief like any other file it already works with.
|
|
242
|
+
|
|
243
|
+
## Why "grokmap"?
|
|
244
|
+
|
|
245
|
+
To *grok* is to understand something so thoroughly it becomes part of you. This is a map of what your team groks.
|
|
246
|
+
|
|
247
|
+
## Roadmap
|
|
248
|
+
|
|
249
|
+
Ideas the project wants help with are tracked as [issues](https://github.com/Aadithya-kl/grokmap/issues). The [good first issues](https://github.com/Aadithya-kl/grokmap/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) are small and well scoped. The biggest ones: an editor extension that colors understood and unread lines in the gutter, keeping understanding across file renames, and detection for more agents.
|
|
250
|
+
|
|
251
|
+
## Contributing
|
|
252
|
+
|
|
253
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md). The short version:
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
git clone https://github.com/Aadithya-kl/grokmap && cd grokmap
|
|
257
|
+
python -m venv .venv && . .venv/bin/activate && pip install -e ".[dev]"
|
|
258
|
+
pytest && ruff check src tests
|
|
259
|
+
python scripts/make_demo.py /tmp/grokmap-demo && grokmap -C /tmp/grokmap-demo report --open
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
Most useful contributions: detection signatures for more agents (with a real example commit), and reports of false positives.
|
|
263
|
+
|
|
264
|
+
## License
|
|
265
|
+
|
|
266
|
+
MIT
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
grokmap/__init__.py,sha256=lJ9RwMifG_W28HT38NFBlqzNTUJVxjIxgPiqGox0vdQ,121
|
|
2
|
+
grokmap/__main__.py,sha256=PCPATsSpif890th1Fya_WaVvi8CDPVxn7OkFIZ4d2Ms,55
|
|
3
|
+
grokmap/badge.py,sha256=50vrPFE-lWHsGrNsfm7CFyBVG0fpAmJqiFPffsLVZBQ,1924
|
|
4
|
+
grokmap/cli.py,sha256=pt-sSKV9WInbhmBQOD_tGkIkImr-bFN_VoNJLDzHnzM,17328
|
|
5
|
+
grokmap/config.py,sha256=g1gRsFH8AwM8cZK8ve3ErqBSK9_efMXz3V7zlecPuRs,4924
|
|
6
|
+
grokmap/detect.py,sha256=VJpTGifVW0P_wzGoTn0i7Jfj5rgKkk74SbZ3Hpi0xTs,3335
|
|
7
|
+
grokmap/gitutil.py,sha256=ZFRndS1a8w7duHARCS2Cs9ed8v3De6P_6R8w6OeYO4E,5143
|
|
8
|
+
grokmap/ledger.py,sha256=FrexgLoZ982QVO2D5aFyhLn7BBLQe5oChokPG3UNEJ0,3006
|
|
9
|
+
grokmap/prdiff.py,sha256=z_oiswA0-tgSpUgAjPt6jy3yCBfOxg3n6BxSG064r5U,4793
|
|
10
|
+
grokmap/quiz.py,sha256=bv0vubdUd8iXc76B2su8mYb2Xk08FVhH6tVY5uk1c2s,11643
|
|
11
|
+
grokmap/report.py,sha256=sQgMKj8rtCudOr2KWhGdpGf9dGKChPOLHap1TXzEesc,2120
|
|
12
|
+
grokmap/report_template.html,sha256=l98nupRIEQXAUo26a5nCHUAqsU9Et064M1tcf2VUsFU,31865
|
|
13
|
+
grokmap/scan.py,sha256=OFLhMdCn7BELsYW91fwhehcrgmURc6zqMyQz3Haxbxw,7064
|
|
14
|
+
grokmap/score.py,sha256=ioxHt_u7c_0ZVJSoGu8e4UkYeIAItlzigbbZloif-AM,5215
|
|
15
|
+
grokmap/trend.py,sha256=uNXDFl3_Boszepz-YttCmy73qLu9wRFgFVg0GL6oSTs,5061
|
|
16
|
+
grokmap-0.2.0.dist-info/METADATA,sha256=aOG4SlXSih_WMZKQxu7q98W6xRO1E1h6Y2qjywMqMg8,13059
|
|
17
|
+
grokmap-0.2.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
18
|
+
grokmap-0.2.0.dist-info/entry_points.txt,sha256=yOFYcTnwvN4o8q9WLP9vmFfLdOkSSPlZyHYLNwQZvv8,45
|
|
19
|
+
grokmap-0.2.0.dist-info/licenses/LICENSE,sha256=TpZF86V_ZC48BhpGu7y9yViEusiDQz9Aycd2ujtRgSQ,1071
|
|
20
|
+
grokmap-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 K. L. Aadithya
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|