Skip to content

Commit d02d51e

Browse files
docs: refresh README (usage, badges, donations) (#11)
1 parent 3ee5283 commit d02d51e

File tree

1 file changed

+261
-8
lines changed

1 file changed

+261
-8
lines changed

README.md

Lines changed: 261 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,273 @@
1-
# diff-risk-dashboard
1+
# diff-risk-dashboard — APV → Risk Summary (Python CLI)
22

3-
Visual dashboard for Pull Request risk exposure, designed to consume **ai-patch-verifier** JSON outputs.
3+
A lean, production-grade **Python CLI** that ingests **ai-patch-verifier (APV)** JSON and outputs a clear **risk summary** (table / JSON / Markdown).
4+
Designed for **always-green CI**, with strict checks and exit codes per risk level to gate merges professionally.
5+
6+
<div align="center">
7+
8+
[![CI / build](https://github.com/CoderDeltaLAN/diff-risk-dashboard/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/CoderDeltaLAN/diff-risk-dashboard/actions/workflows/build.yml)
9+
[![CodeQL Analysis](https://github.com/CoderDeltaLAN/diff-risk-dashboard/actions/workflows/codeql.yml/badge.svg?branch=main)](https://github.com/CoderDeltaLAN/diff-risk-dashboard/actions/workflows/codeql.yml)
10+
[![Release](https://img.shields.io/github/v/release/CoderDeltaLAN/diff-risk-dashboard?display_name=tag)](https://github.com/CoderDeltaLAN/diff-risk-dashboard/releases)
11+
![Python 3.11|3.12](https://img.shields.io/badge/Python-3.11%20|%203.12-3776AB?logo=python)
12+
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
13+
[![Donate](https://img.shields.io/badge/Donate-PayPal-0070ba?logo=paypal&logoColor=white)](https://www.paypal.com/donate/?hosted_button_id=YVENCBNCZWVPW)
14+
15+
</div>
16+
17+
---
18+
19+
## Repo layout
20+
21+
```text
22+
.
23+
├── examples/
24+
│ └── sample_apv.json # APV sample for demos/tests
25+
├── src/diff_risk_dashboard/
26+
│ ├── __main__.py # module entry
27+
│ ├── cli.py # CLI
28+
│ ├── core.py # summarization logic
29+
│ └── report.py # Markdown generator
30+
├── tests/ # pytest
31+
└── .github/workflows/ # CI + CodeQL + Release Drafter
32+
```
33+
34+
---
35+
36+
## 🚀 Quick Start (end users)
37+
38+
> Sin cambios en tu sistema ni shell. Usa el proyecto como **app Python** con su comando **`diff-risk`** tras instalarlo.
39+
40+
```bash
41+
# 1) Clonar
42+
git clone https://github.com/CoderDeltaLAN/diff-risk-dashboard.git
43+
cd diff-risk-dashboard
44+
45+
# 2) Instalar como paquete (aislado con pipx, o pip estándar)
46+
# Opción A (recomendada): pipx
47+
pipx install .
48+
# Opción B: pip usuario
49+
python -m pip install --user .
50+
51+
# 3) Usar el comando instalado
52+
diff-risk examples/sample_apv.json --format md --output report.md
53+
```
54+
55+
### CLI usage
56+
57+
```bash
58+
diff-risk -h
59+
```
60+
61+
```
62+
usage: diff_risk_dashboard [-h] [-f {table,json,md}] [-o OUTPUT]
63+
[--no-exit-by-risk]
64+
input
65+
66+
Diff Risk Dashboard (APV JSON -> summary)
67+
68+
positional arguments:
69+
input Path o texto JSON de ai-patch-verifier
70+
71+
options:
72+
-h, --help show this help message and exit
73+
-f {table,json,md}, --format {table,json,md}
74+
Formato de salida
75+
-o OUTPUT, --output OUTPUT
76+
Archivo de salida; '-' = stdout
77+
--no-exit-by-risk No ajustar el exit code por nivel de riesgo
78+
```
79+
80+
#### Examples
81+
82+
Table (por defecto, al stdout):
83+
84+
```bash
85+
diff-risk examples/sample_apv.json
86+
```
87+
88+
JSON (ideal para piping/automatización):
89+
90+
```bash
91+
diff-risk examples/sample_apv.json -f json
92+
```
93+
94+
Markdown a archivo (para adjuntar en PRs/Wikis):
95+
96+
```bash
97+
diff-risk examples/sample_apv.json -f md -o report.md
98+
```
99+
100+
Salida Markdown de ejemplo:
101+
102+
```md
103+
# Diff Risk Dashboard 🔴 — Worst: **HIGH**
104+
105+
| Severity | Count |
106+
|---|---:|
107+
| CRITICAL | 0 |
108+
| HIGH | 1 |
109+
| MEDIUM | 1 |
110+
| LOW | 1 |
111+
| INFO | 0 |
112+
| **TOTAL** | **3** |
113+
114+
> Generated by diff-risk-dashboard CLI
115+
```
116+
117+
---
118+
119+
## 📦 What the tool expects (APV JSON)
120+
121+
- Entrada: JSON con findings tipo APV, ej. objetos que incluyen `predicted_risk` (`low|medium|high`).
122+
- El sumario **normaliza mayúsculas/minúsculas** y calcula:
123+
- `total`
124+
- `by_severity` (claves `CRITICAL|HIGH|MEDIUM|LOW|INFO` y también minúsculas)
125+
- `worst`
126+
- `risk_level` (`red|yellow|green`)
127+
128+
Ejemplo de salida `-f json`:
129+
130+
```json
131+
{
132+
"total": 3,
133+
"by_severity": {
134+
"critical": 0,
135+
"high": 1,
136+
"medium": 1,
137+
"low": 1,
138+
"info": 0,
139+
"CRITICAL": 0,
140+
"HIGH": 1,
141+
"MEDIUM": 1,
142+
"LOW": 1,
143+
"INFO": 0
144+
},
145+
"worst": "HIGH",
146+
"risk_level": "red"
147+
}
148+
```
149+
150+
---
151+
152+
## ⛳ Exit codes (CI gating)
153+
154+
- `green`**0**
155+
- `yellow`**1**
156+
- `red`**2**
157+
158+
Por defecto, el proceso **sale** con el código según `risk_level`.
159+
Para desactivar este comportamiento (p.ej., en local o cuando solo generas reportes):
4160

5-
## Quick Start
6161
```bash
7-
poetry install
8-
poetry run drd summarize examples/sample_apv.json
162+
diff-risk examples/sample_apv.json --no-exit-by-risk
9163
```
10164

11-
## Run checks (mirrors CI)
165+
---
166+
167+
## 🧪 Local Developer Workflow (mirrors CI)
168+
12169
```bash
170+
# Requisitos de desarrollo
171+
python -m pip install --upgrade pip
172+
pip install poetry
173+
174+
# Instalar deps
175+
poetry install --no-interaction
176+
177+
# Gates locales
13178
poetry run ruff check .
14179
poetry run black --check .
15180
PYTHONPATH=src poetry run pytest -q
16181
poetry run mypy src
17182
```
18183

19-
## License
20-
MIT
184+
---
185+
186+
## 🔧 CI (GitHub Actions)
187+
188+
- Matriz **Python 3.11 / 3.12** alineada con los gates locales.
189+
- **CodeQL** en PRs y `main`.
190+
- **Release Drafter** para changelog/release notes.
191+
- **Branch protection** y merges seguros (historial lineal via squash).
192+
193+
Fragmento típico del job Python:
194+
195+
```yaml
196+
- run: python -m pip install --upgrade pip
197+
- run: pip install poetry
198+
- run: poetry install --no-interaction
199+
- run: poetry run ruff check .
200+
- run: poetry run black --check .
201+
- env:
202+
PYTHONPATH: src
203+
run: poetry run pytest -q
204+
- run: poetry run mypy src
205+
# Ejemplo de uso del CLI en CI:
206+
- run: poetry run python -m pip install .
207+
- run: diff-risk examples/sample_apv.json -f md -o report.md
208+
```
209+
210+
---
211+
212+
## 🗺 When to Use This Project
213+
214+
- Necesitas **resumen de riesgo** claro y portable a partir de **APV**.
215+
- Quieres **bloquear merges** cuando el riesgo supera el umbral (exit codes).
216+
- Buscas **reportes en Markdown/JSON** para PRs, auditorías y tableros.
217+
218+
---
219+
220+
## 🧩 Customization
221+
222+
- Genera tus propios APV JSON y pásalos como `input`.
223+
- Cambia el formato con `--format` (**table/json/md**) y redirige a archivo con `--output`.
224+
- Integra el JSON de salida con otras herramientas o dashboards.
225+
226+
---
227+
228+
## 🔒 Security
229+
230+
- Sin cambios en tu shell o sistema: **no** requiere editar `.zshrc` ni configuración del usuario.
231+
- CodeQL activo; se recomienda usar repos **privados** para datos sensibles.
232+
- No subas JSON con información confidencial a PRs públicos.
233+
234+
---
235+
236+
## 🙌 Contributing
237+
238+
- PRs pequeños y atómicos, estilo **Conventional Commits**.
239+
- Mantén los **gates** verdes antes de solicitar revisión.
240+
- Activa **auto-merge** cuando pasen los checks.
241+
242+
---
243+
244+
## 💚 Donations & Sponsorship
245+
246+
If this project saves you time, consider supporting ongoing maintenance. Thank you!
247+
[![Donate](https://img.shields.io/badge/Donate-PayPal-0070ba?logo=paypal&logoColor=white)](https://www.paypal.com/donate/?hosted_button_id=YVENCBNCZWVPW)
248+
249+
---
250+
251+
## 🔎 SEO Keywords
252+
253+
apv risk summary cli, ai patch verifier json, diff risk dashboard python,
254+
markdown security report, always green ci python, ruff black pytest mypy,
255+
github actions codeql release drafter, branch protection required checks,
256+
console scripts professional cli ux
257+
258+
---
259+
260+
## 👤 Author
261+
262+
**CoderDeltaLAN (Yosvel)**
263+
GitHub: https://github.com/CoderDeltaLAN
264+
265+
---
266+
267+
## 📄 License
268+
269+
Released under the **MIT License**. See [LICENSE](LICENSE).
270+
271+
---
272+
273+
**Download this README**: This same file can be downloaded from the chat link.

0 commit comments

Comments
 (0)