gitstory-cli 0.2.2__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.
@@ -0,0 +1,341 @@
1
+ Metadata-Version: 2.4
2
+ Name: gitstory-cli
3
+ Version: 0.2.2
4
+ Summary: "Why is this code like this" narrative assembler: blame + commit messages + linked PRs/issues in one command.
5
+ Author-email: "Calas Automations Inc." <office@calasautomations.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://calasautomations.com
8
+ Project-URL: Repository, https://github.com/calasdan-sketch/gitstory
9
+ Project-URL: Issues, https://github.com/calasdan-sketch/gitstory/issues
10
+ Project-URL: Changelog, https://github.com/calasdan-sketch/gitstory/blob/main/CHANGELOG.md
11
+ Keywords: git,blame,history,code-archaeology,commit-messages,developer-tools
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Software Development :: Version Control :: Git
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Dynamic: license-file
25
+
26
+ <!-- Image URLs are absolute on purpose: GitHub resolves relative paths, PyPI does not. -->
27
+ ![gitstory: why is this code like this? One command.](https://raw.githubusercontent.com/calasdan-sketch/gitstory/main/docs/brand/gitstory-banner.png)
28
+
29
+ **Point gitstory at a line range and it quotes what git knows about why that code is there: who wrote it, when, the commit messages, and linked PRs.**
30
+
31
+ ```sh
32
+ pip install git+https://github.com/calasdan-sketch/gitstory.git
33
+ ```
34
+
35
+ Needs Python 3.10 or newer and git. Not on PyPI yet; once it is, `pip install gitstory-cli` will work (the command is still `gitstory`).
36
+
37
+ ```text
38
+ $ gitstory app.py 2-3 --no-gh
39
+ gitstory: app.py:2-3
40
+
41
+ SUMMARY:
42
+ First written by Calas Automations on 2026-11-27: add retry helper
43
+ Last changed by Calas Automations on 2026-11-27: fix: retry 5 times, the upstream API drops the first calls
44
+ 2 commit(s) in this range's history. Original reason: subject line only, no extended message.
45
+
46
+ LINES (blame, -w -C):
47
+ 2: fc5fbbb Calas Automations 2026-11-27 — for _ in range(5):
48
+ 3: cf33c41 Calas Automations 2026-11-27 — try:
49
+
50
+ WHY (from the commit messages — quoted, not reconstructed):
51
+ [fc5fbbb] fix: retry 5 times, the upstream API drops the first calls
52
+ Three tries was not enough in production.
53
+ [cf33c41] add retry helper (no extended message — reason undocumented beyond the subject line)
54
+ (... WHO WROTE IT, WHAT IT REPLACED, WHAT BREAKS sections omitted here; see the full example below)
55
+ ```
56
+
57
+ *Real output from a throwaway two-commit repo, trimmed for length (the omitted sections are marked). A longer, untrimmed run on a real repo is [further down](#full-example).*
58
+
59
+ - **Assembles the evidence.** Blame, line history, commit messages and linked PRs/issues, in one short narrative with a cited short hash on every claim.
60
+ - **Never invents a why.** A commit message of "fix stuff" gives "reason undocumented", not a made-up story. Inference is labeled.
61
+ - **Local and read-only.** No LLM calls, no account, no telemetry; it never writes to your repo. The only network use is optional read-only `gh`.
62
+
63
+ ![License](https://img.shields.io/badge/license-MIT-blue)
64
+ ![Python](https://img.shields.io/badge/python-%3E%3D3.10-blue)
65
+
66
+ ## Quickstart
67
+
68
+ ```sh
69
+ gitstory src/app.py 42-58 # a line range
70
+ gitstory src/app.py:42 # one line
71
+ gitstory auth.py::Auth.login # a Python function or class
72
+ ```
73
+
74
+ `gitstory --help` shows these examples. Add `--json` for structured output, `--blame-only` if history is slow.
75
+
76
+ ## Limits up front
77
+
78
+ - Team tier (shared narratives, IDE plugin) — later, not v0.2.0.
79
+ - LLM narration — flagged, not built (hallucinated whys).
80
+ - Native GitHub API calls — gh only, best-effort.
81
+ - History beyond the line range (no whole-file archaeology mode).
82
+ - Windows: the test suite passes on Windows (gh stubs run via .cmd
83
+ wrappers); live use on Windows is not verified.
84
+ - Not tested here: live `gh pr view` on a `#N` reference written in a
85
+ commit message, live review quoting, and submodules. More detail in
86
+ [Live-tested vs fixture-driven](#live-tested-vs-fixture-driven).
87
+
88
+ ## Why this exists
89
+
90
+ Every developer, every week, stares at a weird block and asks why. The
91
+ answer is scattered across blame, PRs, issues, and commit messages —
92
+ assembling it by hand takes 20 minutes and usually gets skipped, so the
93
+ weird code stays weird (or gets "fixed" and regresses).
94
+
95
+ gitstory assembles it for you: one command for a line range — blame +
96
+ linked PRs/issues + commit messages, into a short narrative: who, when,
97
+ why, what it replaced, what breaks if you touch it.
98
+
99
+ ### Full example
100
+
101
+ ```
102
+ gitstory shortleash/cli.py 10-12
103
+ ```
104
+
105
+ ```text
106
+ gitstory: shortleash/cli.py:10-12
107
+
108
+ SUMMARY:
109
+ First written by Calas Automations on 2026-10-15: initial commit
110
+ Last changed by Odin on 2026-10-19: v0.3.0: panel-approved improvements
111
+ 2 commit(s) in this range's history. Original reason: subject line only, no extended message.
112
+
113
+ LINES (blame, -w -C):
114
+ 10: 256b601 Odin 2026-10-19 — import json
115
+ 11: fc33d73 Calas Automations 2026-10-15 — import os
116
+ 12: fc33d73 Calas Automations 2026-10-15 — import signal
117
+
118
+ WHO WROTE IT, AND WHEN:
119
+ 256b601 Odin 2026-10-19 (line(s) 10): v0.3.0: panel-approved improvements
120
+ fc33d73 Calas Automations 2026-10-15 (line(s) 11, 12): initial commit
121
+
122
+ WHY (from the commit messages — quoted, not reconstructed):
123
+ [256b601] v0.3.0: panel-approved improvements
124
+ - advisor: pre-run go/no-go (baseline + fleet pool, exit 0/3, audit log)
125
+ - loop fingerprinting: identical-args / error-retry / output-geyser tripwires (default on)
126
+ - cross-harness telemetry parsers: codex, opencode, gemini (+claude), auto-detect, --harness
127
+ - downgrade: graceful step-down at --downgrade-at of --budget, receipt-chained, budget-breach only
128
+ - fleet budget pools: single-host ledger, exit-2 refusal, atomic debit, fleet status
129
+ - sim: --loop mode, distinct task descriptions, --model/--resume flags
130
+ … (message truncated — full text in --json or --full)
131
+ [fc33d73] initial commit (no extended message — reason undocumented beyond the subject line)
132
+
133
+ WHAT IT REPLACED:
134
+ [256b601] these lines were added new — no prior version in this file (range history)
135
+ [fc33d73] these lines were added new — no prior version in this file (range history)
136
+
137
+ WHAT CHANGED SINCE FIRST APPEARANCE (kind labels are message-pattern inference, not fact):
138
+ 256b601 Odin 2026-10-19 [change, classified by message pattern] [current form]: v0.3.0: panel-approved improvements
139
+ first appearance: fc33d73 Calas Automations 2026-10-15: initial commit
140
+
141
+ WHAT BREAKS IF YOU TOUCH IT:
142
+ - introducing commit(s) 256b601, fc33d73 also changed test file tests/test_cli.py [related by name to this file — evidence that tests exist alongside this code, not proof they cover these lines]
143
+ - introducing commit 256b601 also changed 6 other test file(s) (unrelated by name to this file — count only, not listed; full list in --json)
144
+ - introducing commit fc33d73 also changed 7 other test file(s) (unrelated by name to this file — count only, not listed; full list in --json)
145
+ - file shortleash/__main__.py imports this module [heuristic: git grep for import statements — evidence of coupling, not proof these lines are covered]
146
+
147
+ LINKED PRS / ISSUES:
148
+ none referenced in the commit messages.
149
+
150
+ Method: blame -w -C + line history + commit messages; deterministic template assembly, no LLM. INFERENCE is limited to message-pattern classification, labeled above.
151
+ ```
152
+
153
+ The example above is real (one author name redacted): run against the shortleash repo on this
154
+ machine (hashes 256b601, fc33d73 are that repo's actual commits).
155
+
156
+ ## Install (local)
157
+
158
+ ```sh
159
+ python3 -m venv .venv
160
+ .venv/bin/pip install -e .
161
+ .venv/bin/gitstory <file> <line-range>
162
+ ```
163
+
164
+ No dependencies beyond Python 3.10+ and git. No account, no network
165
+ (except optional gh enrichment), no telemetry, no phone-home.
166
+
167
+ ## Usage
168
+
169
+ ```
170
+ gitstory <file> <line-range> [--json] [--full] [--no-gh] [--blame-only] [--no-ignore-revs]
171
+ ```
172
+
173
+ - `<line-range>`: `42` for one line, `42-58` for a range. A range may
174
+ span multiple commits; each line is attributed to its own
175
+ introducing commit. `gitstory a.py:40-58` and `gitstory a.py -L 40,58`
176
+ mean the same as `gitstory a.py 40-58`. The `file:range` form splits
177
+ on the last colon followed by digits, so `C:\repo\a.py:3` is file
178
+ `C:\repo\a.py`, line 3.
179
+ - Python symbols: `gitstory auth.py::login` or
180
+ `gitstory auth.py::Auth.login` resolves the function or class to its
181
+ lines (decorators included) with Python's `ast`, from the
182
+ working-tree file, and prints the resolved range first. Python only;
183
+ a non-`.py` file or an unknown name exits 2.
184
+ - The repo is found from the FILE's location, not the caller's cwd:
185
+ `gitstory /other/repo/src.py 10` from anywhere uses /other/repo.
186
+ - `--json`: structured evidence (blame entries, introducing commits,
187
+ history, changes, breaks, references, agent trailers) instead of
188
+ narrative text.
189
+ - `--full`: append the raw evidence dump (blame porcelain, line
190
+ history, diffs) to the text narrative.
191
+ - `--no-gh`: skip gh PR/issue enrichment entirely.
192
+ - `--blame-only`: skip `git log -L` history (faster on long
193
+ histories; narrative uses blame only, and says so).
194
+ - Formatting commits: if `blame.ignoreRevsFile` is configured, or the
195
+ repo has a `.git-blame-ignore-revs` file, blame skips the revisions
196
+ listed there and SUMMARY says how many and from which file. This
197
+ applies to blame (LINES, WHO WROTE IT); the `git log -L` history
198
+ still lists those commits. `--no-ignore-revs` turns it off.
199
+
200
+ Exit codes: 0 narrative produced, 2 error (not a repo, file not
201
+ tracked, bad range, range outside the file, git failure).
202
+
203
+ ## What the narrative contains
204
+
205
+ - **Summary** — first written / last changed / commit count / whether
206
+ the original reason is documented, in three lines, before the
207
+ evidence. The fast answer; the rest is the proof.
208
+ - **Lines** — blame for the range (`-w` ignores whitespace, `-C`
209
+ attributes lines moved from another file in the same commit to their
210
+ origin; both labeled).
211
+ - **Who / when** — per introducing commit: author, date, subject,
212
+ short hash.
213
+ - **Why** — the commit message, quoted. A message of "fix stuff" with
214
+ no body yields "reason undocumented in history", not a reconstructed
215
+ story. Text output folds long bodies (first 6 lines + a pointer to
216
+ `--json`/`--full`); subjects cap at 120 chars in text only. Reason
217
+ trailers in the message's last paragraph (`Why:`, `Why-Rationale:`,
218
+ `Why-Alternatives:`, `Reason:`, `Rationale:` — the "git why"
219
+ convention) are also quoted verbatim as `[trailer Why] …`, and the
220
+ summary says "documented in trailer" when the first commit has one.
221
+ - **What it replaced** — the removed lines from the range-scoped diff
222
+ of the introducing commit (or "added new" when there was no prior
223
+ version; capped at 20 lines in text, full diff in `--json`/`--full`).
224
+ Falls back to the commit's diff for the file, or for the path the
225
+ code moved from, labeled as such. A previous filename equal to this
226
+ file is normal continuation, NOT a move — only a different previous
227
+ filename renders as "moved into this file from …".
228
+ - **What changed since first appearance** — the line range's history,
229
+ newest first, from first appearance to now, with blame commits marked
230
+ `[current form]`. Kind labels are message-pattern inference, stated
231
+ in the section header.
232
+ - **What breaks if you touch it** — evidence only: later fix/revert
233
+ touches in the range's history (classified by message pattern,
234
+ labeled), test files changed in the introducing commits (related by
235
+ name listed individually and deduplicated across commits, the rest
236
+ collapsed to a count; full list in `--json`), files that import this
237
+ module (heuristic `git grep` for import statements, word-bounded so
238
+ `import cli` never matches `import click`; capped at 5 in text, full
239
+ list in `--json`), and later touches mentioning breakage. If nothing
240
+ in history says what breaks, it prints "unknown from history" — that
241
+ absence is itself a finding.
242
+ - **Linked PRs / issues** — `#N` and `owner/repo#N` references parsed
243
+ from commit messages. When `gh` is available AND the repo has a
244
+ remote, PR titles/states/URLs are fetched (PR first, then issue
245
+ fallback); GitHub Enterprise hosts work via `GH_HOST`. For a resolved
246
+ PR, text output quotes the first 6 non-blank lines of the PR body
247
+ (`[PR #N body]`) and up to 3 non-empty review bodies, each cut to 200
248
+ characters (`[review by X]`) — quoted verbatim, never paraphrased;
249
+ `--json` carries the full body and every review. An introducing
250
+ commit whose message has no `#N` is looked up with
251
+ `gh api repos/{owner}/{repo}/commits/{sha}/pulls`; a PR found that
252
+ way is labelled `[found via commit->PR lookup for <sha>]`, and a failed
253
+ or empty lookup prints an "unresolved" note, never a guessed link.
254
+ These lookups go first and share the cap below. Enrichment is
255
+ capped at 10 gh lookups (the rest shown unresolved with a note).
256
+ When gh or the remote is absent, references are listed unresolved
257
+ and the narrative says so — never a fabricated link. `--no-gh`
258
+ disables enrichment.
259
+ - **Agent-authorship note** — only when commit metadata says so
260
+ (e.g. a Co-Authored-By trailer naming an AI tool), quoted verbatim,
261
+ with a count of trailer-carrying commits. Never guessed from code
262
+ style.
263
+
264
+ ## Honesty contract (this IS the product's trust)
265
+
266
+ - NEVER invent a why. The narrative distinguishes EVIDENCE (commit
267
+ message text, blame, diffs, PR titles) from INFERENCE, and inference
268
+ is labeled and kept to message-pattern classification only.
269
+ - Every claim traces to a cited short hash.
270
+ - Subjects are first lines, not git's paragraph-collapsed `%s`: a
271
+ message with no blank line after the first line would otherwise
272
+ collapse into one space-joined "subject" with an empty body.
273
+ - Blame `previous` is parent-commit bookkeeping, not move evidence:
274
+ only a previous filename different from this file indicates a
275
+ rename or copy origin. Lines copied from a file untouched in the
276
+ copy commit attribute to the copy commit (verified: single `-C`
277
+ and `-C -C` agree there) — git cannot see that copy, and the
278
+ narrative does not pretend otherwise.
279
+ - No LLM calls. LLM narration risks hallucinated whys and breaks the
280
+ $0 contract — flagged for a later version, not built.
281
+ - No network calls except optional read-only `gh` enrichment.
282
+ - gitstory never writes to the repo. All git invocations are reads
283
+ (`blame`, `log -L`, `show`, `ls-files`, `rev-parse`, `remote`,
284
+ `grep`).
285
+ - Non-UTF-8 or binary content renders with replacement characters,
286
+ never a traceback.
287
+
288
+ ## Live-tested vs fixture-driven
289
+
290
+ - **Live-tested:** the example above (real shortleash history, real
291
+ blame ranges, real multi-commit ranges); a single-commit repo
292
+ (adr-drift) end-to-end; a venv install check (`gitstory --version`
293
+ → 0.2.0, real CLI run from the installed entry point); a
294
+ never-modifies-the-repo check (`git status` clean before and after).
295
+ - **Fixture-driven:** empty-history files, uncommitted changes in
296
+ range, ranges spanning a rename, single lines, files not in git,
297
+ moved code (blame `-C` attribution + diff fallback), PR references
298
+ with gh present (stub `gh` binary in PATH) and absent, AI trailers,
299
+ fix/revert classification, `--json` structure, exit codes,
300
+ non-UTF-8 files, merge commits (`--first-parent` file lists),
301
+ Enterprise remotes (`GH_HOST`), the 10-reference enrichment cap,
302
+ importer word boundaries, repo-from-file resolution.
303
+ - **Live gh, once:** on 2026-11-07, on Windows, `gitstory
304
+ pre_commit_hooks/check_case_conflict.py:72 --blame-only` in a clone
305
+ of pre-commit/pre-commit-hooks found PR #677 (MERGED) via the
306
+ commit->PR lookup and quoted its body. That is one run of one path.
307
+ - **Not tested here:** live `gh pr view` on a `#N` reference written
308
+ in a commit message, and live review quoting (the stub path proves
309
+ the mechanics). Also: submodules.
310
+
311
+ ## What's new in v0.2.0
312
+
313
+ - SUMMARY lead: first written / last changed / commit count / reason
314
+ documented, in three lines before the evidence.
315
+ - Text output stays SHORT: WHY bodies fold after 6 lines, subjects
316
+ cap at 120 chars, replaced lines cap at 20 — full text always in
317
+ `--json`/`--full`.
318
+ - Breaks section strengthened: related test files deduplicated across
319
+ commits, and importer evidence (`git grep`, word-bounded) added.
320
+ - Two honesty bugs fixed, both caught live: (1) blame `previous`
321
+ misread as move evidence — a plain added import rendered as a
322
+ "move"; now only a different previous filename counts. (2) git's
323
+ `%s` collapses no-blank-line messages into one space-joined
324
+ subject with an empty body; gitstory now splits raw messages on
325
+ the first line itself.
326
+ - Robustness: non-UTF-8/binary content renders instead of
327
+ trace-backing; `-L` history parser tolerates empty diffs and
328
+ missing blank lines instead of silently dropping records; merge
329
+ commits list files via `--first-parent`.
330
+ - Usability: repo found from the file's location (not the cwd);
331
+ `--blame-only` skips slow `-L` history; Enterprise remotes via
332
+ `GH_HOST`; gh enrichment capped at 10 references; timeout errors
333
+ suggest a smaller range or `--blame-only`.
334
+ - `-C -C` tested and NOT adopted: identical attribution to `-C` on
335
+ move-with-delete and pure-copy fixtures, at higher cost.
336
+
337
+ Changes: [CHANGELOG.md](./CHANGELOG.md). Panel review notes: [REVIEW.md](./REVIEW.md). License: MIT, see [LICENSE](./LICENSE).
338
+
339
+ ---
340
+
341
+ Made by Calas Automations (CAL-us). Need help? Call Cara 431-244-9026.
@@ -0,0 +1,12 @@
1
+ gitstory/__init__.py,sha256=8Gm476BnvQpKQKnAJdNtfLIcGhkQ-KO698agmvafiGY,92
2
+ gitstory/__main__.py,sha256=D5REQHa2B5IWVOKsEPrQzBBA9UVFbrXmRipE_MAYGPY,131
3
+ gitstory/cli.py,sha256=_He5GOGIr1jBJvRRLdIArUbIAJjBb4HCgZY_biUWmTk,7311
4
+ gitstory/evidence.py,sha256=7opHzB7-RLAu38dVlVJYX30oVfudPblrG91OpgEs5So,12487
5
+ gitstory/gitops.py,sha256=p5bAqT9t0uFFqDVuZL9Li76eYUP7SWfwxBfKf2cr0gQ,13478
6
+ gitstory/narrative.py,sha256=A56HgZpqsqEwEYcDx8_MnGmj65fPwU-wV4FsWTC6p8c,27549
7
+ gitstory_cli-0.2.2.dist-info/licenses/LICENSE,sha256=OG8PHctCAONIgrgurSX-IOcnSawWGBnpRo6uEwNSS3s,1100
8
+ gitstory_cli-0.2.2.dist-info/METADATA,sha256=vAiVuISNrH1675wiATF1QXbAN2cMFhgTEkGUukPLzGk,18095
9
+ gitstory_cli-0.2.2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
10
+ gitstory_cli-0.2.2.dist-info/entry_points.txt,sha256=QzZyAjIWf4IUVnAXFGjyjnH2l4xlmY5ds-lw8FSfnsM,47
11
+ gitstory_cli-0.2.2.dist-info/top_level.txt,sha256=denQpQjRKXIvG9BD9IasstMjq_aE4MXbfHV1oVJaKlo,9
12
+ gitstory_cli-0.2.2.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ gitstory = gitstory.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Calas Automations Inc.
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.
@@ -0,0 +1 @@
1
+ gitstory