tzero-mcp 12.2.0 → 12.2.1
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.
- package/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/src/addmcp.py +2 -2
- package/src/app.py +1 -1
- package/src/tzero/__init__.py +1 -1
- package/src/tzero/tzero_budget.py +1 -1
- package/src/tzero/tzero_ci.py +1 -1
- package/src/tzero/tzero_contracts.py +2 -2
- package/src/tzero/tzero_dashboard.py +3 -3
- package/src/tzero/tzero_debt.py +1 -1
- package/src/tzero/tzero_golden.py +2 -2
- package/src/tzero/tzero_lsp.py +1 -1
- package/src/tzero/tzero_mcp.py +1 -1
- package/src/tzero/tzero_promo.py +1 -1
- package/src/tzero/tzero_task_benchmark.py +2 -2
- package/src/tzero/tzero_traffic.py +1 -1
- package/src/tzero/tzero_tui.py +2 -2
- package/src/tzero/tzero_v3.py +6 -6
- package/src/tzero/tzero_welcome.py +54 -27
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [12.2.1] - 2026-11-25
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- Package installation and the welcome banner no longer install Git hooks or change `core.hooksPath` (#43, #44).
|
|
7
|
+
- Star-reminder hooks now require explicit opt-in via `python -m tzero.tzero_welcome --install-star-hooks` and preserve existing hook managers and files.
|
|
8
|
+
- Hook installation reports failures, rolls back partial writes, and supports linked worktrees.
|
|
9
|
+
- Synchronized the npm-bundled Python runtime with the canonical package.
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- Successful trusted main CI now creates the missing version release and starts all existing publication workflows against its immutable tag.
|
|
13
|
+
- Registry publication errors now fail their workflow instead of being silently reported as success.
|
|
14
|
+
- Updated the English and Turkish README community goal to 500 GitHub stars.
|
|
15
|
+
- Synchronized Python, npm, VS Code/Open VSX, MCP, and release metadata to 12.2.1.
|
|
16
|
+
|
|
3
17
|
## [11.0.0] - 2026-11-11
|
|
4
18
|
|
|
5
19
|
- Bundle the reorganized `tzero/` package and desktop icon.
|
package/package.json
CHANGED
package/src/addmcp.py
CHANGED
|
@@ -22,7 +22,7 @@ from pathlib import Path
|
|
|
22
22
|
from typing import Callable, Dict, List, Optional, Tuple
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
APP_VERSION = "12.2.
|
|
25
|
+
APP_VERSION = "12.2.1"
|
|
26
26
|
SERVER_NAME = "tzero"
|
|
27
27
|
SERVER_FILENAME = "TZeroMCP.exe"
|
|
28
28
|
|
|
@@ -1131,7 +1131,7 @@ def run_init(argv: Optional[List[str]] = None) -> int:
|
|
|
1131
1131
|
# Print banner
|
|
1132
1132
|
print(sanitize_terminal_text("""
|
|
1133
1133
|
\033[1;36m================================================================================
|
|
1134
|
-
⚡ SİBER AKADEMİ — T-ZERO 1-CLICK MCP INITIALIZATION (v12.2.
|
|
1134
|
+
⚡ SİBER AKADEMİ — T-ZERO 1-CLICK MCP INITIALIZATION (v12.2.1)
|
|
1135
1135
|
================================================================================\033[0m
|
|
1136
1136
|
\033[32m★ Zero-Config AST Codebase Context & 100% Zero-Leak Security Guard\033[0m
|
|
1137
1137
|
"""))
|
package/src/app.py
CHANGED
|
@@ -45,7 +45,7 @@ import gradio as gr
|
|
|
45
45
|
# ==================================================================================================
|
|
46
46
|
# CONSTANTS, PALETTES & MULTI-MODEL PRICING TIERS
|
|
47
47
|
# ==================================================================================================
|
|
48
|
-
APP_VERSION = "12.2.
|
|
48
|
+
APP_VERSION = "12.2.1"
|
|
49
49
|
REPO_URL = "https://github.com/toprakahmetaydogmus/TZeroAlgorithm"
|
|
50
50
|
VERCEL_URL = "https://tzero-indol.vercel.app"
|
|
51
51
|
SPACE_URL = "https://huggingface.co/spaces/toprakke4/tzero-token-reducer"
|
package/src/tzero/__init__.py
CHANGED
|
@@ -12,7 +12,7 @@ Capabilities:
|
|
|
12
12
|
- 100% Offline, $0 cost, zero cloud dependencies (Python standard library only).
|
|
13
13
|
|
|
14
14
|
Author: Toprak Ahmet Aydoğmuş (Siber Akademi)
|
|
15
|
-
Part of T-Zero Context Architect v12.2.
|
|
15
|
+
Part of T-Zero Context Architect v12.2.1 Master Edition.
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
18
|
import hashlib
|
package/src/tzero/tzero_ci.py
CHANGED
|
@@ -755,7 +755,7 @@ def main():
|
|
|
755
755
|
prog="tzero-ci",
|
|
756
756
|
description="Siber Akademi T-Zero Local CI Pipeline & Pre-Push Verification Shield"
|
|
757
757
|
)
|
|
758
|
-
parser.add_argument("--version", "-v", action="version", version="%(prog)s 12.2.
|
|
758
|
+
parser.add_argument("--version", "-v", action="version", version="%(prog)s 12.2.1")
|
|
759
759
|
parser.add_argument("--quick", "-q", action="store_true", help="Run fast verification battery (seconds)")
|
|
760
760
|
parser.add_argument("--all", "-a", action="store_true", help="Run full matrix verification battery")
|
|
761
761
|
parser.add_argument("--fix", action="store_true", help="Attempt auto-repair for auto-fixable gates (metadata sync)")
|
|
@@ -13,7 +13,7 @@ Capabilities:
|
|
|
13
13
|
- 100% Offline, $0 cost, zero external dependencies (pure Python standard library).
|
|
14
14
|
|
|
15
15
|
Author: Toprak Ahmet Aydoğmuş (Siber Akademi)
|
|
16
|
-
Part of T-Zero Context Architect v12.2.
|
|
16
|
+
Part of T-Zero Context Architect v12.2.1 Master Edition.
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
19
|
import ast
|
|
@@ -1054,7 +1054,7 @@ class ASTContractComparator:
|
|
|
1054
1054
|
"tool": {
|
|
1055
1055
|
"driver": {
|
|
1056
1056
|
"name": "T-Zero Contract Guardian",
|
|
1057
|
-
"version": "12.2.
|
|
1057
|
+
"version": "12.2.1",
|
|
1058
1058
|
"rules": rules_list
|
|
1059
1059
|
}
|
|
1060
1060
|
},
|
|
@@ -457,7 +457,7 @@ HTML_PAGE = """<!DOCTYPE html>
|
|
|
457
457
|
<div class="brand-logo">T0</div>
|
|
458
458
|
<div>
|
|
459
459
|
<div class="brand-title">T-Zero Developer Console</div>
|
|
460
|
-
<div class="brand-sub" id="headerBrandSub">Enterprise AST Context Architect • v12.2.
|
|
460
|
+
<div class="brand-sub" id="headerBrandSub">Enterprise AST Context Architect • v12.2.1</div>
|
|
461
461
|
</div>
|
|
462
462
|
</div>
|
|
463
463
|
<div class="header-actions">
|
|
@@ -850,7 +850,7 @@ x = 2
|
|
|
850
850
|
</main>
|
|
851
851
|
|
|
852
852
|
<footer>
|
|
853
|
-
<span id="footerBrand">T-Zero Context Architect v12.2.
|
|
853
|
+
<span id="footerBrand">T-Zero Context Architect v12.2.1</span> • Developer: Toprak Ahmet Aydoğmuş • Siber Akademi
|
|
854
854
|
</footer>
|
|
855
855
|
|
|
856
856
|
<script>
|
|
@@ -1481,7 +1481,7 @@ def compute_live_dashboard_stats(workspace_dir: str = ".") -> Dict[str, Any]:
|
|
|
1481
1481
|
if cached is not None and (now - _DASHBOARD_STATS_CACHE["ts"]) < 60.0:
|
|
1482
1482
|
return cached
|
|
1483
1483
|
|
|
1484
|
-
version = "12.2.
|
|
1484
|
+
version = "12.2.1"
|
|
1485
1485
|
tools_count = 57
|
|
1486
1486
|
try:
|
|
1487
1487
|
from tzero import tzero_mcp
|
package/src/tzero/tzero_debt.py
CHANGED
|
@@ -13,7 +13,7 @@ Capabilities:
|
|
|
13
13
|
- 100% Offline, $0 cost, zero cloud dependencies (Python standard library only).
|
|
14
14
|
|
|
15
15
|
Author: Toprak Ahmet Aydoğmuş (Siber Akademi)
|
|
16
|
-
Part of T-Zero Context Architect v12.2.
|
|
16
|
+
Part of T-Zero Context Architect v12.2.1 Master Edition.
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
19
|
import ast
|
|
@@ -11,7 +11,7 @@ Capabilities:
|
|
|
11
11
|
- 100% Offline, $0 cost, zero cloud dependencies (Python standard library only).
|
|
12
12
|
|
|
13
13
|
Author: Toprak Ahmet Aydoğmuş (Siber Akademi)
|
|
14
|
-
Part of T-Zero Context Architect v12.2.
|
|
14
|
+
Part of T-Zero Context Architect v12.2.1 Master Edition.
|
|
15
15
|
"""
|
|
16
16
|
|
|
17
17
|
import ast
|
|
@@ -194,7 +194,7 @@ class ASTGoldenRegressionEngine:
|
|
|
194
194
|
|
|
195
195
|
return GoldenBaseline(
|
|
196
196
|
workspace_root=abs_root,
|
|
197
|
-
version="12.2.
|
|
197
|
+
version="12.2.1",
|
|
198
198
|
created_at=time.time(),
|
|
199
199
|
symbols=all_sigs,
|
|
200
200
|
total_symbols=len(all_sigs),
|
package/src/tzero/tzero_lsp.py
CHANGED
package/src/tzero/tzero_mcp.py
CHANGED
|
@@ -33,7 +33,7 @@ import ast
|
|
|
33
33
|
import inspect
|
|
34
34
|
import logging
|
|
35
35
|
|
|
36
|
-
SERVER_VERSION = "12.2.
|
|
36
|
+
SERVER_VERSION = "12.2.1"
|
|
37
37
|
|
|
38
38
|
# Version checks must not initialize the MCP SDK or dependency bootstrap. Besides
|
|
39
39
|
# being needlessly expensive, that path may wait on package discovery/network
|
package/src/tzero/tzero_promo.py
CHANGED
|
@@ -75,7 +75,7 @@ class TaskEvaluationResult:
|
|
|
75
75
|
|
|
76
76
|
@dataclass
|
|
77
77
|
class TaskBenchmarkReport:
|
|
78
|
-
version: str = "12.2.
|
|
78
|
+
version: str = "12.2.1"
|
|
79
79
|
tokenizer: str = "tiktoken (cl100k_base)" if TIKTOKEN_AVAILABLE else "character-ratio fallback"
|
|
80
80
|
total_tasks: int = 0
|
|
81
81
|
passed_tasks: int = 0
|
|
@@ -465,7 +465,7 @@ def analyze_symbol_impact(symbol_path: str, table: SymbolTable, dag: CallGraphDA
|
|
|
465
465
|
"""Formats ANSI-styled benchmark summary table."""
|
|
466
466
|
lines = []
|
|
467
467
|
lines.append("=" * 78)
|
|
468
|
-
lines.append(" T-ZERO TASK-COMPLETION & BPE TOKENIZER BENCHMARK REPORT (v12.2.
|
|
468
|
+
lines.append(" T-ZERO TASK-COMPLETION & BPE TOKENIZER BENCHMARK REPORT (v12.2.1)")
|
|
469
469
|
lines.append(f" Tokenizer: {report.tokenizer} | Tasks Evaluated: {report.total_tasks}")
|
|
470
470
|
lines.append("=" * 78)
|
|
471
471
|
lines.append(f"{'Task ID':<10} | {'Raw BPE':<8} | {'T-Zero':<8} | {'Saved %':<8} | {'Contract %':<10} | {'Status'}")
|
|
@@ -18,7 +18,7 @@ import webbrowser
|
|
|
18
18
|
from pathlib import Path
|
|
19
19
|
from typing import Any, Dict, List, Optional, Tuple
|
|
20
20
|
|
|
21
|
-
CURRENT_VERSION = "12.2.
|
|
21
|
+
CURRENT_VERSION = "12.2.1"
|
|
22
22
|
REPO_URL = "https://github.com/toprakahmetaydogmus/TZeroAlgorithm"
|
|
23
23
|
RELEASES_URL = f"{REPO_URL}/releases"
|
|
24
24
|
PYPI_URL = "https://pypi.org/project/tzero-mcp/"
|
package/src/tzero/tzero_tui.py
CHANGED
|
@@ -180,7 +180,7 @@ class TZeroTerminalCockpit:
|
|
|
180
180
|
box_bottom = f"{c.CYAN}╚{'═' * 78}╝{c.RESET}"
|
|
181
181
|
|
|
182
182
|
lines.append(box_top)
|
|
183
|
-
lines.append(cls._box_line(f" {c.BOLD}{c.BRIGHT_CYAN}⚡ SİBER AKADEMİ — T-ZERO CONTEXT ARCHITECT & LIVE COCKPIT v12.2.
|
|
183
|
+
lines.append(cls._box_line(f" {c.BOLD}{c.BRIGHT_CYAN}⚡ SİBER AKADEMİ — T-ZERO CONTEXT ARCHITECT & LIVE COCKPIT v12.2.1{c.RESET}"))
|
|
184
184
|
lines.append(cls._box_line(f" {c.DIM}Zero-Leak AST Intelligence | 100% Offline | $0 Cloud Cost Guarantee{c.RESET}"))
|
|
185
185
|
lines.append(box_mid)
|
|
186
186
|
|
|
@@ -325,7 +325,7 @@ class TZeroTerminalCockpit:
|
|
|
325
325
|
elif choice == "4":
|
|
326
326
|
from tzero.tzero_commit import LocalSemanticCommitSynthesizer
|
|
327
327
|
print(f"\n{cls.YELLOW}[Synthesizing Release CHANGELOG]...{cls.RESET}")
|
|
328
|
-
entry = LocalSemanticCommitSynthesizer.generate_changelog_entry(version="v12.2.
|
|
328
|
+
entry = LocalSemanticCommitSynthesizer.generate_changelog_entry(version="v12.2.1", repo_dir=workspace_dir)
|
|
329
329
|
print(f"\n{cls.BRIGHT_CYAN}{entry}{cls.RESET}\n")
|
|
330
330
|
input("Press Enter to return to cockpit...")
|
|
331
331
|
elif choice == "5":
|
package/src/tzero/tzero_v3.py
CHANGED
|
@@ -493,7 +493,7 @@ def calculate_token_cost(token_count: int, provider_name: str) -> float:
|
|
|
493
493
|
# i18n Translations
|
|
494
494
|
TRANSLATIONS: Dict[str, Dict[str, str]] = {
|
|
495
495
|
"en": {
|
|
496
|
-
"title": "T-Zero Developer Console & Context Architect v12.2.
|
|
496
|
+
"title": "T-Zero Developer Console & Context Architect v12.2.1",
|
|
497
497
|
"subtitle": f"Developer: {DEV_NAME} | {DEV_URL_MAIN} | {DEV_URL_BIO}",
|
|
498
498
|
"overview_tab": "🏠 Overview Dashboard",
|
|
499
499
|
"setup_tab": "⚡ Setup & AI Models",
|
|
@@ -530,7 +530,7 @@ TRANSLATIONS: Dict[str, Dict[str, str]] = {
|
|
|
530
530
|
"audit_btn": "🛡️ SECURITY AUDIT"
|
|
531
531
|
},
|
|
532
532
|
"tr": {
|
|
533
|
-
"title": "T-Zero Geliştirici Konsolu & Bağlam Mimarı v12.2.
|
|
533
|
+
"title": "T-Zero Geliştirici Konsolu & Bağlam Mimarı v12.2.1",
|
|
534
534
|
"subtitle": f"Geliştirici: {DEV_NAME} | {DEV_URL_MAIN} | {DEV_URL_BIO}",
|
|
535
535
|
"overview_tab": "🏠 Genel Bakış",
|
|
536
536
|
"setup_tab": "⚡ Kurulum & Model",
|
|
@@ -9453,7 +9453,7 @@ def main():
|
|
|
9453
9453
|
default="o200k_base", help="BPE encoding for --symbol-context")
|
|
9454
9454
|
parser.add_argument("--cache-aligned", action="store_true", help="Order context for KV-cache prefix stability (immutable static prefix before dynamic query suffix)")
|
|
9455
9455
|
parser.add_argument("--commit-msg", action="store_true", help="Generate Conventional Commit message from local AST git diff ($0 local engine)")
|
|
9456
|
-
parser.add_argument("--changelog", nargs="?", const="v12.2.
|
|
9456
|
+
parser.add_argument("--changelog", nargs="?", const="v12.2.1", default=None, metavar="VERSION", help="Generate release CHANGELOG markdown from git history")
|
|
9457
9457
|
parser.add_argument("--ci", choices=["github", "gitlab", "pre-commit", "local", "all"], default=None, help="Install CI/CD workflow or run local verification suite")
|
|
9458
9458
|
parser.add_argument("--local-ci", action="store_true", help="Run comprehensive Local CI & Pre-Push verification battery ($0 quota burn)")
|
|
9459
9459
|
parser.add_argument("--quick-ci", action="store_true", help="Run fast Local CI smoke checks in seconds")
|
|
@@ -9517,7 +9517,7 @@ def main():
|
|
|
9517
9517
|
parser.add_argument("--card", "--badge", nargs="?", const="assets/tzero_badge_card.svg", default=None, metavar="FILE", help="Generate viral dark-mode SVG banner card and GitHub README badges")
|
|
9518
9518
|
parser.add_argument("--showcase", nargs="?", const="tzero_showcase.html", default=None, metavar="FILE", help="Generate interactive split-screen HTML5 comparison showcase slider")
|
|
9519
9519
|
parser.add_argument("--marketing", "--growth", action="store_true", help="Launch $0-budget viral growth engine and export campaign materials for Reddit, HN, X, and Product Hunt")
|
|
9520
|
-
parser.add_argument("--version", "-v", action="version", version="T-Zero Context Architect v12.2.
|
|
9520
|
+
parser.add_argument("--version", "-v", action="version", version="T-Zero Context Architect v12.2.1 Master Edition (engine v4.1.0)")
|
|
9521
9521
|
|
|
9522
9522
|
|
|
9523
9523
|
def print_master_tutorial():
|
|
@@ -9626,7 +9626,7 @@ If this open-source tool helped you, please consider giving us a ⭐ on GitHub:
|
|
|
9626
9626
|
def print_quickstart_guide():
|
|
9627
9627
|
print("""
|
|
9628
9628
|
================================================================================
|
|
9629
|
-
⚡ SİBER AKADEMİ — T-ZERO CONTEXT ARCHITECT & MCP v12.2.
|
|
9629
|
+
⚡ SİBER AKADEMİ — T-ZERO CONTEXT ARCHITECT & MCP v12.2.1 MASTER (engine v4.1.0)
|
|
9630
9630
|
================================================================================
|
|
9631
9631
|
🎯 %95'e Varan Token Tasarrufu & Otonom Yapay Zeka Mimari Bağlam Motoru
|
|
9632
9632
|
|
|
@@ -10600,7 +10600,7 @@ If this open-source tool helped you, please consider giving us a ⭐ on GitHub:
|
|
|
10600
10600
|
if not os.path.exists(app_path):
|
|
10601
10601
|
app_path = os.path.join(os.getcwd(), "huggingface-space", "app.py")
|
|
10602
10602
|
print("\033[36m" + "=" * 80)
|
|
10603
|
-
print("🤗 SİBER AKADEMİ — T-ZERO HUGGING FACE SPACE & GRADIO COCKPIT (v12.2.
|
|
10603
|
+
print("🤗 SİBER AKADEMİ — T-ZERO HUGGING FACE SPACE & GRADIO COCKPIT (v12.2.1)")
|
|
10604
10604
|
print("=" * 80 + "\033[0m")
|
|
10605
10605
|
print("🌐 Official Live Space : https://huggingface.co/spaces/toprakke4/tzero-token-reducer")
|
|
10606
10606
|
print(f"📁 Local Application : {app_path}")
|
|
@@ -6,9 +6,11 @@ License: AGPL-3.0-only
|
|
|
6
6
|
Repository: https://github.com/toprakahmetaydogmus/TZeroAlgorithm
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
|
+
import argparse
|
|
9
10
|
import os
|
|
10
|
-
import sys
|
|
11
11
|
import subprocess
|
|
12
|
+
import sys
|
|
13
|
+
import warnings
|
|
12
14
|
from pathlib import Path
|
|
13
15
|
from typing import Optional
|
|
14
16
|
|
|
@@ -36,7 +38,7 @@ except ImportError:
|
|
|
36
38
|
return False
|
|
37
39
|
|
|
38
40
|
REPO_URL = "https://github.com/toprakahmetaydogmus/TZeroAlgorithm"
|
|
39
|
-
VERSION = "12.2.
|
|
41
|
+
VERSION = "12.2.1"
|
|
40
42
|
_BANNER_PRINTED = False
|
|
41
43
|
|
|
42
44
|
|
|
@@ -44,7 +46,7 @@ def find_git_root(start_dir: Optional[Path] = None) -> Optional[Path]:
|
|
|
44
46
|
"""Recursively locates .git root directory starting from start_dir or cwd."""
|
|
45
47
|
curr = (start_dir or Path.cwd()).resolve()
|
|
46
48
|
for p in [curr] + list(curr.parents):
|
|
47
|
-
if (p / ".git").
|
|
49
|
+
if (p / ".git").exists():
|
|
48
50
|
return p
|
|
49
51
|
return None
|
|
50
52
|
|
|
@@ -109,8 +111,6 @@ def print_star_banner(force: bool = False) -> None:
|
|
|
109
111
|
_BANNER_PRINTED = True
|
|
110
112
|
# On first interactive terminal run, open GitHub repository to encourage star
|
|
111
113
|
check_first_launch_repo_open()
|
|
112
|
-
# Silently ensure git hooks are installed if running inside repository
|
|
113
|
-
install_git_star_hooks()
|
|
114
114
|
except Exception:
|
|
115
115
|
pass
|
|
116
116
|
|
|
@@ -143,13 +143,37 @@ def check_first_launch_repo_open(force_open: bool = False, state_path: Optional[
|
|
|
143
143
|
|
|
144
144
|
|
|
145
145
|
def install_git_star_hooks(repo_dir: Optional[Path] = None) -> bool:
|
|
146
|
-
"""
|
|
146
|
+
"""Install reminders only when explicitly called; never change Git configuration.
|
|
147
|
+
|
|
148
|
+
Refuse configured hook managers and existing active hooks. The default Git
|
|
149
|
+
hooks directory also works for linked worktrees; no core.hooksPath is needed.
|
|
150
|
+
"""
|
|
151
|
+
created = []
|
|
147
152
|
try:
|
|
148
153
|
target_dir = find_git_root(repo_dir)
|
|
149
154
|
if not target_dir:
|
|
150
|
-
|
|
155
|
+
raise ValueError("not inside a Git repository")
|
|
151
156
|
|
|
152
|
-
|
|
157
|
+
configured = subprocess.run(
|
|
158
|
+
["git", "config", "--get", "core.hooksPath"], cwd=target_dir,
|
|
159
|
+
capture_output=True, text=True, check=False,
|
|
160
|
+
)
|
|
161
|
+
if configured.returncode == 0:
|
|
162
|
+
raise ValueError("core.hooksPath is already configured; existing hooks preserved")
|
|
163
|
+
if configured.returncode != 1:
|
|
164
|
+
raise ValueError("could not read Git hook configuration")
|
|
165
|
+
|
|
166
|
+
result = subprocess.run(
|
|
167
|
+
["git", "rev-parse", "--path-format=absolute", "--git-path", "hooks"],
|
|
168
|
+
cwd=target_dir, capture_output=True, text=True, check=True,
|
|
169
|
+
)
|
|
170
|
+
githooks_dir = Path(result.stdout.strip())
|
|
171
|
+
if not githooks_dir.is_absolute():
|
|
172
|
+
raise ValueError("Git did not return an absolute hooks directory")
|
|
173
|
+
if githooks_dir.exists() and any(
|
|
174
|
+
not entry.name.endswith(".sample") for entry in githooks_dir.iterdir()
|
|
175
|
+
):
|
|
176
|
+
raise ValueError("existing Git hooks found; no hooks were changed")
|
|
153
177
|
githooks_dir.mkdir(parents=True, exist_ok=True)
|
|
154
178
|
|
|
155
179
|
hook_content = f"""#!/bin/sh
|
|
@@ -162,34 +186,37 @@ exit 0
|
|
|
162
186
|
"""
|
|
163
187
|
for hook_name in ("post-checkout", "post-merge"):
|
|
164
188
|
hook_file = githooks_dir / hook_name
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
# Set core.hooksPath in git config
|
|
172
|
-
subprocess.run(
|
|
173
|
-
["git", "config", "core.hooksPath", ".githooks"],
|
|
174
|
-
cwd=target_dir,
|
|
175
|
-
stdout=subprocess.DEVNULL,
|
|
176
|
-
stderr=subprocess.DEVNULL,
|
|
177
|
-
check=False
|
|
178
|
-
)
|
|
189
|
+
# Exclusive creation also protects hooks created after the checks above.
|
|
190
|
+
with hook_file.open("x", encoding="utf-8", newline="\n") as stream:
|
|
191
|
+
created.append(hook_file)
|
|
192
|
+
stream.write(hook_content)
|
|
193
|
+
hook_file.chmod(0o755)
|
|
179
194
|
return True
|
|
180
|
-
except
|
|
195
|
+
except (OSError, ValueError, subprocess.SubprocessError) as exc:
|
|
196
|
+
for hook_file in created:
|
|
197
|
+
hook_file.unlink(missing_ok=True)
|
|
198
|
+
warnings.warn(f"Star reminder hooks were not installed: {exc}", stacklevel=2)
|
|
181
199
|
return False
|
|
182
200
|
|
|
183
201
|
|
|
184
|
-
def main():
|
|
202
|
+
def main(argv=None) -> int:
|
|
185
203
|
"""CLI entrypoint for scripts/welcome.py."""
|
|
204
|
+
parser = argparse.ArgumentParser(description="T-Zero community welcome")
|
|
205
|
+
parser.add_argument(
|
|
206
|
+
"--install-star-hooks", action="store_true",
|
|
207
|
+
help="Explicitly install star reminders in an unused default Git hooks directory",
|
|
208
|
+
)
|
|
209
|
+
args = parser.parse_args(argv)
|
|
186
210
|
init_terminal()
|
|
187
211
|
print_star_banner(force=True)
|
|
188
|
-
if
|
|
189
|
-
|
|
212
|
+
if args.install_star_hooks:
|
|
213
|
+
if not install_git_star_hooks():
|
|
214
|
+
return 1
|
|
215
|
+
print(sanitize_terminal_text("\033[32m✔ Git community hooks installed\033[0m"))
|
|
190
216
|
info_text = f"\033[36mFor questions or support, visit:\033[0m {REPO_URL}/discussions\n"
|
|
191
217
|
print(sanitize_terminal_text(info_text))
|
|
218
|
+
return 0
|
|
192
219
|
|
|
193
220
|
|
|
194
221
|
if __name__ == "__main__":
|
|
195
|
-
main()
|
|
222
|
+
raise SystemExit(main())
|