Repository navigation
feat(stats): count what a branch changed by kind of file with --since - #42
Merged
Merged
Conversation
`cella stats` counts the whole repository, so it could not say where a pull request's lines went. `cella stats --since <ref>` counts what the current branch committed since it left the ref, which is what a pull request into that ref shows: - one row per kind of file: source, tests, stories, generated, json, docs, other - the source lines split into code, comments and blank, read from a zero-context patch - the source lines per workspace package - `--md` prints the table as markdown on stdout for a PR description; `-V` lists every file Every file in a diff counts, so beyond the snapshot's categories this knows docs (`md`, `mdx`) and a rest group, and reads a lock file as generated. A diff shows changed lines only, so a comment is recognized by how its line starts. Uncommitted files are reported as not counted. The mode lives in its own file, `services/stats-since.ts`; `stats.ts` only exports the classifier and the workspace lookup it shares. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
flipvh
added a commit
that referenced
this pull request
Oct 8, 2026
…review Brings in stats --since (#42). Conflicts resolved by keeping this branch's structure and wording and adding #42's feature on top: - src/cli.ts: since/md read through the str()/flag() helpers; --md joins the machine-output modes next to the audit --list exception - src/cella-cli.ts: braced stats case, runStats(config) for the snapshot mode, runBranchStats for --since - src/services/stats.ts: this branch's comments, plus the exports stats-since.ts imports - README.md: this branch's wording, plus the --since row and section Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cella statscounts the whole repository, so it cannot say where a pull request's lines went. This adds a branchmode that can, as the tool behind a rule for cella's
AGENTS.md: a PR that grows the codebase says which kind oflines grew and why.
Run on cella#1331, which shows as +722 −121 on GitHub:
72% of that PR's growth is tests and 65 lines are new code, which the raw count hides.
How it counts
HEADand the ref: the same diff a pull request into thatref shows. Uncommitted files are reported as not counted.
lock files. So this adds
docs(md,mdx) andotherto the snapshot's categories and reads a lock file asgenerated. The snapshot's own classifier is reused unchanged for everything else.recognized by how its line starts (
//,/*,*,{/*). The parser follows each hunk header's line counts, so achanged line that itself starts with
+++is not taken for a file header. The three parts add up to the numstattotals of the source files; a test checks that on a real repo.
--mduses the existing machine-output mode: header, warnings and spinner go to stderr, the table to stdout.Things to check
--since <ref>, not--diff.--diff <path>already prints one file's patch inanalyzeandcontributions. The ref is required: a default would have to guess betweenmainandorigin/main, and a stalelocal
maincounts other people's commits as the branch's.stats.ts,cli.ts,cella-cli.tsandtypes.ts. The mode lives in itsown file,
services/stats-since.ts, and touches those four by a few lines each (fiveexportkeywords, two optiondefinitions, two config fields, one dispatch). Whichever merges second needs a small rebase.
calling
collectBranchStatsandformatMarkdowndirectly.Verification
pnpm checkclean.pnpm test: 282 passed, 27 files. Newtests/stats-since.test.tscovers the classifiers, bothparsers on literal git output (binary files, quoted paths, a hunk line that looks like a header), and the collector on
a real repo: kinds, content split, package split, merge base after the ref moved on, uncommitted work left out. The
built binary was run against cella#1331's branch for the output above, plus the two error paths (
--mdwithout--since, an unknown ref) and the unchanged snapshot mode.Size
Source lines by content: code +281, comments +52, blank +55.
formatters (terminal tables, markdown). The shared files grow by 30 lines of wiring.
cli.test.ts.🤖 Generated with Claude Code