gitpr-cli 1.6.0__py3-none-any.whl → 1.7.0__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.
- {gitpr_cli-1.6.0.dist-info → gitpr_cli-1.7.0.dist-info}/METADATA +2 -2
- {gitpr_cli-1.6.0.dist-info → gitpr_cli-1.7.0.dist-info}/RECORD +13 -12
- src/ascii_chart.py +248 -0
- src/config.py +2 -0
- src/config_schema.py +110 -0
- src/core.py +8 -0
- src/ui/config_app.py +1 -0
- src/ui/metrics_app.py +118 -21
- src/updater.py +2 -2
- {gitpr_cli-1.6.0.dist-info → gitpr_cli-1.7.0.dist-info}/WHEEL +0 -0
- {gitpr_cli-1.6.0.dist-info → gitpr_cli-1.7.0.dist-info}/entry_points.txt +0 -0
- {gitpr_cli-1.6.0.dist-info → gitpr_cli-1.7.0.dist-info}/licenses/LICENSE +0 -0
- {gitpr_cli-1.6.0.dist-info → gitpr_cli-1.7.0.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gitpr-cli
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.7.0
|
|
4
4
|
Summary: AI-powered PR automation, commit messages, and code review (Gemini, DeepSeek, and Ollama)
|
|
5
5
|
Author-email: Natan Fiuza <contato@natanfiuza.dev.br>
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -499,7 +499,7 @@ This is useful for scripting, CI/CD pipelines, and one-off queries where you don
|
|
|
499
499
|
|
|
500
500
|
📖 **Full documentation:** [gitpr.natanfiuza.dev.br/docs/mcp-integration](https://gitpr.natanfiuza.dev.br/docs/mcp-integration) — available in 5 languages (EN, PT-BR, PT-PT, ES, FR).
|
|
501
501
|
|
|
502
|
-
> 🧩 **Official VS Code & Cursor Extension** — Prefer native editor commands, SCM toolbar buttons, and inline `Problems` diagnostics?
|
|
502
|
+
> 🧩 **Official VS Code & Cursor Extension** — Prefer native editor commands, SCM toolbar buttons, and inline `Problems` diagnostics? Download the ready-to-use `.vsix` from [GitHub Releases](https://github.com/natanfiuza/gitpr/releases) or see the [Editor Extension Guide](https://gitpr.natanfiuza.dev.br/docs/editor-extension) for 1-click install in VS Code and Cursor.
|
|
503
503
|
|
|
504
504
|
> 💬 **MCP Prompts** — GitPR also exposes 7 pre-defined message templates (prompts) for common flows like "Review PR", "Generate Commit Message", and "Create Issue from Diff". See the [MCP Prompts guide](https://gitpr.natanfiuza.dev.br/docs/mcp-prompts) for the full list.
|
|
505
505
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
gitpr_cli-1.
|
|
1
|
+
gitpr_cli-1.7.0.dist-info/licenses/LICENSE,sha256=UQzLC6mwqb-ZNDkBBAqOxC-SMQcEID0gaM6oFcu6u48,27030
|
|
2
2
|
src/__init__.py,sha256=ZHymXsocMDazI_fjOIgAQsRQvFPN2tV8FOuv0qptI_o,30
|
|
3
3
|
src/ai_providers.py,sha256=QyFEOsXyA59lZziO5bl-4nlYFJpxBcxU9aLhcTBnkWE,14633
|
|
4
|
+
src/ascii_chart.py,sha256=WFQclaxm5W6bPBBNVlImyrnrJYCSj5gRgEpldYzI7wk,8279
|
|
4
5
|
src/blame_engine.py,sha256=Zov1hxrt7Dcmf56ovJKz3QmHIfzDKtSub2iItXeg9-A,17104
|
|
5
6
|
src/cache.py,sha256=frROc69NyTn3TdJIOPctvuH9z_sh2pdKxL4ekMtyh6k,6572
|
|
6
7
|
src/changelog_builder.py,sha256=Ea0coS6LCqsdxTWrKW8SZyVsD02HuNNYzCoggI0loi8,9922
|
|
7
8
|
src/chat_memory.py,sha256=PcohnyspAfIwwwbsp9U2Wk_1AylJMFEMoWqRSJe_w30,8949
|
|
8
9
|
src/commit_classifier.py,sha256=HQHxPbCfgW_GD1_4mbO2No16jh_Ci5RTSoLbTU4IWYI,6920
|
|
9
|
-
src/config.py,sha256=
|
|
10
|
-
src/config_schema.py,sha256=
|
|
11
|
-
src/core.py,sha256=
|
|
10
|
+
src/config.py,sha256=MrfZW27x-41gI9P8gtAyMuTryzeluBtvZfxRZkVIiBk,47122
|
|
11
|
+
src/config_schema.py,sha256=VATmOHWs_eeMLVhrtGFANcOVdrYwSadiFPUUhZM33OE,58091
|
|
12
|
+
src/core.py,sha256=RmwqnEa0-lEHKpxCIH95JLJkJQGsfx_QC8n8H_uJitQ,99037
|
|
12
13
|
src/diff_parser.py,sha256=JHeaTJflNOEbR9SYK_Ljr2hctrrABUIb31IFHAbyIDo,15405
|
|
13
14
|
src/doc_links.py,sha256=GdANhE6XbEnVDsbpCf22eUZnqFXor_2SU1O4S-pteIE,2028
|
|
14
15
|
src/github_api.py,sha256=i1o58oKWWmMCerP-g-hOQHGCwPWd01ooKntTKjpFhIA,3948
|
|
@@ -32,7 +33,7 @@ src/skill_frontmatter.py,sha256=K-HsjwSYPHUsDRjIiugBE3koxVdGf38L5d4l8eYVqEo,2167
|
|
|
32
33
|
src/spinner.py,sha256=JGOO_taTXbrQK0KnNxUQ40PcpS802bYYBosWWm_NG9o,9012
|
|
33
34
|
src/suggest_reviewers.py,sha256=LTOtwDIjaBS_FGDU6bjN6oGy-YD112hIPugYytNKD_A,5821
|
|
34
35
|
src/tui_issue.py,sha256=yaNpj9SSXiWWjMJ7a9FABcNWSffCkA1tjUSnJ1hN-MQ,11477
|
|
35
|
-
src/updater.py,sha256=
|
|
36
|
+
src/updater.py,sha256=8OwxL8hhh-hzKyQo5sjckw_e4bNlmlKeegwwH35nrG8,9560
|
|
36
37
|
src/usage_log.py,sha256=CBCNlUm_xftXsBaGRHvsEjTENvZfE-lW70HGLMkisSg,4508
|
|
37
38
|
src/version_bump.py,sha256=Dw1LZ_c6VzaO_s9cDeYSevoWtXVr_oP70eS_mkrOm8s,3041
|
|
38
39
|
src/application/__init__.py,sha256=3YXFcmxJh0f7BwryKXxUrOhGrLnZLsagV-VbBIk0eGk,31
|
|
@@ -163,11 +164,11 @@ src/split/split_plan.py,sha256=Y0Ah3LbzixKgAy74dh7XiQImsw6-f2dxwfJSkQHreCw,6572
|
|
|
163
164
|
src/ui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
164
165
|
src/ui/chat_app.py,sha256=eOhGsaC2EweYNJe9kdCbN9AMYcN_LI2BCj_tmOYZ7Bs,26789
|
|
165
166
|
src/ui/commit_app.py,sha256=mggIsdHkg3EIvQoSc11XL7tpkSGJ25WWszHdgmJnMjc,8304
|
|
166
|
-
src/ui/config_app.py,sha256=
|
|
167
|
+
src/ui/config_app.py,sha256=thlCw2E8DungQf2W8DoATT2RFioq_vmsyS_IM2nsybo,94671
|
|
167
168
|
src/ui/help_screen.py,sha256=PxdLLey13DycZpIY0nj2Zd0DSF1uV02Gcrq3Ny88CuU,1723
|
|
168
169
|
src/ui/issue_app.py,sha256=ea8RYK0QcS9izoJ9e60TTTznOX8QVhMREW_GQEyi_xM,10192
|
|
169
170
|
src/ui/linter_app.py,sha256=xVMMZJhVQAo6XKI_MrRQvnGXNoDjELRs7k8rNaF4yws,1602
|
|
170
|
-
src/ui/metrics_app.py,sha256=
|
|
171
|
+
src/ui/metrics_app.py,sha256=8zbCVwTMN8k6uDHpbXlzBxd1EFIFaDTPDyH4h-0bdXY,20618
|
|
171
172
|
src/ui/metrics_migration_app.py,sha256=U6l-ORUk1NlC2aIQSLvFjahMVM1dat-wFjWlct0fRYQ,6096
|
|
172
173
|
src/ui/pr_base_app.py,sha256=OvPcQVeyBrGBH8lhlVy0Ks1kVdvqcYHl7Zc3P2tXPGI,3857
|
|
173
174
|
src/ui/pr_publish_app.py,sha256=TU5IrSB3bkQEhl2N0W8KCwHfRGGacijqziMD9I7By04,71802
|
|
@@ -176,8 +177,8 @@ src/ui/demo/__init__.py,sha256=aOdUN0izuwW2FfLAHG9Qga-DJG5NBVqP0gYNO8OiKls,59
|
|
|
176
177
|
src/ui/demo/demo_app.py,sha256=4t_Mct-BJXpe5tlt1XmtRyN1IT0OL6U3WSmGqOJqMG4,3165
|
|
177
178
|
src/ui/demo/demo_help_screen.py,sha256=I_LELswhPtbHjfMWGVUqLtOwxGbzSYJsVWXjqZrLoLA,2108
|
|
178
179
|
src/ui/demo/demo_screens.py,sha256=GXaQFTgTn9awSP-EYiBXsCZqB583WrSQcuNYoBK12g8,1997
|
|
179
|
-
gitpr_cli-1.
|
|
180
|
-
gitpr_cli-1.
|
|
181
|
-
gitpr_cli-1.
|
|
182
|
-
gitpr_cli-1.
|
|
183
|
-
gitpr_cli-1.
|
|
180
|
+
gitpr_cli-1.7.0.dist-info/METADATA,sha256=hpoCCrRp4v_yMf_v7Pqsg4YtA0nVWFha4N2JugWwr7E,54113
|
|
181
|
+
gitpr_cli-1.7.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
182
|
+
gitpr_cli-1.7.0.dist-info/entry_points.txt,sha256=TstGnMUzdOI5qNmpM97EPDBPuMqOZxoo6EoLxHSOMSQ,71
|
|
183
|
+
gitpr_cli-1.7.0.dist-info/top_level.txt,sha256=74rtVfumQlgAPzR5_2CgYN24MB0XARCg0t-gzk6gTrM,4
|
|
184
|
+
gitpr_cli-1.7.0.dist-info/RECORD,,
|
src/ascii_chart.py
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ASCII / Unicode 2D Chart Rendering Engine for GitPR Metrics.
|
|
3
|
+
|
|
4
|
+
Provides pure functions to render 2D terminal charts (vertical histograms,
|
|
5
|
+
time-series charts) without external dependencies or UI framework coupling.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import math
|
|
9
|
+
from typing import Any, Dict, List, Optional
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _fmt_tokens(val: float) -> str:
|
|
13
|
+
"""Format token count in human-readable compact form (e.g. 1.2M, 45.0k, 500)."""
|
|
14
|
+
if val >= 1_000_000:
|
|
15
|
+
return f"{val / 1_000_000:.1f}M"
|
|
16
|
+
if val >= 1_000:
|
|
17
|
+
return f"{val / 1_000:.1f}k"
|
|
18
|
+
return str(int(round(val)))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _duration_ms_label(ms: Optional[float]) -> str:
|
|
22
|
+
"""Format duration in milliseconds into ms, s, or min."""
|
|
23
|
+
if ms is None:
|
|
24
|
+
return "0 ms"
|
|
25
|
+
if ms < 1000:
|
|
26
|
+
return f"{ms:.0f} ms"
|
|
27
|
+
seconds = ms / 1000.0
|
|
28
|
+
if seconds < 60:
|
|
29
|
+
return f"{seconds:.1f} s"
|
|
30
|
+
return f"{seconds / 60.0:.1f} min"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def render_empty_card(title: str, message: str, width: int = 60) -> str:
|
|
34
|
+
"""Render a framed empty-state banner with informative text."""
|
|
35
|
+
w = max(40, width)
|
|
36
|
+
inner_w = w - 4
|
|
37
|
+
top_border = f"┌{'─' * (w - 2)}┐"
|
|
38
|
+
bottom_border = f"└{'─' * (w - 2)}┘"
|
|
39
|
+
empty_line = f"│ {' ' * inner_w} │"
|
|
40
|
+
|
|
41
|
+
title_line = f"│ [bold cyan]{title:<{inner_w}}[/bold cyan] │"
|
|
42
|
+
msg_line = f"│ [yellow]{message:<{inner_w}}[/yellow] │"
|
|
43
|
+
|
|
44
|
+
return "\n".join([top_border, title_line, empty_line, msg_line, bottom_border])
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def render_vertical_histogram(
|
|
48
|
+
latency: Optional[Dict[str, Any]],
|
|
49
|
+
height: int = 7,
|
|
50
|
+
col_width: int = 7,
|
|
51
|
+
) -> str:
|
|
52
|
+
"""Render a 2D vertical ASCII histogram for latency distributions.
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
latency: Dict from latency_report() containing 'count', 'average_ms',
|
|
56
|
+
'median_ms', 'p95_ms', and 'buckets'.
|
|
57
|
+
height: Height in lines for the plotting area.
|
|
58
|
+
col_width: Character width of each column bar.
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
Formatted multi-line string containing the 2D chart.
|
|
62
|
+
"""
|
|
63
|
+
if not latency or not latency.get("count") or not latency.get("buckets"):
|
|
64
|
+
return render_empty_card(
|
|
65
|
+
"📊 Latency Distribution",
|
|
66
|
+
"No timed executions recorded in the selected window.",
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
buckets: List[Dict[str, Any]] = latency["buckets"]
|
|
70
|
+
counts = [b["count"] for b in buckets]
|
|
71
|
+
max_count = max(counts) if counts else 0
|
|
72
|
+
if max_count <= 0:
|
|
73
|
+
max_count = 1
|
|
74
|
+
|
|
75
|
+
count_total = latency.get("count", 0)
|
|
76
|
+
avg_lbl = _duration_ms_label(latency.get("average_ms"))
|
|
77
|
+
med_lbl = _duration_ms_label(latency.get("median_ms"))
|
|
78
|
+
p95_lbl = _duration_ms_label(latency.get("p95_ms"))
|
|
79
|
+
|
|
80
|
+
lines: List[str] = []
|
|
81
|
+
|
|
82
|
+
# Title & Summary header
|
|
83
|
+
lines.append("[bold cyan]📊 Latency Histogram[/bold cyan]")
|
|
84
|
+
lines.append(
|
|
85
|
+
f" Timed runs: [bold]{count_total}[/bold] │ "
|
|
86
|
+
f"Average: [cyan]{avg_lbl}[/cyan] │ "
|
|
87
|
+
f"Median (P50): [green]{med_lbl}[/green] │ "
|
|
88
|
+
f"P95: [yellow]{p95_lbl}[/yellow]"
|
|
89
|
+
)
|
|
90
|
+
lines.append("")
|
|
91
|
+
|
|
92
|
+
# Y-axis label formatting width
|
|
93
|
+
y_label_width = max(len(str(max_count)), 3)
|
|
94
|
+
|
|
95
|
+
# Plot rows from top (height) down to 1
|
|
96
|
+
for r in range(height, 0, -1):
|
|
97
|
+
# Y-axis tick mark and label
|
|
98
|
+
ratio = r / height
|
|
99
|
+
level_val = round(ratio * max_count)
|
|
100
|
+
if r == height:
|
|
101
|
+
y_tick = f"{max_count:>{y_label_width}} ┤"
|
|
102
|
+
elif r == math.ceil(height / 2):
|
|
103
|
+
half_val = round(max_count / 2)
|
|
104
|
+
y_tick = f"{half_val:>{y_label_width}} ┤"
|
|
105
|
+
else:
|
|
106
|
+
y_tick = f"{' ' * y_label_width} │"
|
|
107
|
+
|
|
108
|
+
# Build column cells
|
|
109
|
+
cells = []
|
|
110
|
+
for b_count in counts:
|
|
111
|
+
# Thresholds for full block and half block
|
|
112
|
+
val_ratio = b_count / max_count
|
|
113
|
+
if val_ratio >= (r / height):
|
|
114
|
+
# Full block
|
|
115
|
+
bar_chars = "█" * col_width
|
|
116
|
+
elif val_ratio >= ((r - 0.5) / height):
|
|
117
|
+
# Half block
|
|
118
|
+
bar_chars = "▄" * col_width
|
|
119
|
+
else:
|
|
120
|
+
bar_chars = " " * col_width
|
|
121
|
+
|
|
122
|
+
cells.append(bar_chars)
|
|
123
|
+
|
|
124
|
+
row_content = " ".join(cells)
|
|
125
|
+
lines.append(f" {y_tick} {row_content}")
|
|
126
|
+
|
|
127
|
+
# X-axis Baseline
|
|
128
|
+
base_col = "─" * col_width
|
|
129
|
+
x_axis_line = "───".join([base_col] * len(buckets))
|
|
130
|
+
lines.append(f" {0:>{y_label_width}} ┴─{x_axis_line}─")
|
|
131
|
+
|
|
132
|
+
# Bucket Labels
|
|
133
|
+
label_cells = []
|
|
134
|
+
for b in buckets:
|
|
135
|
+
lbl = b.get("label", "")
|
|
136
|
+
label_cells.append(f"{lbl:^{col_width}}")
|
|
137
|
+
lines.append(f" {' ' * y_label_width} " + " ".join(label_cells))
|
|
138
|
+
|
|
139
|
+
# Counts and percentages below labels
|
|
140
|
+
stat_cells = []
|
|
141
|
+
for b in buckets:
|
|
142
|
+
c = b.get("count", 0)
|
|
143
|
+
rate = b.get("rate", 0.0)
|
|
144
|
+
txt = f"{c} ({rate:.0%})"
|
|
145
|
+
stat_cells.append(f"{txt:^{col_width}}")
|
|
146
|
+
lines.append(f" {' ' * y_label_width} " + " ".join(stat_cells))
|
|
147
|
+
|
|
148
|
+
return "\n".join(lines)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def render_token_timeseries(
|
|
152
|
+
trend: Optional[Dict[str, Any]],
|
|
153
|
+
height: int = 7,
|
|
154
|
+
col_width: int = 5,
|
|
155
|
+
) -> str:
|
|
156
|
+
"""Render a 2D continuous ASCII time-series chart for daily token trends.
|
|
157
|
+
|
|
158
|
+
Args:
|
|
159
|
+
trend: Dict from token_trend_report() containing 'days', 'total_tokens',
|
|
160
|
+
'peak_tokens', 'average_tokens', and 'sparkline'.
|
|
161
|
+
height: Height in lines for the plotting area.
|
|
162
|
+
col_width: Character width allocated per day column.
|
|
163
|
+
|
|
164
|
+
Returns:
|
|
165
|
+
Formatted multi-line string containing the 2D chart.
|
|
166
|
+
"""
|
|
167
|
+
if not trend or not trend.get("days") or not trend.get("total_tokens"):
|
|
168
|
+
return render_empty_card(
|
|
169
|
+
"📈 Token Trend & Consumption",
|
|
170
|
+
"No token consumption recorded in the selected window.",
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
days: List[Dict[str, Any]] = trend["days"]
|
|
174
|
+
peak_tokens = trend.get("peak_tokens", 0)
|
|
175
|
+
total_tokens = trend.get("total_tokens", 0)
|
|
176
|
+
avg_tokens = trend.get("average_tokens", 0.0)
|
|
177
|
+
sparkline = trend.get("sparkline", "")
|
|
178
|
+
|
|
179
|
+
if peak_tokens <= 0:
|
|
180
|
+
peak_tokens = 1
|
|
181
|
+
|
|
182
|
+
lines: List[str] = []
|
|
183
|
+
|
|
184
|
+
# Title & Summary header
|
|
185
|
+
lines.append("[bold cyan]📈 Token Consumption Trend[/bold cyan]")
|
|
186
|
+
lines.append(
|
|
187
|
+
f" Total: [bold]{total_tokens:,}[/bold] │ "
|
|
188
|
+
f"Peak: [yellow]{peak_tokens:,}[/yellow] │ "
|
|
189
|
+
f"Daily Avg: [green]{avg_tokens:,.0f}[/green] │ "
|
|
190
|
+
f"Sparkline: {sparkline}"
|
|
191
|
+
)
|
|
192
|
+
lines.append("")
|
|
193
|
+
|
|
194
|
+
y_label_top = _fmt_tokens(peak_tokens)
|
|
195
|
+
y_label_mid = _fmt_tokens(peak_tokens / 2)
|
|
196
|
+
y_label_width = max(len(y_label_top), len(y_label_mid), 4)
|
|
197
|
+
|
|
198
|
+
# Plot matrix from top down
|
|
199
|
+
for r in range(height, 0, -1):
|
|
200
|
+
if r == height:
|
|
201
|
+
y_tick = f"{y_label_top:>{y_label_width}} ┼"
|
|
202
|
+
grid_char = "┈"
|
|
203
|
+
elif r == math.ceil(height / 2):
|
|
204
|
+
y_tick = f"{y_label_mid:>{y_label_width}} ┼"
|
|
205
|
+
grid_char = "┈"
|
|
206
|
+
else:
|
|
207
|
+
y_tick = f"{' ' * y_label_width} │"
|
|
208
|
+
grid_char = " "
|
|
209
|
+
|
|
210
|
+
day_cells = []
|
|
211
|
+
for d in days:
|
|
212
|
+
tokens = d.get("tokens", 0)
|
|
213
|
+
ratio = tokens / peak_tokens
|
|
214
|
+
if ratio >= (r / height):
|
|
215
|
+
cell_str = "█" * col_width
|
|
216
|
+
elif ratio >= ((r - 0.5) / height):
|
|
217
|
+
cell_str = "▄" * col_width
|
|
218
|
+
elif grid_char != " ":
|
|
219
|
+
cell_str = grid_char * col_width
|
|
220
|
+
else:
|
|
221
|
+
cell_str = " " * col_width
|
|
222
|
+
day_cells.append(cell_str)
|
|
223
|
+
|
|
224
|
+
lines.append(f" {y_tick} " + " ".join(day_cells))
|
|
225
|
+
|
|
226
|
+
# X-axis Baseline
|
|
227
|
+
base_col = "─" * col_width
|
|
228
|
+
x_axis_line = "─".join([base_col] * len(days))
|
|
229
|
+
lines.append(f" {'0':>{y_label_width}} ┴─{x_axis_line}─")
|
|
230
|
+
|
|
231
|
+
# Date labels (MM-DD)
|
|
232
|
+
date_cells = []
|
|
233
|
+
for d in days:
|
|
234
|
+
raw_day = d.get("day", "")
|
|
235
|
+
# Format YYYY-MM-DD -> MM-DD
|
|
236
|
+
short_date = raw_day[5:] if len(raw_day) >= 10 else raw_day
|
|
237
|
+
date_cells.append(f"{short_date:^{col_width}}")
|
|
238
|
+
lines.append(f" {' ' * y_label_width} " + " ".join(date_cells))
|
|
239
|
+
|
|
240
|
+
# Compact token labels below dates
|
|
241
|
+
tok_cells = []
|
|
242
|
+
for d in days:
|
|
243
|
+
t = d.get("tokens", 0)
|
|
244
|
+
tok_str = _fmt_tokens(t) if t > 0 else "·"
|
|
245
|
+
tok_cells.append(f"{tok_str:^{col_width}}")
|
|
246
|
+
lines.append(f" {' ' * y_label_width} " + " ".join(tok_cells))
|
|
247
|
+
|
|
248
|
+
return "\n".join(lines)
|
src/config.py
CHANGED
|
@@ -291,6 +291,8 @@ DEFAULT_MODEL_PRICES = {
|
|
|
291
291
|
"deepseek-v4-pro": (0.435, 0.87),
|
|
292
292
|
"gemini-2.5-pro": (1.25, 10.00),
|
|
293
293
|
"gemini-2.5-flash-lite": (0.10, 0.40),
|
|
294
|
+
"gemini-pro-latest": (1.25, 10.00),
|
|
295
|
+
"gemini-flash-lite-latest": (0.10, 0.40),
|
|
294
296
|
}
|
|
295
297
|
|
|
296
298
|
# Providers that run on this machine. There is no invoice behind them, so their
|
src/config_schema.py
CHANGED
|
@@ -22,6 +22,7 @@ from src.i18n import __
|
|
|
22
22
|
# Widget kinds. Each one maps to a different control in ui/config_app.py.
|
|
23
23
|
KIND_BOOL = "bool"
|
|
24
24
|
KIND_INT = "int"
|
|
25
|
+
KIND_FLOAT = "float"
|
|
25
26
|
KIND_STR = "str"
|
|
26
27
|
KIND_ENUM = "enum"
|
|
27
28
|
KIND_TEMPLATE = "template"
|
|
@@ -39,6 +40,7 @@ KIND_BRANCH = "branch"
|
|
|
39
40
|
KINDS = (
|
|
40
41
|
KIND_BOOL,
|
|
41
42
|
KIND_INT,
|
|
43
|
+
KIND_FLOAT,
|
|
42
44
|
KIND_STR,
|
|
43
45
|
KIND_ENUM,
|
|
44
46
|
KIND_TEMPLATE,
|
|
@@ -395,6 +397,16 @@ FIELDS = (
|
|
|
395
397
|
default="180",
|
|
396
398
|
seeded=True,
|
|
397
399
|
),
|
|
400
|
+
ConfigField(
|
|
401
|
+
key="GITPR_METRICS_CURRENCY",
|
|
402
|
+
label=__("Metrics Currency"),
|
|
403
|
+
description=__(
|
|
404
|
+
"Currency code used in telemetry and cost reports (default USD)."
|
|
405
|
+
),
|
|
406
|
+
category="ai",
|
|
407
|
+
kind=KIND_STR,
|
|
408
|
+
default="",
|
|
409
|
+
),
|
|
398
410
|
ConfigField(
|
|
399
411
|
key="GEMINI_API_MODEL_PRIMARY",
|
|
400
412
|
label=__("Gemini Advanced Model"),
|
|
@@ -405,6 +417,28 @@ FIELDS = (
|
|
|
405
417
|
show_if=(("DEFAULT_AI_PROVIDER", ("gemini",)),),
|
|
406
418
|
seeded=True,
|
|
407
419
|
),
|
|
420
|
+
ConfigField(
|
|
421
|
+
key="GITPR_METRICS_PRICE_GEMINI_PRO_LATEST_INPUT",
|
|
422
|
+
label=__("Gemini Advanced Model - Input Price"),
|
|
423
|
+
description=__(
|
|
424
|
+
"Cost per million input tokens for the advanced model."
|
|
425
|
+
),
|
|
426
|
+
category="ai",
|
|
427
|
+
kind=KIND_FLOAT,
|
|
428
|
+
default="",
|
|
429
|
+
show_if=(("DEFAULT_AI_PROVIDER", ("gemini",)),),
|
|
430
|
+
),
|
|
431
|
+
ConfigField(
|
|
432
|
+
key="GITPR_METRICS_PRICE_GEMINI_PRO_LATEST_OUTPUT",
|
|
433
|
+
label=__("Gemini Advanced Model - Output Price"),
|
|
434
|
+
description=__(
|
|
435
|
+
"Cost per million completion tokens for the advanced model."
|
|
436
|
+
),
|
|
437
|
+
category="ai",
|
|
438
|
+
kind=KIND_FLOAT,
|
|
439
|
+
default="",
|
|
440
|
+
show_if=(("DEFAULT_AI_PROVIDER", ("gemini",)),),
|
|
441
|
+
),
|
|
408
442
|
ConfigField(
|
|
409
443
|
key="GEMINI_API_MODEL_SECONDARY",
|
|
410
444
|
label=__("Gemini Fast Model"),
|
|
@@ -415,6 +449,28 @@ FIELDS = (
|
|
|
415
449
|
show_if=(("DEFAULT_AI_PROVIDER", ("gemini",)),),
|
|
416
450
|
seeded=True,
|
|
417
451
|
),
|
|
452
|
+
ConfigField(
|
|
453
|
+
key="GITPR_METRICS_PRICE_GEMINI_FLASH_LITE_LATEST_INPUT",
|
|
454
|
+
label=__("Gemini Fast Model - Input Price"),
|
|
455
|
+
description=__(
|
|
456
|
+
"Cost per million input tokens for the fast model."
|
|
457
|
+
),
|
|
458
|
+
category="ai",
|
|
459
|
+
kind=KIND_FLOAT,
|
|
460
|
+
default="",
|
|
461
|
+
show_if=(("DEFAULT_AI_PROVIDER", ("gemini",)),),
|
|
462
|
+
),
|
|
463
|
+
ConfigField(
|
|
464
|
+
key="GITPR_METRICS_PRICE_GEMINI_FLASH_LITE_LATEST_OUTPUT",
|
|
465
|
+
label=__("Gemini Fast Model - Output Price"),
|
|
466
|
+
description=__(
|
|
467
|
+
"Cost per million completion tokens for the fast model."
|
|
468
|
+
),
|
|
469
|
+
category="ai",
|
|
470
|
+
kind=KIND_FLOAT,
|
|
471
|
+
default="",
|
|
472
|
+
show_if=(("DEFAULT_AI_PROVIDER", ("gemini",)),),
|
|
473
|
+
),
|
|
418
474
|
ConfigField(
|
|
419
475
|
key="GEMINI_API_KEY_ENCRYPTED",
|
|
420
476
|
label=__("Gemini API Key"),
|
|
@@ -437,6 +493,28 @@ FIELDS = (
|
|
|
437
493
|
show_if=(("DEFAULT_AI_PROVIDER", ("deepseek",)),),
|
|
438
494
|
seeded=True,
|
|
439
495
|
),
|
|
496
|
+
ConfigField(
|
|
497
|
+
key="GITPR_METRICS_PRICE_DEEPSEEK_V4_PRO_INPUT",
|
|
498
|
+
label=__("DeepSeek Advanced Model - Input Price"),
|
|
499
|
+
description=__(
|
|
500
|
+
"Cost per million input tokens for the advanced model."
|
|
501
|
+
),
|
|
502
|
+
category="ai",
|
|
503
|
+
kind=KIND_FLOAT,
|
|
504
|
+
default="",
|
|
505
|
+
show_if=(("DEFAULT_AI_PROVIDER", ("deepseek",)),),
|
|
506
|
+
),
|
|
507
|
+
ConfigField(
|
|
508
|
+
key="GITPR_METRICS_PRICE_DEEPSEEK_V4_PRO_OUTPUT",
|
|
509
|
+
label=__("DeepSeek Advanced Model - Output Price"),
|
|
510
|
+
description=__(
|
|
511
|
+
"Cost per million completion tokens for the advanced model."
|
|
512
|
+
),
|
|
513
|
+
category="ai",
|
|
514
|
+
kind=KIND_FLOAT,
|
|
515
|
+
default="",
|
|
516
|
+
show_if=(("DEFAULT_AI_PROVIDER", ("deepseek",)),),
|
|
517
|
+
),
|
|
440
518
|
ConfigField(
|
|
441
519
|
key="DEEPSEEK_API_MODEL_SECONDARY",
|
|
442
520
|
label=__("DeepSeek Fast Model"),
|
|
@@ -447,6 +525,28 @@ FIELDS = (
|
|
|
447
525
|
show_if=(("DEFAULT_AI_PROVIDER", ("deepseek",)),),
|
|
448
526
|
seeded=True,
|
|
449
527
|
),
|
|
528
|
+
ConfigField(
|
|
529
|
+
key="GITPR_METRICS_PRICE_DEEPSEEK_V4_FLASH_INPUT",
|
|
530
|
+
label=__("DeepSeek Fast Model - Input Price"),
|
|
531
|
+
description=__(
|
|
532
|
+
"Cost per million input tokens for the fast model."
|
|
533
|
+
),
|
|
534
|
+
category="ai",
|
|
535
|
+
kind=KIND_FLOAT,
|
|
536
|
+
default="",
|
|
537
|
+
show_if=(("DEFAULT_AI_PROVIDER", ("deepseek",)),),
|
|
538
|
+
),
|
|
539
|
+
ConfigField(
|
|
540
|
+
key="GITPR_METRICS_PRICE_DEEPSEEK_V4_FLASH_OUTPUT",
|
|
541
|
+
label=__("DeepSeek Fast Model - Output Price"),
|
|
542
|
+
description=__(
|
|
543
|
+
"Cost per million completion tokens for the fast model."
|
|
544
|
+
),
|
|
545
|
+
category="ai",
|
|
546
|
+
kind=KIND_FLOAT,
|
|
547
|
+
default="",
|
|
548
|
+
show_if=(("DEFAULT_AI_PROVIDER", ("deepseek",)),),
|
|
549
|
+
),
|
|
450
550
|
ConfigField(
|
|
451
551
|
key="DEEPSEEK_API_KEY_ENCRYPTED",
|
|
452
552
|
label=__("DeepSeek API Key"),
|
|
@@ -1595,6 +1695,16 @@ def validate_field_value(field, value):
|
|
|
1595
1695
|
if parsed <= 0:
|
|
1596
1696
|
return __("Use a whole number greater than zero.")
|
|
1597
1697
|
|
|
1698
|
+
elif field.kind == KIND_FLOAT:
|
|
1699
|
+
if not value:
|
|
1700
|
+
return ""
|
|
1701
|
+
try:
|
|
1702
|
+
parsed = float(value)
|
|
1703
|
+
except ValueError:
|
|
1704
|
+
return __("Use a number greater than or equal to zero.")
|
|
1705
|
+
if parsed < 0:
|
|
1706
|
+
return __("Use a number greater than or equal to zero.")
|
|
1707
|
+
|
|
1598
1708
|
elif field.kind == KIND_ENUM:
|
|
1599
1709
|
if value not in field.choices:
|
|
1600
1710
|
return __("Choose one of: {choices}", choices=", ".join(field.choices))
|
src/core.py
CHANGED
|
@@ -170,6 +170,10 @@ _FALLBACK_SMART_EXCLUDES = [
|
|
|
170
170
|
"*.pth",
|
|
171
171
|
"*.onnx",
|
|
172
172
|
"*.safetensors",
|
|
173
|
+
"*.arrow",
|
|
174
|
+
"*.gguf",
|
|
175
|
+
"*.tflite",
|
|
176
|
+
"*.keras",
|
|
173
177
|
"*.bin",
|
|
174
178
|
"*.dat",
|
|
175
179
|
"*.p12",
|
|
@@ -1156,6 +1160,10 @@ def generate_pr_content(
|
|
|
1156
1160
|
)
|
|
1157
1161
|
return None
|
|
1158
1162
|
|
|
1163
|
+
# Defensive Binary hunk guard: collapse any U+FFFD-heavy binary hunks that
|
|
1164
|
+
# slipped past path excludes or were passed as a raw diff by an external caller.
|
|
1165
|
+
diff_text = collapse_binary_hunks(diff_text)
|
|
1166
|
+
|
|
1159
1167
|
t_start = time.perf_counter()
|
|
1160
1168
|
|
|
1161
1169
|
# Cache folder configuration — THE map for the whole project. It used to
|
src/ui/config_app.py
CHANGED
src/ui/metrics_app.py
CHANGED
|
@@ -17,7 +17,15 @@ different story about one ledger.
|
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
19
|
from textual.app import App, ComposeResult
|
|
20
|
-
from textual.widgets import
|
|
20
|
+
from textual.widgets import (
|
|
21
|
+
Header,
|
|
22
|
+
Footer,
|
|
23
|
+
Static,
|
|
24
|
+
DataTable,
|
|
25
|
+
ProgressBar,
|
|
26
|
+
TabbedContent,
|
|
27
|
+
TabPane,
|
|
28
|
+
)
|
|
21
29
|
from textual.containers import Vertical, VerticalScroll
|
|
22
30
|
from textual.binding import Binding
|
|
23
31
|
from collections import Counter
|
|
@@ -25,6 +33,11 @@ import os
|
|
|
25
33
|
|
|
26
34
|
from src import ledger
|
|
27
35
|
from src.i18n import __
|
|
36
|
+
from src.ascii_chart import (
|
|
37
|
+
render_vertical_histogram,
|
|
38
|
+
render_token_timeseries,
|
|
39
|
+
render_empty_card,
|
|
40
|
+
)
|
|
28
41
|
from src.metrics import (
|
|
29
42
|
TITLE,
|
|
30
43
|
WARN,
|
|
@@ -119,9 +132,26 @@ class MetricsApp(App):
|
|
|
119
132
|
width: 100%;
|
|
120
133
|
display: none;
|
|
121
134
|
}
|
|
135
|
+
#main_tabs {
|
|
136
|
+
height: 1fr;
|
|
137
|
+
}
|
|
138
|
+
#charts_container {
|
|
139
|
+
height: 1fr;
|
|
140
|
+
margin: 0 2;
|
|
141
|
+
padding: 1 0;
|
|
142
|
+
}
|
|
143
|
+
#latency_chart_panel, #token_chart_panel {
|
|
144
|
+
background: $surface;
|
|
145
|
+
border: solid $accent;
|
|
146
|
+
padding: 1 2;
|
|
147
|
+
margin-bottom: 1;
|
|
148
|
+
height: auto;
|
|
149
|
+
}
|
|
122
150
|
"""
|
|
123
151
|
|
|
124
152
|
BINDINGS = [
|
|
153
|
+
Binding("1", "switch_tab('tab_events')", __("Events"), priority=True),
|
|
154
|
+
Binding("2", "switch_tab('tab_charts')", __("Charts"), priority=True),
|
|
125
155
|
Binding("f5", "refresh", __("Refresh")),
|
|
126
156
|
Binding("escape", "quit", __("Exit")),
|
|
127
157
|
]
|
|
@@ -141,15 +171,20 @@ class MetricsApp(App):
|
|
|
141
171
|
repo_text = self.repo_filter or __("All repositories")
|
|
142
172
|
yield Static(f"\U0001f4c1 {__('Repository')}: {repo_text}", id="repo_label")
|
|
143
173
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
174
|
+
with TabbedContent(id="main_tabs"):
|
|
175
|
+
with TabPane(__("Events"), id="tab_events"):
|
|
176
|
+
yield Static("", id="summary")
|
|
177
|
+
with VerticalScroll(id="sections"):
|
|
178
|
+
yield Static("", id="sections_notice")
|
|
179
|
+
for section_id in SECTION_IDS:
|
|
180
|
+
yield Static("", id=section_id)
|
|
181
|
+
with Vertical(id="table_container"):
|
|
182
|
+
yield DataTable(id="events_table")
|
|
183
|
+
|
|
184
|
+
with TabPane(__("Charts & Trends"), id="tab_charts"):
|
|
185
|
+
with VerticalScroll(id="charts_container"):
|
|
186
|
+
yield Static("", id="latency_chart_panel")
|
|
187
|
+
yield Static("", id="token_chart_panel")
|
|
153
188
|
|
|
154
189
|
yield Static("", id="status_bar")
|
|
155
190
|
|
|
@@ -214,14 +249,14 @@ class MetricsApp(App):
|
|
|
214
249
|
"""Background worker: reads the ledger, or the files while it is absent."""
|
|
215
250
|
if self.using_ledger:
|
|
216
251
|
rows = self._load_from_ledger()
|
|
217
|
-
sections = self._load_sections()
|
|
252
|
+
sections, chart_data = self._load_sections()
|
|
218
253
|
else:
|
|
219
254
|
rows = self._load_from_files()
|
|
220
|
-
sections = self._load_sections(with_ledger=False)
|
|
255
|
+
sections, chart_data = self._load_sections(with_ledger=False)
|
|
221
256
|
|
|
222
|
-
self.call_from_thread(self._finish_scan, rows, sections)
|
|
257
|
+
self.call_from_thread(self._finish_scan, rows, sections, chart_data)
|
|
223
258
|
|
|
224
|
-
def _load_sections(self, with_ledger: bool = True) ->
|
|
259
|
+
def _load_sections(self, with_ledger: bool = True) -> tuple:
|
|
225
260
|
"""The metric sections, through the readers the terminal also uses.
|
|
226
261
|
|
|
227
262
|
Same readers, same lines, only the markup differs: a metric drawn here
|
|
@@ -263,10 +298,16 @@ class MetricsApp(App):
|
|
|
263
298
|
sections = list(zip(SECTION_IDS, readers, renderers))
|
|
264
299
|
if not with_ledger:
|
|
265
300
|
sections = sections[-1:]
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
301
|
+
rendered = []
|
|
302
|
+
chart_data = {}
|
|
303
|
+
for section_id, reader, renderer in sections:
|
|
304
|
+
data = reader(**scope)
|
|
305
|
+
rendered.append((f"#{section_id}", renderer(data)))
|
|
306
|
+
if section_id == "section_latency":
|
|
307
|
+
chart_data["latency"] = data
|
|
308
|
+
elif section_id == "section_token_trend":
|
|
309
|
+
chart_data["token_trend"] = data
|
|
310
|
+
return rendered, chart_data
|
|
270
311
|
|
|
271
312
|
def _load_from_ledger(self) -> list:
|
|
272
313
|
"""Rows in the window, newest first, filtered by repository.
|
|
@@ -334,15 +375,19 @@ class MetricsApp(App):
|
|
|
334
375
|
except Exception:
|
|
335
376
|
pass # Widget may not exist yet or may have been removed
|
|
336
377
|
|
|
337
|
-
def _finish_scan(
|
|
378
|
+
def _finish_scan(
|
|
379
|
+
self, rows: list, sections: list = None, chart_data: dict = None
|
|
380
|
+
) -> None:
|
|
338
381
|
"""Called on the main thread when loading is complete."""
|
|
339
382
|
self.query_one("#loading_overlay").display = False
|
|
340
383
|
self.events = rows
|
|
341
384
|
self._populate_table()
|
|
342
385
|
self._update_summary()
|
|
343
|
-
self._render_sections(sections)
|
|
386
|
+
self._render_sections(sections, chart_data)
|
|
344
387
|
|
|
345
|
-
def _render_sections(
|
|
388
|
+
def _render_sections(
|
|
389
|
+
self, sections: list = None, chart_data: dict = None
|
|
390
|
+
) -> None:
|
|
346
391
|
"""Draws the shared section lines, in Textual markup.
|
|
347
392
|
|
|
348
393
|
While the ledger is absent the four readers that query it have nothing
|
|
@@ -367,6 +412,50 @@ class MetricsApp(App):
|
|
|
367
412
|
if lines:
|
|
368
413
|
widget.update(self._markup(lines))
|
|
369
414
|
|
|
415
|
+
# Render 2D charts in Tab 2
|
|
416
|
+
try:
|
|
417
|
+
latency_widget = self.query_one("#latency_chart_panel", Static)
|
|
418
|
+
token_widget = self.query_one("#token_chart_panel", Static)
|
|
419
|
+
if chart_data is None and self.using_ledger:
|
|
420
|
+
scope = {
|
|
421
|
+
"repo_filter": self.repo_filter or None,
|
|
422
|
+
"since": self.since,
|
|
423
|
+
"until": self.until,
|
|
424
|
+
}
|
|
425
|
+
chart_data = {
|
|
426
|
+
"latency": latency_report(**scope),
|
|
427
|
+
"token_trend": token_trend_report(**scope),
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
if self.using_ledger and chart_data:
|
|
431
|
+
latency_widget.update(
|
|
432
|
+
render_vertical_histogram(chart_data.get("latency"))
|
|
433
|
+
)
|
|
434
|
+
token_widget.update(
|
|
435
|
+
render_token_timeseries(chart_data.get("token_trend"))
|
|
436
|
+
)
|
|
437
|
+
else:
|
|
438
|
+
latency_widget.update(
|
|
439
|
+
render_empty_card(
|
|
440
|
+
__("Latency Distribution"),
|
|
441
|
+
__(
|
|
442
|
+
"Cost and latency metrics need the ledger — "
|
|
443
|
+
"run `gitpr metrics migrate` to import the event files."
|
|
444
|
+
),
|
|
445
|
+
)
|
|
446
|
+
)
|
|
447
|
+
token_widget.update(
|
|
448
|
+
render_empty_card(
|
|
449
|
+
__("Token Trend"),
|
|
450
|
+
__(
|
|
451
|
+
"Token trend metrics need the ledger — "
|
|
452
|
+
"run `gitpr metrics migrate` to import the event files."
|
|
453
|
+
),
|
|
454
|
+
)
|
|
455
|
+
)
|
|
456
|
+
except Exception:
|
|
457
|
+
pass
|
|
458
|
+
|
|
370
459
|
@staticmethod
|
|
371
460
|
def _markup(lines: list) -> str:
|
|
372
461
|
"""The section lines as Textual markup, one rendering spelled twice.
|
|
@@ -455,6 +544,14 @@ class MetricsApp(App):
|
|
|
455
544
|
# Actions
|
|
456
545
|
# ------------------------------------------------------------------
|
|
457
546
|
|
|
547
|
+
def action_switch_tab(self, tab_id: str) -> None:
|
|
548
|
+
"""Switch active tab in TabbedContent (1 for Events, 2 for Charts)."""
|
|
549
|
+
try:
|
|
550
|
+
tabs = self.query_one("#main_tabs", TabbedContent)
|
|
551
|
+
tabs.active = tab_id
|
|
552
|
+
except Exception:
|
|
553
|
+
pass
|
|
554
|
+
|
|
458
555
|
def action_refresh(self) -> None:
|
|
459
556
|
"""Reload data from its source (F5)."""
|
|
460
557
|
self._start_scan()
|
src/updater.py
CHANGED
|
@@ -9,8 +9,8 @@ from packaging.version import InvalidVersion, Version
|
|
|
9
9
|
# Canonical Single Source of Truth (SSOT) for GitPR package version (PyPI distribution)
|
|
10
10
|
# ── Must stay ABOVE the i18n import: i18n.py lazily imports __lang_version__
|
|
11
11
|
# from here, and pyproject.toml reads __version__ via setuptools attr:.
|
|
12
|
-
__version__ = "1.
|
|
13
|
-
__lang_version__ = "v0.0.
|
|
12
|
+
__version__ = "1.7.0" # GitPR current package version (Canonical SSOT)
|
|
13
|
+
__lang_version__ = "v0.0.42" # Language dictionary version control (asset, independent of package version)
|
|
14
14
|
__scripts_version__ = (
|
|
15
15
|
"v0.0.4" # Git Hook scripts version control (independent from __lang_version__)
|
|
16
16
|
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|