diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d9ad6735..b10f934c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -245,19 +245,18 @@ repos: # Was on pre-push, but force-push diffs caused full-repo scans + OOM. # =========================================================================== - repo: https://github.com/pylint-dev/pylint - rev: v3.3.2 + rev: v4.1.4 hooks: - id: pylint stages: [pre-commit] args: - --rcfile=pyproject.toml - --fail-under=10 - - --jobs=4 + # One job: dill, which pickles for --jobs>1, breaks on Python 3.15. + - --jobs=1 additional_dependencies: - pytest - - python-chess - requests - - pygame - pillow # archwiki_rag parses the local arch-wiki-docs HTML dump. pylint runs # in its own venv, so a package being in meta/requirements.txt is not @@ -268,7 +267,7 @@ repos: # beautifulsoup4 above: requirements.txt is not on pylint's path. - defusedxml # android_ui's MCP server; same isolated-venv reason. - - fastmcp==4.2.2 + - fastmcp==4.2.4 # artgate computes image gates over pixel arrays. Same reason again: # it is the first package here to import numpy. - numpy @@ -276,6 +275,8 @@ repos: - genanki - gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.1.0#subdirectory=gatelock - sql_drills @ git+https://github.com/kuhyx/utils@sql-drills-v0.2.2#subdirectory=sql_drills + # The shared logo credit on the CLIs' --help; same isolated-venv reason. + - kuhy-credit @ git+https://github.com/kuhyx/utils@kuhy-credit-v0.3.1#subdirectory=kuhy_credit - anthropic - rich - typer diff --git a/docs/superpowers/contracts/kuhy-credit-cli-help-2026-11-21.json b/docs/superpowers/contracts/kuhy-credit-cli-help-2026-11-21.json new file mode 100644 index 00000000..966ac57b --- /dev/null +++ b/docs/superpowers/contracts/kuhy-credit-cli-help-2026-11-21.json @@ -0,0 +1,15 @@ +{ + "title": "kuhy credit on CLI --help", + "objective": "Every interactive python_pkg CLI prints the shared kuhy credit line at the end of --help, imported from kuhy-credit v0.3.1.", + "acceptance_criteria": [ + "--help of android_ui, android_ui.workout_firebase_flow, app_icons, archwiki_rag, artgate, code_tutor, js_anki, morning_routine, phone_lease, random_jpg, sql_drills and vscode_optimizer contains 'Created by kuhy https://kuhy.duckdns.org'", + "the same 12 work under /usr/bin/python", + "pre-commit hooks for the changed files pass" + ], + "out_of_scope": [ + "Changes to kuhyx/utils", + "stdio/daemon entry points without argparse", + "linux_configuration system tooling" + ], + "verifier": "python_pkg/tests/test_cli_credit.py and pre-commit run" +} diff --git a/docs/superpowers/evidence/kuhy-credit-cli-help-2026-11-21.json b/docs/superpowers/evidence/kuhy-credit-cli-help-2026-11-21.json new file mode 100644 index 00000000..01ea3d5f --- /dev/null +++ b/docs/superpowers/evidence/kuhy-credit-cli-help-2026-11-21.json @@ -0,0 +1,52 @@ +{ + "intent": "Every interactive python_pkg CLI ends its --help on kuhy's shared logo credit line (Created by kuhy https://kuhy.duckdns.org). testsAndMisc holds no GUI, web app or game, so --help is the only place the credit can go here.", + "scope": [ + "python_pkg: android_ui (cli, workout_firebase_flow), app_icons, archwiki_rag, artgate, code_tutor, js_anki, morning_routine, phone_lease, random_jpg, sql_drills, vscode_optimizer", + "python_pkg/morning_routine/install.sh installs the pin for /usr/bin/python", + "meta/requirements*.txt, .pre-commit-config.yaml pylint hook, meta/.fvmrc", + "No change to kuhyx/utils: credit_line() already covers terminal programs" + ], + "changes": [ + "argparse parsers take epilog=credit_line(); code_tutor's typer.Typer takes epilog=credit_line()", + "kuhy-credit pinned at v0.3.1 (newest tag) in meta/requirements.txt, meta/requirements-test.txt and the pylint hook env", + "test_cli_credit.py runs each CLI as python -m --help in a subprocess (12 modules)", + "morning_routine/install.sh pip-installs the requirements.txt pin into /usr/bin/python's user site, since its unit runs the system interpreter", + "Flutter pin 3.50.0 -> 3.50.1; stale Python pins bumped (anthropic 2.12.0, coverage 7.17.4, fastmcp 4.2.4, hypothesis 6.170.17)", + "pylint hook: rev v4.1.4, --jobs=1 (dill breaks on 3.15), unused pygame/python-chess deps dropped" + ], + "excluded": [ + "android_ui/mcp_server.py: stdio JSON-RPC, extra stdout breaks the protocol", + "live_calc/calc_eval.py: called per keystroke by the zsh widget; output is the result", + "brother_printer, wallpaper_rotator, phone_guard, endurain_import, archwiki_rag/_reindex_entry: no argparse, daemons or status producers whose stdout other programs read", + "linux_configuration/*.py: monitor_autoconfig (background watcher), g29_shifter_capture (root BPF diagnostic), verify_helium / migrate_helium (installer steps), transcribe_fw/helpers (run in their own venv without kuhy-credit) - system tooling, not apps", + "meta/scripts/*: repo gate tooling", + "GUIs/games: git grep for gatelock|tkinter|pygame|godot outside docs hits only package lists and lint configs; no *.desktop, project.godot or pubspec.yaml is tracked" + ], + "verification": [ + { + "command": ".venv/bin/python -m pytest -q -o addopts= python_pkg/tests/test_cli_credit.py", + "result": "pass", + "evidence": "red first: 7 failed, 5 passed; after the change: 12 passed" + }, + { + "command": "/usr/bin/python -m python_pkg. --help for all 12 modules", + "result": "pass", + "evidence": "each prints 'Created by kuhy https://kuhy.duckdns.org'" + }, + { + "command": "/usr/bin/python -m pip install --user --break-system-packages ", + "result": "pass", + "evidence": "the install.sh step exits 0 with the v0.3.1 pin" + }, + { + "command": "scripts/check_dependency_freshness.sh --all", + "result": "pass", + "evidence": "exit 0 after the Flutter bump" + } + ], + "risks": [ + "morning_routine now imports a third-party package under /usr/bin/python; a fresh machine needs install.sh rerun", + "pylint 4 may flag files the 3.3 hook passed" + ], + "rollback": ["git revert the commit", "re-run pre-commit run pylint"] +} diff --git a/meta/.fvmrc b/meta/.fvmrc index 14bb2a96..dfb61701 100644 --- a/meta/.fvmrc +++ b/meta/.fvmrc @@ -1,3 +1,3 @@ { - "flutter": "3.50.0" + "flutter": "3.50.1" } diff --git a/meta/requirements-test.txt b/meta/requirements-test.txt index 17e8761f..68231a0f 100644 --- a/meta/requirements-test.txt +++ b/meta/requirements-test.txt @@ -21,12 +21,13 @@ # suite itself fails loudly here on a missing import. # ============================================================================== -anthropic==2.10.0 +anthropic==2.12.0 beautifulsoup4==4.15.0 -coverage==7.17.3 +coverage==7.17.4 defusedxml==0.7.1 -fastmcp==4.2.2 +fastmcp==4.2.4 genanki==0.13.1 +kuhy-credit @ git+https://github.com/kuhyx/utils@kuhy-credit-v0.3.1#subdirectory=kuhy_credit markdownify==1.2.4 numpy==2.5.5 pillow==13.0.0 diff --git a/meta/requirements.txt b/meta/requirements.txt index cb7e30fc..88cee725 100644 --- a/meta/requirements.txt +++ b/meta/requirements.txt @@ -6,7 +6,7 @@ add-trailing-comma==4.0.0 aiohttp==3.14.5 -anthropic==2.10.0 +anthropic==2.12.0 autoflake==2.4.0 autopep8==2.3.2 bandit==1.9.4 @@ -15,13 +15,13 @@ berserk==0.14.0 black==26.10.1 bottle==0.13.4 codespell==2.4.3 -coverage==7.17.3 +coverage==7.17.4 cryptography==50.0.2 darglint==1.8.1 dead==2.1.0 defusedxml==0.7.1 docformatter==1.7.8 -fastmcp==4.2.2 +fastmcp==4.2.4 fixit==2.2.1 flake8==7.5.0 flake8-annotations==3.3.1 @@ -40,9 +40,10 @@ gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.16.0#subdirectory=gate genanki==0.13.1 geopandas==1.2.0 howlongtobeatpy==1.0.24 -hypothesis==6.170.15 +hypothesis==6.170.17 importlib-metadata==10.2.0 interrogate==1.7.0 +kuhy-credit @ git+https://github.com/kuhyx/utils@kuhy-credit-v0.3.1#subdirectory=kuhy_credit # isort is deliberately not pinned: nothing here imports it (ruff's isort # rules replaced it) and pylint constrains it (`isort!=5.13,<10,>=5` as of # 4.0.8), so pinning it independently risks an unsolvable environment for a diff --git a/python_pkg/android_ui/cli.py b/python_pkg/android_ui/cli.py index e34d5c97..3b3c9651 100644 --- a/python_pkg/android_ui/cli.py +++ b/python_pkg/android_ui/cli.py @@ -18,6 +18,8 @@ from __future__ import annotations import argparse import sys +from kuhy_credit import credit_line + from python_pkg.android_ui.driver import AndroidUi, UiAutomationError from python_pkg.phone_guard.vd_state import display_owner, own_display from python_pkg.phone_lease import ( @@ -44,6 +46,7 @@ def _build_parser() -> argparse.ArgumentParser: parser = argparse.ArgumentParser( prog="android-ui", description="Drive an Android app by element, never by coordinates.", + epilog=credit_line(), ) parser.add_argument("-s", "--serial", help="target device serial") parser.add_argument( diff --git a/python_pkg/android_ui/workout_firebase_flow.py b/python_pkg/android_ui/workout_firebase_flow.py index c770386d..1b4d480c 100644 --- a/python_pkg/android_ui/workout_firebase_flow.py +++ b/python_pkg/android_ui/workout_firebase_flow.py @@ -25,6 +25,7 @@ import time from typing import TYPE_CHECKING from fastmcp.exceptions import ToolError +from kuhy_credit import credit_line from python_pkg.android_ui._mcp_target import connect from python_pkg.android_ui.driver import ElementNotFoundError, UiAutomationError @@ -127,7 +128,7 @@ def run_flow(ui: AndroidUi, *, account: str | None, timeout: float) -> str: def _parser() -> argparse.ArgumentParser: - parser = argparse.ArgumentParser(prog="workout-firebase-flow") + parser = argparse.ArgumentParser(prog="workout-firebase-flow", epilog=credit_line()) parser.add_argument("--serial", help="device serial (required with 2+ devices)") parser.add_argument( "--display", default="self", help="'self' (default) or 0 for the real screen" diff --git a/python_pkg/app_icons/cli.py b/python_pkg/app_icons/cli.py index b67330ef..4d675cf1 100644 --- a/python_pkg/app_icons/cli.py +++ b/python_pkg/app_icons/cli.py @@ -12,6 +12,8 @@ import argparse from pathlib import Path import sys +from kuhy_credit import credit_line + from python_pkg.app_icons import apps, generate, glyphs, preview @@ -49,6 +51,7 @@ def build_parser() -> argparse.ArgumentParser: parser = argparse.ArgumentParser( prog="python -m python_pkg.app_icons", description="Generate on-style launcher icons for kuhy's Flutter apps.", + epilog=credit_line(), ) subparsers = parser.add_subparsers(dest="command", required=True) diff --git a/python_pkg/archwiki_rag/cli.py b/python_pkg/archwiki_rag/cli.py index 95380317..06b4f245 100644 --- a/python_pkg/archwiki_rag/cli.py +++ b/python_pkg/archwiki_rag/cli.py @@ -11,6 +11,8 @@ import argparse from pathlib import Path import sys +from kuhy_credit import credit_line + from python_pkg.archwiki_rag import reindex as reindex_mod from python_pkg.archwiki_rag.constants import ( DEFAULT_STORE_DIR, @@ -38,6 +40,7 @@ def build_parser() -> argparse.ArgumentParser: parser = argparse.ArgumentParser( prog="python -m python_pkg.archwiki_rag", description="Convert the offline ArchWiki dump into a knowledge-rag corpus.", + epilog=credit_line(), ) subparsers = parser.add_subparsers(dest="command", required=True) diff --git a/python_pkg/artgate/cli.py b/python_pkg/artgate/cli.py index 9713e535..dd8af4ac 100644 --- a/python_pkg/artgate/cli.py +++ b/python_pkg/artgate/cli.py @@ -17,6 +17,7 @@ from pathlib import Path import sys from typing import TYPE_CHECKING +from kuhy_credit import credit_line import numpy as np from PIL import Image, UnidentifiedImageError @@ -134,6 +135,7 @@ def main(argv: list[str] | None = None) -> int: parser = argparse.ArgumentParser( prog="artgate", description="Gate generated game art deterministically.", + epilog=credit_line(), ) parser.add_argument("image", type=Path, help="PNG to check") parser.add_argument("--spec", type=Path, required=True, help="TOML spec") diff --git a/python_pkg/code_tutor/cli.py b/python_pkg/code_tutor/cli.py index 2435cc2e..fa4bab8a 100644 --- a/python_pkg/code_tutor/cli.py +++ b/python_pkg/code_tutor/cli.py @@ -12,6 +12,7 @@ from __future__ import annotations from pathlib import Path import sys +from kuhy_credit import credit_line import requests from rich.console import Console from rich.table import Table @@ -36,7 +37,7 @@ from python_pkg.code_tutor._progress import ( from python_pkg.code_tutor._session import run_session from python_pkg.code_tutor._verifier import Verifier -app = typer.Typer(help="Socratic codebase understanding tutor.") +app = typer.Typer(help="Socratic codebase understanding tutor.", epilog=credit_line()) _console = Console() _OLLAMA_API = "http://localhost:11434/api/tags" diff --git a/python_pkg/js_anki/cli.py b/python_pkg/js_anki/cli.py index 696630a5..0340a044 100644 --- a/python_pkg/js_anki/cli.py +++ b/python_pkg/js_anki/cli.py @@ -6,6 +6,8 @@ import argparse from pathlib import Path import sys +from kuhy_credit import credit_line + from python_pkg.js_anki.deck import build_package from python_pkg.js_anki.models import load_all from python_pkg.js_anki.verify import VerificationError, verify @@ -15,7 +17,11 @@ DEFAULT_OUT = Path(__file__).parent / "build" / "js_methods.apkg" def build_parser() -> argparse.ArgumentParser: """Argument parser with a single `build` subcommand.""" - parser = argparse.ArgumentParser(prog="js_anki", description=__doc__) + parser = argparse.ArgumentParser( + prog="js_anki", + description=__doc__, + epilog=credit_line(), + ) sub = parser.add_subparsers(dest="cmd", required=True) build = sub.add_parser("build", help="verify examples and write the .apkg") build.add_argument("--out", type=Path, default=DEFAULT_OUT) diff --git a/python_pkg/morning_routine/_orchestrator.py b/python_pkg/morning_routine/_orchestrator.py index 84fbc21b..951a1d4c 100644 --- a/python_pkg/morning_routine/_orchestrator.py +++ b/python_pkg/morning_routine/_orchestrator.py @@ -25,6 +25,8 @@ import logging import subprocess import sys +from kuhy_credit import credit_line + from python_pkg.shared.logging_setup import configure_logging _logger = logging.getLogger(__name__) @@ -59,7 +61,9 @@ def _run_workout_lock() -> int: def _parse_args(argv: list[str]) -> argparse.Namespace: """Parse CLI arguments for the orchestrator.""" - parser = argparse.ArgumentParser(description="Unified morning routine.") + parser = argparse.ArgumentParser( + description="Unified morning routine.", epilog=credit_line() + ) parser.add_argument( "--production", action="store_true", diff --git a/python_pkg/morning_routine/install.sh b/python_pkg/morning_routine/install.sh index 3b09a260..51cf4af8 100755 --- a/python_pkg/morning_routine/install.sh +++ b/python_pkg/morning_routine/install.sh @@ -2,6 +2,7 @@ # Install the morning routine: the workout lock, started at the alarm time. # # What it does: +# 0. Installs kuhy-credit (pinned in meta/requirements.txt) for /usr/bin/python. # 1. Installs morning-routine.service (user service, started at alarm time). # 2. Clears the retired standalone wake-alarm.service left by old installs. # 3. Leaves workout-locker.service + the early-bird timer for login / 08:30. @@ -16,9 +17,17 @@ set -euo pipefail SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" SERVICE_SRC="$SCRIPT_DIR/morning-routine.service" SYSTEMD_USER_DIR="$HOME/.config/systemd/user" +REQUIREMENTS="$SCRIPT_DIR/../../meta/requirements.txt" echo "=== Unified Morning Routine Installer ===" +# 0. The unit runs /usr/bin/python, not the repo venv, so the one third-party +# import (the kuhy credit on --help) goes into that interpreter's user site. +# The pin is read from meta/requirements.txt so the two never drift. +echo "[0/2] Installing kuhy-credit for /usr/bin/python..." +credit_pin="$(grep -m1 '^kuhy-credit @' "$REQUIREMENTS")" +/usr/bin/python -m pip install --user --break-system-packages --quiet "$credit_pin" + # 1. Install the orchestrator user service. echo "[1/2] Installing morning-routine.service..." mkdir -p "$SYSTEMD_USER_DIR" diff --git a/python_pkg/phone_lease/__main__.py b/python_pkg/phone_lease/__main__.py index df1b8aec..1ca5afdf 100644 --- a/python_pkg/phone_lease/__main__.py +++ b/python_pkg/phone_lease/__main__.py @@ -12,6 +12,8 @@ from dataclasses import asdict import json import sys +from kuhy_credit import credit_line + from python_pkg.phone_lease.lease import ( DEFAULT_TTL, DEFAULT_WAIT, @@ -37,7 +39,11 @@ def _scoped(parser: argparse.ArgumentParser) -> None: def _build_parser() -> argparse.ArgumentParser: - parser = argparse.ArgumentParser(prog="phone-lease", description=__doc__) + parser = argparse.ArgumentParser( + prog="phone-lease", + description=__doc__, + epilog=credit_line(), + ) sub = parser.add_subparsers(dest="command", required=True) take = sub.add_parser( "acquire", help="take or refresh a lease (exit 3 when held elsewhere)" diff --git a/python_pkg/random_jpg/generate_jpeg.py b/python_pkg/random_jpg/generate_jpeg.py index 5ce67dd5..c05447aa 100644 --- a/python_pkg/random_jpg/generate_jpeg.py +++ b/python_pkg/random_jpg/generate_jpeg.py @@ -7,6 +7,7 @@ import logging from pathlib import Path import secrets +from kuhy_credit import credit_line from PIL import Image _logger = logging.getLogger(__name__) @@ -89,7 +90,8 @@ def _save_image( def main() -> None: """Generate bloated JPEG images from command line arguments.""" parser = argparse.ArgumentParser( - description="Generate bloated JPEG images with random colors." + description="Generate bloated JPEG images with random colors.", + epilog=credit_line(), ) parser.add_argument( "-n", diff --git a/python_pkg/sql_drills/__main__.py b/python_pkg/sql_drills/__main__.py index 16642e71..dff01afa 100644 --- a/python_pkg/sql_drills/__main__.py +++ b/python_pkg/sql_drills/__main__.py @@ -11,6 +11,7 @@ import logging from pathlib import Path import sys +from kuhy_credit import credit_line import sql_drills as sd _LOG = logging.getLogger(__name__) @@ -41,7 +42,9 @@ def _err(line: str) -> None: def _build_parser() -> argparse.ArgumentParser: - parser = argparse.ArgumentParser(prog="sql_drills", description=__doc__) + parser = argparse.ArgumentParser( + prog="sql_drills", description=__doc__, epilog=credit_line() + ) sub = parser.add_subparsers(dest="cmd", required=True) sub.add_parser("start", help="start the MySQL 8.0.33 container and wait") sub.add_parser("stop", help="remove the container") diff --git a/python_pkg/tests/test_cli_credit.py b/python_pkg/tests/test_cli_credit.py new file mode 100644 index 00000000..c98619ba --- /dev/null +++ b/python_pkg/tests/test_cli_credit.py @@ -0,0 +1,45 @@ +"""Every argparse/typer CLI in python_pkg ends its --help with the kuhy credit. + +Each module runs as ``python -m --help`` in a subprocess, the same +way kuhy and the systemd units start it, so the check covers the real entry +point rather than an internal parser builder. +""" + +from __future__ import annotations + +import subprocess +import sys + +from kuhy_credit import credit_line +import pytest + +# Entry points deliberately left without a credit, and why, live in +# docs/superpowers/evidence/kuhy-credit-cli-help-2026-11-21.json. +CREDITED_CLIS = ( + "python_pkg.android_ui", + "python_pkg.android_ui.workout_firebase_flow", + "python_pkg.app_icons", + "python_pkg.archwiki_rag", + "python_pkg.artgate.cli", + "python_pkg.code_tutor.cli", + "python_pkg.js_anki", + "python_pkg.morning_routine._orchestrator", + "python_pkg.phone_lease", + "python_pkg.random_jpg.generate_jpeg", + "python_pkg.sql_drills", + "python_pkg.vscode_optimizer", +) + + +@pytest.mark.parametrize("module", CREDITED_CLIS) +def test_help_ends_with_credit(module: str) -> None: + """``--help`` exits 0 and prints the shared credit line.""" + result = subprocess.run( + [sys.executable, "-m", module, "--help"], + capture_output=True, + text=True, + timeout=30, + check=False, + ) + assert result.returncode == 0, result.stderr + assert credit_line() in result.stdout diff --git a/python_pkg/vscode_optimizer/_optimize.py b/python_pkg/vscode_optimizer/_optimize.py index 2cacdab9..4bdcc950 100644 --- a/python_pkg/vscode_optimizer/_optimize.py +++ b/python_pkg/vscode_optimizer/_optimize.py @@ -9,6 +9,8 @@ import argparse import sys from typing import TYPE_CHECKING +from kuhy_credit import credit_line + from python_pkg.vscode_optimizer._config_io import ( _backup, _discover_variants, @@ -78,7 +80,8 @@ def _apply_variant( def main() -> None: """Entry point: detect hardware, compute optimizations, and apply.""" ap = argparse.ArgumentParser( - description="Auto-optimize VS Code for current hardware." + description="Auto-optimize VS Code for current hardware.", + epilog=credit_line(), ) ap.add_argument("--dry-run", action="store_true", help="Preview without writing.") ap.add_argument("--yes", "-y", action="store_true", help="Skip confirmation.")