Skip to content

Commit 31bcdae

Browse files
mitchdennyCopilot
andauthored
Add LOC breakdown canvas extension (#17829)
* Add LOC breakdown canvas extension A project-scoped Copilot CLI canvas that breaks down the lines of code changed on the current branch by project/category, sorts by total churn, and tags each category with a heuristic review characterization (mechanical / documentation / detailed / careful). Lives in .github/extensions/loc-breakdown so anyone using Copilot CLI in this repo picks it up automatically. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address review feedback: drop unused import, validate refs - Remove unused 'node:path' import. - Reject user-supplied base/head refs that start with '-' or contain characters outside the safe set, before passing them to git. Prevents option-injection if a caller passes e.g. '--upload-pack=evil' as a ref. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add screenshot of LOC breakdown canvas to README Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f8eca3a commit 31bcdae

3 files changed

Lines changed: 598 additions & 0 deletions

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# LOC breakdown canvas extension
2+
3+
A Copilot CLI canvas extension that shows a breakdown of the lines of code
4+
changed in the current branch, grouped by project/category, with a heuristic
5+
characterization of each group (mechanical / detailed / careful review etc).
6+
7+
![Screenshot of the LOC breakdown canvas](screenshot.png)
8+
9+
## What it does
10+
11+
When opened, the canvas:
12+
13+
1. Resolves the merge-base of the current branch against `origin/HEAD` (or
14+
`main`/`master` as a fallback).
15+
2. Runs `git diff --numstat` between that merge-base and `HEAD`.
16+
3. Groups files into buckets that reflect the Aspire repo layout — each
17+
`src/<Project>`, `src/Components/<Component>`, `tests/<Suite>`,
18+
`playground/<App>`, `tools/<Tool>`, plus catch-all buckets for
19+
`docs`, `eng`, `.github`, the VS Code extension, and `.agents`.
20+
4. Sorts categories by total lines touched (added + removed), descending.
21+
5. Tags each category with a short characterization derived from file types
22+
and the add/remove ratio:
23+
24+
| Tone | Examples |
25+
|------|----------|
26+
| Mechanical | localization, generated files, snapshots, assets, trivial edits |
27+
| Documentation | `.md`/`.mdx`/`.txt` only |
28+
| Detailed | tests, small additions, moderate edits |
29+
| Careful | CI workflows, significant new code, large removals, big refactors |
30+
31+
Rows are expandable to show the per-file added/removed counts within a
32+
category.
33+
34+
## Usage
35+
36+
In any Copilot CLI session inside this repo, ask the agent to open the
37+
"LOC breakdown" canvas (or any phrasing that implies wanting a per-project
38+
summary of the diff). The canvas has a ↻ Refresh button and a `refresh`
39+
action the agent can invoke to recompute the report.
40+
41+
Optional inputs when opening the canvas:
42+
43+
- `cwd` — working directory inside a git repo (defaults to the agent's cwd)
44+
- `base` — base ref to diff against (defaults to `origin/HEAD`)
45+
- `head` — head ref (defaults to `HEAD`)
46+
47+
## Implementation notes
48+
49+
- Single-file extension; no dependencies beyond the Node.js standard library
50+
and `@github/copilot-sdk/extension`.
51+
- Spins up a loopback HTTP server on an ephemeral port per canvas instance
52+
and tears it down on close.
53+
- The HTML shell fetches `/data` and renders client-side, so refresh is
54+
cheap and doesn't require restarting the server.
55+
56+
## Discovery
57+
58+
Project-scoped extensions in `.github/extensions/` are picked up
59+
automatically by the Copilot CLI for anyone working in this repo — no
60+
install step is required.

0 commit comments

Comments
 (0)