git-analytics-cli 0.1.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.
@@ -0,0 +1,528 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Git Analytics Share Card Designer</title>
7
+ <style>
8
+ * { box-sizing: border-box; }
9
+ body {
10
+ margin: 0;
11
+ min-height: 100vh;
12
+ font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", sans-serif;
13
+ background: #101114;
14
+ color: #f4f2eb;
15
+ }
16
+ .app {
17
+ min-height: 100vh;
18
+ display: grid;
19
+ grid-template-columns: minmax(360px, 420px) 1fr;
20
+ }
21
+ .panel {
22
+ padding: 28px;
23
+ border-right: 1px solid rgba(255,255,255,0.10);
24
+ background:
25
+ linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02)),
26
+ #17181c;
27
+ }
28
+ .brand {
29
+ font-size: 12px;
30
+ letter-spacing: 0.22em;
31
+ color: #a7f3d0;
32
+ text-transform: uppercase;
33
+ margin-bottom: 10px;
34
+ }
35
+ h1 {
36
+ margin: 0 0 8px;
37
+ font-size: 32px;
38
+ line-height: 1.05;
39
+ letter-spacing: 0;
40
+ }
41
+ .sub {
42
+ color: rgba(244,242,235,0.62);
43
+ font-size: 14px;
44
+ line-height: 1.7;
45
+ margin-bottom: 26px;
46
+ }
47
+ .group { margin-bottom: 22px; }
48
+ .group-title {
49
+ font-size: 13px;
50
+ color: rgba(244,242,235,0.74);
51
+ font-weight: 700;
52
+ margin-bottom: 10px;
53
+ }
54
+ .seg {
55
+ display: grid;
56
+ grid-template-columns: repeat(2, 1fr);
57
+ gap: 8px;
58
+ }
59
+ .seg.three { grid-template-columns: repeat(3, 1fr); }
60
+ button, .file-label {
61
+ border: 1px solid rgba(255,255,255,0.13);
62
+ border-radius: 8px;
63
+ padding: 10px 12px;
64
+ background: rgba(255,255,255,0.055);
65
+ color: #f4f2eb;
66
+ font: inherit;
67
+ cursor: pointer;
68
+ transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
69
+ }
70
+ button:hover, .file-label:hover {
71
+ transform: translateY(-1px);
72
+ border-color: rgba(167,243,208,0.45);
73
+ background: rgba(255,255,255,0.09);
74
+ }
75
+ button.active {
76
+ border-color: #a7f3d0;
77
+ background: rgba(167,243,208,0.14);
78
+ }
79
+ .download {
80
+ width: 100%;
81
+ margin-top: 6px;
82
+ background: #f4f2eb;
83
+ color: #111214;
84
+ border-color: #f4f2eb;
85
+ font-weight: 800;
86
+ }
87
+ label {
88
+ display: block;
89
+ font-size: 12px;
90
+ color: rgba(244,242,235,0.58);
91
+ margin-bottom: 7px;
92
+ }
93
+ input[type="text"] {
94
+ width: 100%;
95
+ border: 1px solid rgba(255,255,255,0.13);
96
+ border-radius: 8px;
97
+ background: rgba(0,0,0,0.22);
98
+ color: #f4f2eb;
99
+ padding: 11px 12px;
100
+ font: inherit;
101
+ outline: none;
102
+ }
103
+ input[type="color"] {
104
+ width: 100%;
105
+ height: 42px;
106
+ border: 1px solid rgba(255,255,255,0.13);
107
+ border-radius: 8px;
108
+ background: transparent;
109
+ padding: 4px;
110
+ }
111
+ input[type="file"] { display: none; }
112
+ .color-row {
113
+ display: grid;
114
+ grid-template-columns: 1fr 1fr;
115
+ gap: 10px;
116
+ }
117
+ .file-label {
118
+ display: flex;
119
+ align-items: center;
120
+ justify-content: center;
121
+ min-height: 42px;
122
+ font-size: 13px;
123
+ }
124
+ .hint {
125
+ color: rgba(244,242,235,0.46);
126
+ font-size: 12px;
127
+ line-height: 1.6;
128
+ margin-top: 10px;
129
+ }
130
+ .stage {
131
+ display: flex;
132
+ align-items: center;
133
+ justify-content: center;
134
+ padding: 36px;
135
+ background:
136
+ linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px),
137
+ linear-gradient(180deg, rgba(255,255,255,0.04) 1px, transparent 1px),
138
+ #0f1013;
139
+ background-size: 42px 42px;
140
+ overflow: auto;
141
+ }
142
+ .canvas-wrap {
143
+ width: min(480px, 92vw);
144
+ aspect-ratio: 4 / 5;
145
+ border-radius: 18px;
146
+ box-shadow: 0 28px 90px rgba(0,0,0,0.48);
147
+ overflow: hidden;
148
+ background: #222;
149
+ }
150
+ canvas {
151
+ display: block;
152
+ width: 100%;
153
+ height: 100%;
154
+ }
155
+ @media (max-width: 900px) {
156
+ .app { grid-template-columns: 1fr; }
157
+ .panel { border-right: 0; border-bottom: 1px solid rgba(255,255,255,0.10); }
158
+ .stage { padding: 22px; }
159
+ }
160
+ </style>
161
+ </head>
162
+ <body>
163
+ <main class="app">
164
+ <aside class="panel">
165
+ <div class="brand">Git Analytics</div>
166
+ <h1>代码画像分享器</h1>
167
+ <div class="sub">生成适合朋友圈、X、LinkedIn、小红书传播的竖版 PNG。背景可以换风格、换颜色,也可以上传自己的图片。</div>
168
+
169
+ <div class="group">
170
+ <div class="group-title">卡片标题</div>
171
+ <input id="titleInput" type="text" value="我的代码人格">
172
+ </div>
173
+
174
+ <div class="group">
175
+ <div class="group-title">版式</div>
176
+ <div class="seg">
177
+ <button class="active" data-layout="poster">传播海报</button>
178
+ <button data-layout="badge">身份徽章</button>
179
+ </div>
180
+ </div>
181
+
182
+ <div class="group">
183
+ <div class="group-title">背景风格</div>
184
+ <div class="seg">
185
+ <button class="active" data-bg="aurora">极光</button>
186
+ <button data-bg="terminal">终端</button>
187
+ <button data-bg="paper">纸张</button>
188
+ <button data-bg="sunrise">日出</button>
189
+ </div>
190
+ </div>
191
+
192
+ <div class="group">
193
+ <div class="group-title">个性化颜色</div>
194
+ <div class="color-row">
195
+ <div>
196
+ <label for="primaryColor">主色</label>
197
+ <input id="primaryColor" type="color" value="#a7f3d0">
198
+ </div>
199
+ <div>
200
+ <label for="accentColor">强调色</label>
201
+ <input id="accentColor" type="color" value="#fbbf24">
202
+ </div>
203
+ </div>
204
+ </div>
205
+
206
+ <div class="group">
207
+ <div class="group-title">自定义背景图</div>
208
+ <label class="file-label" for="bgFile">选择图片作为背景</label>
209
+ <input id="bgFile" type="file" accept="image/*">
210
+ <div class="hint">上传后会自动 cover 裁切,并加暗色蒙层保证文字可读。点击下面按钮可移除图片。</div>
211
+ <button id="clearImage" style="width:100%;margin-top:10px;">移除背景图</button>
212
+ </div>
213
+
214
+ <button class="download" id="downloadBtn">导出 PNG 分享图</button>
215
+ <div class="hint">输出尺寸:2160 × 2700 高清 PNG。传播时发 PNG,不需要发 HTML。</div>
216
+ </aside>
217
+
218
+ <section class="stage">
219
+ <div class="canvas-wrap">
220
+ <canvas id="shareCanvas" width="2160" height="2700"></canvas>
221
+ </div>
222
+ </section>
223
+ </main>
224
+
225
+ <script>
226
+ const DATA = {
227
+ summary: { totalCommits: 604, totalActiveDays: 198, totalProjects: 20 },
228
+ score: 71,
229
+ persona: {
230
+ icon: "⚡",
231
+ name: "顶级黑客",
232
+ code: "DSCPQA",
233
+ desc: "跨项目、高频率、能交付也能打磨",
234
+ detail: "白天 62% · 高频提交 100% · 核心项目 51% · AI 协作型"
235
+ },
236
+ dims: [
237
+ ["时间偏好", "白天型", "D"],
238
+ ["节奏风格", "冲刺型", "S"],
239
+ ["专注程度", "核心深挖", "C"],
240
+ ["开发风格", "功能开拓", "P"],
241
+ ["工程取向", "质量导向", "Q"],
242
+ ["AI 协作", "AI 搭子", "A"]
243
+ ],
244
+ tags: ["AI 搭子", "测试守门人", "文档布道者", "多仓调度大师"]
245
+ };
246
+
247
+ const state = {
248
+ layout: "poster",
249
+ bg: "aurora",
250
+ primary: "#a7f3d0",
251
+ accent: "#fbbf24",
252
+ title: "我的代码人格",
253
+ image: null
254
+ };
255
+
256
+ const canvas = document.getElementById("shareCanvas");
257
+ const ctx = canvas.getContext("2d");
258
+ const EXPORT_SCALE = 2;
259
+ const W = 1080;
260
+ const H = 1350;
261
+
262
+ function hexToRgb(hex) {
263
+ const clean = hex.replace("#", "");
264
+ return [
265
+ parseInt(clean.slice(0, 2), 16),
266
+ parseInt(clean.slice(2, 4), 16),
267
+ parseInt(clean.slice(4, 6), 16)
268
+ ];
269
+ }
270
+
271
+ function mix(a, b, t) {
272
+ return Math.round(a + (b - a) * t);
273
+ }
274
+
275
+ function rgb(hex, alpha = 1) {
276
+ const [r, g, b] = hexToRgb(hex);
277
+ return `rgba(${r},${g},${b},${alpha})`;
278
+ }
279
+
280
+ function drawCoverImage(img) {
281
+ const scale = Math.max(W / img.width, H / img.height);
282
+ const iw = img.width * scale;
283
+ const ih = img.height * scale;
284
+ ctx.drawImage(img, (W - iw) / 2, (H - ih) / 2, iw, ih);
285
+ ctx.fillStyle = "rgba(0,0,0,0.46)";
286
+ ctx.fillRect(0, 0, W, H);
287
+ }
288
+
289
+ function drawBg() {
290
+ if (state.image) {
291
+ drawCoverImage(state.image);
292
+ return;
293
+ }
294
+
295
+ if (state.bg === "paper") {
296
+ const g = ctx.createLinearGradient(0, 0, W, H);
297
+ g.addColorStop(0, "#f3efe3");
298
+ g.addColorStop(1, "#d8cdb9");
299
+ ctx.fillStyle = g;
300
+ ctx.fillRect(0, 0, W, H);
301
+ ctx.fillStyle = "rgba(30,28,24,0.055)";
302
+ for (let i = 0; i < 1800; i++) ctx.fillRect(Math.random() * W, Math.random() * H, 1.2, 1.2);
303
+ return;
304
+ }
305
+
306
+ const top = state.bg === "terminal" ? "#07100d" : state.bg === "sunrise" ? "#251015" : "#101114";
307
+ const bottom = state.bg === "terminal" ? "#111a16" : state.bg === "sunrise" ? "#603019" : "#17202a";
308
+ const g = ctx.createLinearGradient(0, 0, W, H);
309
+ g.addColorStop(0, top);
310
+ g.addColorStop(1, bottom);
311
+ ctx.fillStyle = g;
312
+ ctx.fillRect(0, 0, W, H);
313
+
314
+ if (state.bg === "terminal") {
315
+ ctx.strokeStyle = "rgba(167,243,208,0.08)";
316
+ ctx.lineWidth = 1;
317
+ for (let x = 80; x < W; x += 80) {
318
+ ctx.beginPath();
319
+ ctx.moveTo(x, 0);
320
+ ctx.lineTo(x, H);
321
+ ctx.stroke();
322
+ }
323
+ for (let y = 80; y < H; y += 80) {
324
+ ctx.beginPath();
325
+ ctx.moveTo(0, y);
326
+ ctx.lineTo(W, y);
327
+ ctx.stroke();
328
+ }
329
+ } else {
330
+ const p = hexToRgb(state.primary);
331
+ const a = hexToRgb(state.accent);
332
+ const glow1 = ctx.createRadialGradient(820, 180, 10, 820, 180, 620);
333
+ glow1.addColorStop(0, `rgba(${p[0]},${p[1]},${p[2]},0.55)`);
334
+ glow1.addColorStop(1, "rgba(0,0,0,0)");
335
+ ctx.fillStyle = glow1;
336
+ ctx.fillRect(0, 0, W, H);
337
+
338
+ const glow2 = ctx.createRadialGradient(160, 1040, 10, 160, 1040, 720);
339
+ glow2.addColorStop(0, `rgba(${a[0]},${a[1]},${a[2]},0.40)`);
340
+ glow2.addColorStop(1, "rgba(0,0,0,0)");
341
+ ctx.fillStyle = glow2;
342
+ ctx.fillRect(0, 0, W, H);
343
+ }
344
+ }
345
+
346
+ function roundRect(x, y, w, h, r) {
347
+ ctx.beginPath();
348
+ ctx.moveTo(x + r, y);
349
+ ctx.arcTo(x + w, y, x + w, y + h, r);
350
+ ctx.arcTo(x + w, y + h, x, y + h, r);
351
+ ctx.arcTo(x, y + h, x, y, r);
352
+ ctx.arcTo(x, y, x + w, y, r);
353
+ ctx.closePath();
354
+ }
355
+
356
+ function fillRound(x, y, w, h, r, fill, stroke) {
357
+ roundRect(x, y, w, h, r);
358
+ ctx.fillStyle = fill;
359
+ ctx.fill();
360
+ if (stroke) {
361
+ ctx.strokeStyle = stroke;
362
+ ctx.lineWidth = 1.5;
363
+ ctx.stroke();
364
+ }
365
+ }
366
+
367
+ function textCenter(text, x, y, font, fill) {
368
+ ctx.font = font;
369
+ ctx.fillStyle = fill;
370
+ ctx.textAlign = "center";
371
+ ctx.textBaseline = "top";
372
+ ctx.fillText(text, x, y);
373
+ }
374
+
375
+ function drawPoster() {
376
+ const darkText = state.bg === "paper" && !state.image;
377
+ const mainText = darkText ? "#171512" : "#fffdf7";
378
+ const softText = darkText ? "rgba(23,21,18,0.62)" : "rgba(255,253,247,0.64)";
379
+ const glass = darkText ? "rgba(255,255,255,0.48)" : "rgba(255,255,255,0.10)";
380
+ const border = darkText ? "rgba(23,21,18,0.12)" : "rgba(255,255,255,0.16)";
381
+
382
+ ctx.save();
383
+ ctx.translate(70, 70);
384
+ fillRound(0, 0, W - 140, H - 140, 46, darkText ? "rgba(255,255,255,0.36)" : "rgba(0,0,0,0.20)", border);
385
+ ctx.restore();
386
+
387
+ textCenter(state.title, W / 2, 122, "700 42px PingFang SC, sans-serif", rgb(state.primary));
388
+ textCenter(DATA.persona.icon, W / 2, 210, "900 98px PingFang SC, sans-serif", mainText);
389
+ textCenter(DATA.persona.name, W / 2, 330, "900 78px PingFang SC, sans-serif", mainText);
390
+ textCenter(DATA.persona.code, W / 2, 430, "800 34px ui-monospace, SFMono-Regular, Menlo, monospace", softText);
391
+ textCenter(DATA.persona.detail, W / 2, 488, "500 26px PingFang SC, sans-serif", softText);
392
+
393
+ const statY = 590;
394
+ const statW = 278;
395
+ const stats = [
396
+ [DATA.summary.totalCommits, "commits"],
397
+ [DATA.summary.totalActiveDays, "active days"],
398
+ [DATA.summary.totalProjects, "projects"]
399
+ ];
400
+ stats.forEach(([value, label], i) => {
401
+ const x = 82 + i * (statW + 28);
402
+ fillRound(x, statY, statW, 156, 28, glass, border);
403
+ textCenter(String(value), x + statW / 2, statY + 30, "900 58px ui-sans-serif, sans-serif", rgb(state.accent));
404
+ textCenter(label, x + statW / 2, statY + 96, "700 22px ui-sans-serif, sans-serif", softText);
405
+ });
406
+
407
+ const dimY = 800;
408
+ DATA.dims.forEach(([label, value, code], i) => {
409
+ const col = i % 3;
410
+ const row = Math.floor(i / 3);
411
+ const x = 82 + col * 306;
412
+ const y = dimY + row * 126;
413
+ fillRound(x, y, 278, 102, 24, glass, border);
414
+ ctx.textAlign = "left";
415
+ ctx.textBaseline = "top";
416
+ ctx.fillStyle = rgb(state.primary);
417
+ ctx.font = "900 30px ui-monospace, SFMono-Regular, Menlo, monospace";
418
+ ctx.fillText(code, x + 24, y + 22);
419
+ ctx.fillStyle = softText;
420
+ ctx.font = "600 19px PingFang SC, sans-serif";
421
+ ctx.fillText(label, x + 72, y + 18);
422
+ ctx.fillStyle = mainText;
423
+ ctx.font = "800 25px PingFang SC, sans-serif";
424
+ ctx.fillText(value, x + 72, y + 48);
425
+ });
426
+
427
+ const scoreY = 1076;
428
+ fillRound(82, scoreY, W - 164, 142, 30, glass, border);
429
+ ctx.textAlign = "left";
430
+ ctx.fillStyle = rgb(state.accent);
431
+ ctx.font = "900 78px ui-sans-serif, sans-serif";
432
+ ctx.fillText(DATA.score, 124, scoreY + 34);
433
+ ctx.fillStyle = softText;
434
+ ctx.font = "700 24px PingFang SC, sans-serif";
435
+ ctx.fillText("Developer Habit Score", 270, scoreY + 38);
436
+ fillRound(270, scoreY + 86, 600, 14, 7, darkText ? "rgba(23,21,18,0.12)" : "rgba(255,255,255,0.14)");
437
+ fillRound(270, scoreY + 86, 600 * DATA.score / 100, 14, 7, rgb(state.accent));
438
+
439
+ textCenter("Git Analytics · 本地优先的代码习惯体检", W / 2, 1262, "600 22px PingFang SC, sans-serif", softText);
440
+ }
441
+
442
+ function drawBadge() {
443
+ const darkText = state.bg === "paper" && !state.image;
444
+ const mainText = darkText ? "#171512" : "#fffdf7";
445
+ const softText = darkText ? "rgba(23,21,18,0.62)" : "rgba(255,253,247,0.64)";
446
+ textCenter("DEV PERSONA", W / 2, 125, "900 34px ui-monospace, SFMono-Regular, Menlo, monospace", rgb(state.primary));
447
+ textCenter(DATA.persona.icon, W / 2, 230, "900 150px PingFang SC, sans-serif", mainText);
448
+ textCenter(DATA.persona.name, W / 2, 420, "900 86px PingFang SC, sans-serif", mainText);
449
+ textCenter(DATA.persona.desc, W / 2, 535, "600 31px PingFang SC, sans-serif", softText);
450
+
451
+ fillRound(170, 632, 740, 150, 38, darkText ? "rgba(255,255,255,0.40)" : "rgba(255,255,255,0.10)", darkText ? "rgba(23,21,18,0.12)" : "rgba(255,255,255,0.16)");
452
+ textCenter(DATA.persona.code, W / 2, 660, "900 72px ui-monospace, SFMono-Regular, Menlo, monospace", rgb(state.accent));
453
+ textCenter(`${DATA.summary.totalCommits} commits · ${DATA.summary.totalProjects} projects · score ${DATA.score}`, W / 2, 905, "800 34px ui-sans-serif, sans-serif", mainText);
454
+
455
+ const tagText = DATA.tags.join(" / ");
456
+ textCenter(tagText, W / 2, 988, "600 28px PingFang SC, sans-serif", softText);
457
+ textCenter("Git Analytics", W / 2, 1190, "900 30px ui-monospace, SFMono-Regular, Menlo, monospace", rgb(state.primary));
458
+ }
459
+
460
+ function render() {
461
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
462
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
463
+ ctx.setTransform(EXPORT_SCALE, 0, 0, EXPORT_SCALE, 0, 0);
464
+ drawBg();
465
+ if (state.layout === "poster") drawPoster();
466
+ else drawBadge();
467
+ }
468
+
469
+ document.querySelectorAll("[data-layout]").forEach(btn => {
470
+ btn.addEventListener("click", () => {
471
+ document.querySelectorAll("[data-layout]").forEach(b => b.classList.remove("active"));
472
+ btn.classList.add("active");
473
+ state.layout = btn.dataset.layout;
474
+ render();
475
+ });
476
+ });
477
+
478
+ document.querySelectorAll("[data-bg]").forEach(btn => {
479
+ btn.addEventListener("click", () => {
480
+ document.querySelectorAll("[data-bg]").forEach(b => b.classList.remove("active"));
481
+ btn.classList.add("active");
482
+ state.bg = btn.dataset.bg;
483
+ render();
484
+ });
485
+ });
486
+
487
+ document.getElementById("titleInput").addEventListener("input", e => {
488
+ state.title = e.target.value || "我的代码人格";
489
+ render();
490
+ });
491
+ document.getElementById("primaryColor").addEventListener("input", e => {
492
+ state.primary = e.target.value;
493
+ render();
494
+ });
495
+ document.getElementById("accentColor").addEventListener("input", e => {
496
+ state.accent = e.target.value;
497
+ render();
498
+ });
499
+ document.getElementById("bgFile").addEventListener("change", e => {
500
+ const file = e.target.files && e.target.files[0];
501
+ if (!file) return;
502
+ const reader = new FileReader();
503
+ reader.onload = () => {
504
+ const img = new Image();
505
+ img.onload = () => {
506
+ state.image = img;
507
+ render();
508
+ };
509
+ img.src = reader.result;
510
+ };
511
+ reader.readAsDataURL(file);
512
+ });
513
+ document.getElementById("clearImage").addEventListener("click", () => {
514
+ state.image = null;
515
+ document.getElementById("bgFile").value = "";
516
+ render();
517
+ });
518
+ document.getElementById("downloadBtn").addEventListener("click", () => {
519
+ const a = document.createElement("a");
520
+ a.href = canvas.toDataURL("image/png");
521
+ a.download = "git-analytics-share-card-2x.png";
522
+ a.click();
523
+ });
524
+
525
+ render();
526
+ </script>
527
+ </body>
528
+ </html>
@@ -0,0 +1,175 @@
1
+ Metadata-Version: 2.4
2
+ Name: git-analytics-cli
3
+ Version: 0.1.0
4
+ Summary: Local-first Git habit analytics — scan your repos, get a developer persona and health report
5
+ Author: Git Analytics Contributors
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/mark-618/git-analytics
8
+ Project-URL: Repository, https://github.com/mark-618/git-analytics
9
+ Project-URL: Issues, https://github.com/mark-618/git-analytics/issues
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Software Development :: Version Control :: Git
22
+ Requires-Python: >=3.8
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Provides-Extra: share-card
26
+ Requires-Dist: Pillow>=8.0; extra == "share-card"
27
+ Dynamic: license-file
28
+
29
+ # Git Analytics
30
+
31
+ **扫描本地 Git 仓库,生成你的开发者人格画像和代码习惯体检报告。**
32
+
33
+ 不只统计 commits 和 lines——它告诉你:你是什么类型的开发者,你的代码习惯健康吗。
34
+
35
+ ## 安装
36
+
37
+ ```bash
38
+ pip install git-analytics
39
+ ```
40
+
41
+ 如需生成 PNG 分享卡片(可选,需要 Pillow):
42
+
43
+ ```bash
44
+ pip install git-analytics[share-card]
45
+ ```
46
+
47
+ ## 30 秒快速开始
48
+
49
+ ```bash
50
+ # 运行交互式向导,选目录、选参数,一键出报告
51
+ git-analytics
52
+
53
+ # 或者直接指定扫描目录
54
+ git-analytics ~/Projects
55
+ ```
56
+
57
+ 向导会引导你选择扫描目录、扫描深度、输出目录等,不需要记任何参数。
58
+
59
+ ## CLI 用法
60
+
61
+ ```bash
62
+ # 交互式向导(默认)
63
+ git-analytics
64
+
65
+ # 扫描指定目录
66
+ git-analytics ~/Projects
67
+
68
+ # 同时扫描多个目录
69
+ git-analytics ~/Projects ~/Work ~/Side-projects
70
+
71
+ # 关闭向导,适合脚本 / CI
72
+ git-analytics --no-wizard
73
+
74
+ # 指定输出目录 + 自动打开报告 + 生成分享卡片设计器
75
+ git-analytics ~/Projects --output-dir ./out --open --share-card
76
+
77
+ # 限定时间范围
78
+ git-analytics ~/Projects --since 2024-01-01 --until 2024-12-31
79
+
80
+ # 只分析特定项目(模糊匹配)
81
+ git-analytics ~/Projects --project my-app
82
+
83
+ # 增加扫描深度(默认 3)
84
+ git-analytics ~/Projects --max-depth 5
85
+ ```
86
+
87
+ ### 参数一览
88
+
89
+ | 参数 | 说明 |
90
+ |------|------|
91
+ | `scan_dir` | 扫描目录,可传多个(默认当前目录) |
92
+ | `--no-wizard` | 关闭交互式向导 |
93
+ | `--output-dir` | 输出目录(默认当前目录) |
94
+ | `--max-depth` | 扫描目录深度(默认 3) |
95
+ | `--since` / `--until` | 时间范围过滤 |
96
+ | `--project` | 只分析指定项目(模糊匹配) |
97
+ | `--open` | 生成后自动打开报告 |
98
+ | `--share-card` | 同时输出分享卡片设计器 HTML |
99
+
100
+ ## 输出文件
101
+
102
+ | 文件 | 说明 |
103
+ |------|------|
104
+ | `report.html` | 代码习惯体检报告,用浏览器打开 |
105
+ | `data.json` | 原始分析数据(JSON) |
106
+ | `share-card.html` | 分享卡片设计器(使用 `--share-card` 时生成) |
107
+
108
+ ## 它分析什么
109
+
110
+ - **开发者人格**:6 维度光谱分类(时间偏好、节奏风格、专注程度、开发风格、工程取向、AI 协作)
111
+ - **习惯健康分**:0-100 分,覆盖提交粒度、测试意识、文档意识、作息规律、项目聚焦度
112
+ - **时间习惯**:24 小时热力图、最活跃时段、周末工作指数
113
+ - **工程健康**:测试覆盖、文档投入、commit 类型分布、低信息量 commit 占比
114
+ - **AI 使用痕迹**:检测 commit 中的 AI 工具信号(Claude、Copilot、Cursor 等)
115
+ - **项目聚焦度**:Top 3 项目占比、多项目切换分析
116
+
117
+ ## 本地隐私
118
+
119
+ - **完全本地运行**,不上传任何代码或数据
120
+ - 不需要 GitHub Token
121
+ - 可分析私有项目、实验项目、未发布项目
122
+ - 所有数据只存在你的电脑上
123
+
124
+ ## 分享卡片
125
+
126
+ 使用 `--share-card` 生成一个 HTML 设计器,可以在浏览器中:
127
+
128
+ - 预览你的开发者画像卡片
129
+ - 选择配色主题
130
+ - 导出 PNG 图片用于社交分享
131
+
132
+ ## 为什么不是全盘扫描
133
+
134
+ 默认只扫描你指定的目录,不会遍历整个磁盘。原因:
135
+
136
+ 1. 安全:避免意外扫描包含敏感数据的目录
137
+ 2. 性能:全盘扫描耗时太长
138
+ 3. 聚焦:你只关心自己的项目目录
139
+
140
+ ## FAQ
141
+
142
+ ### 扫描不到仓库?
143
+
144
+ - 确认目录下有 `.git` 文件夹
145
+ - 增加 `--max-depth`(默认 3,可以试 5)
146
+ - 检查目录路径是否正确
147
+
148
+ ### 报告打不开?
149
+
150
+ - 用浏览器直接打开 `report.html` 文件
151
+ - 确保文件有读取权限
152
+ - 检查文件大小是否为 0(可能扫描没找到数据)
153
+
154
+ ### 如何扫多个目录?
155
+
156
+ ```bash
157
+ git-analytics ~/Projects ~/Work ~/Code
158
+ ```
159
+
160
+ 多个目录直接用空格分隔。
161
+
162
+ ### 和 GitStats 有什么区别?
163
+
164
+ GitStats 告诉你一个仓库发生了什么;Git Analytics 告诉你你是一个什么样的开发者。
165
+
166
+ ## 技术栈
167
+
168
+ - Python 3.8+
169
+ - 零运行时依赖(纯标准库)
170
+ - Chart.js 可视化报告
171
+ - 本地运行
172
+
173
+ ## License
174
+
175
+ MIT