Skip to content

Commit 70b785c

Browse files
committed
feat(docs): document history trends command and add chart example
- Add trend analysis section and CLI examples to README - Add `history trends` command docs with metrics/options and image export notes - Include trends example image asset and switch logo to raw GitHub URL - Add `viz` extra (matplotlib) and update lockfile dependencies
1 parent eb2d671 commit 70b785c

4 files changed

Lines changed: 774 additions & 2 deletions

File tree

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<p align="center">
2-
<img src="assets/logo-ascii.png" alt="Pacta" width="400">
2+
<img src="https://raw.githubusercontent.com/akhundMurad/pacta/main/assets/logo-ascii.png" alt="Pacta" width="400">
33
</p>
44

55
<p align="center">
@@ -46,6 +46,7 @@ Codebases rot. The "clean architecture" you designed becomes spaghetti after a f
4646
- **Baseline mode** — fail only on *new* violations, not legacy debt
4747
- **Snapshots** — version your architecture like code
4848
- **History tracking** — view architecture evolution over time
49+
- **Trend analysis** — track violations, nodes, edges over time with charts
4950

5051
## Quick example
5152

@@ -121,10 +122,20 @@ a1b2c3d4 2025-01-22 abc1234 main 42 nodes 87 edges 2 violations (latest)
121122
e5f6g7h8 2025-01-20 def5678 main 42 nodes 85 edges 4 violations
122123
...
123124
125+
# View trends over time
126+
$ pacta history trends . --metric violations
127+
128+
# Export chart as image (requires pacta[viz])
129+
$ pacta history trends . --output trends.png
130+
124131
# Export for external tools
125132
pacta history export --format json > history.json
126133
```
127134

135+
<p align="center">
136+
<img src="https://raw.githubusercontent.com/akhundMurad/pacta/main/assets/trends-example.png" alt="Trends Chart" width="600">
137+
</p>
138+
128139
## Docs
129140

130141
- [CLI Reference](https://akhundmurad.github.io/pacta/cli/)
@@ -135,6 +146,7 @@ pacta history export --format json > history.json
135146

136147
- [x] Open-source CLI and analysis engine
137148
- [x] Content-addressed snapshots with history tracking
149+
- [x] Trend analysis with chart export
138150
- [ ] Architecture visualization (Mermaid, D2)
139151
- [ ] Health metrics (drift score, instability)
140152
- [ ] Proprietary hosted service with:

assets/trends-example.png

68.4 KB
Loading

docs/cli.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,95 @@ pacta history export . -o export.json
206206
}
207207
```
208208

209+
## history trends
210+
211+
Show metric trends over time with ASCII charts or export as images.
212+
213+
```bash
214+
pacta history trends [PATH] [OPTIONS]
215+
```
216+
217+
**Options:**
218+
219+
| Option | Default | Description |
220+
|--------|---------|-------------|
221+
| `--metric {violations,nodes,edges,density}` | `violations` | Metric to track |
222+
| `--last N` | - | Show only last N entries |
223+
| `--since DATE` | - | Show entries since date (ISO-8601) |
224+
| `--branch NAME` | - | Filter by branch name |
225+
| `--width N` | `60` | Chart width in characters |
226+
| `--format {text,json}` | `text` | Output format |
227+
| `-o, --output FILE` | - | Export chart as image (PNG/SVG) |
228+
229+
**Metrics:**
230+
231+
| Metric | Description |
232+
|--------|-------------|
233+
| `violations` | Total violation count (default) |
234+
| `nodes` | Architecture component count |
235+
| `edges` | Dependency count |
236+
| `density` | Coupling ratio (edges/nodes) |
237+
238+
**Examples:**
239+
240+
```bash
241+
# Show violation trends (default)
242+
pacta history trends .
243+
244+
# Show node count trends
245+
pacta history trends . --metric nodes
246+
247+
# Show density trends (edges/nodes ratio)
248+
pacta history trends . --metric density
249+
250+
# Filter by branch and limit
251+
pacta history trends . --branch main --last 10
252+
253+
# JSON output for scripting
254+
pacta history trends . --format json
255+
256+
# Export as PNG image (requires pacta[viz])
257+
pacta history trends . --output trends.png
258+
259+
# Export as SVG for docs/presentations
260+
pacta history trends . --metric violations --output violations.svg
261+
```
262+
263+
**Image Export:**
264+
265+
To export charts as images, install the visualization extras:
266+
267+
```bash
268+
pip install pacta[viz]
269+
```
270+
271+
This adds matplotlib support for PNG, SVG, and PDF export.
272+
273+
![Trends Example](https://raw.githubusercontent.com/akhundMurad/pacta/main/assets/trends-example.png)
274+
275+
**Example output:**
276+
277+
```
278+
Violations Trend (5 entries)
279+
============================
280+
281+
5 | *
282+
4 | * *
283+
3 | *
284+
2 | *
285+
1 |
286+
0 |
287+
+--------------------
288+
Jan 15 Jan 22
289+
290+
Trend: Improving (-3 over period)
291+
First: 4 violations (Jan 15)
292+
Last: 2 violations (Jan 22)
293+
294+
Average: 3 violations
295+
Min: 2, Max: 5
296+
```
297+
209298
## Exit Codes
210299

211300
| Code | Meaning |

0 commit comments

Comments
 (0)