← Keyhac crftwr/keyhac on GitHub · craftware

Packaging, launchers, distribution

Languages: the complete answer

Layer Language Size Why
Application (engine, UI, platform bindings) Python (3.15t, free-threaded, in the apps) ~everything ctypes covers Win32 (PuiKit’s Windows backend proves it incl. COM/Direct2D); PyObjC covers Quartz/AX/AppKit
Embedding launcher, Windows (Keyhac.exe) C ~150 lines PEP 587 PyConfig isolated init, module search paths. Also: exe icon, DPI manifest.
Embedding launcher, macOS (Keyhac.app main) Objective-C ~150 lines Same PEP 587 pattern. A real bundle executable is required so the Accessibility permission attaches to a stable identity — running under a generic python3 would grant the permission to that interpreter, not to Keyhac.
Build scripts PowerShell / shell / Python   windows_app/build.ps1, macos_app/build.sh, tools/

No ckit, no pyauto, no compiled extension of our own. Runtime dependencies: puikit, pyobjc-framework-{Cocoa,Quartz,ApplicationServices} (macOS only), pillow (via puikit). The pipeline is a port of XeFM’s Makefile/bundle system — the author’s shipped PuiKit app, the standard to follow for build infra.

Windows: windows_app/

Microsoft Store (MSIX)

Ported from XeFM’s pipeline (../xefm/windows_app/build_msix.ps1, doc/dev/WINDOWS_STORE_MSIX_PLAN.md there has the full background). The Store route exists because it makes Windows code signing free: the package is uploaded unsigned and Microsoft re-signs it during certification — no certificate to buy, no SmartScreen warning, and a winget install --source msstore line for free.

macOS: macos_app/

HTTPS verification: the OS, not a PEM file (#279)

Python’s ssl verifies with OpenSSL against a static CA file and checks no revocation. Keyhac.app’s python.org Python.framework looks for that file at /Library/Frameworks/Python.framework/Versions/3.14/etc/openssl/cert.pem, outside the app: missing on a Mac without python.org’s Python (CERTIFICATE_VERIFY_FAILED), and that installation’s certifi on a Mac with it. The framework’s own site-packages/certifi, copied in with it, is as old as the build machine’s. Neither, nor /etc/ssl/cert.pem, refused the revoked eMudhra intermediates (October 2026).

So main() calls keyhac.tls.use_os_trust_store() before anything else, keyhac deps included: truststore.inject_into_ssl() on darwin and win32, which replaces ssl.SSLContext process-wide. urllib, requests and anything else that builds a context afterwards verify through Security.framework / CryptoAPI: revocation is checked, and Keychain or certificate-store roots (corporate proxies, MDM) are trusted. A context built before the call keeps OpenSSL - urllib.request.urlopen caches its opener on first use - which is why it is the first thing main() does. On Windows it also covers the roots Windows has not fetched yet, which OpenSSL reading the store would not see.

truststore is a marker-gated [project] dependency, so both bundles collect it; if it is missing (an old pip install), Keyhac logs a warning and keeps OpenSSL. A synced package’s own truststore is pruned like any other distribution Keyhac already provides.

Shared tooling

Release pipeline

make tag → make release-github → make release-macos-dmg (on macOS) / make release-windows-zip (on Windows) → make release-whl → make release-skill; make release-status shows where a version stands. make release-windows-msix (on Windows) is the odd one out: it submits to the Microsoft Store, not the GitHub Release. After the DMG is attached, brew bump-cask-pr --no-fork --version X.Y.Z crftwr/tap/keyhac bumps the cask in crftwr/homebrew-tap (by hand, not from the Makefile; the cask is only a URL and a sha256 pointing at that DMG). Supporting scripts: tools/{release_preflight,bump_version,_version_source}.py. The version lives in keyhac/__init__.py (__version__), one number for both OSes.

make release-review (tools/release_review.py) runs before make tag, from the release skill’s step 2, and reports what is about to ship against CLAUDE.md’s rules; it fixes nothing. Keyhac has no CI and most changes land through the maintainer’s own sessions, so this one pass over the last tag..origin/main is where drift across many small changes shows.

Release artifacts per version: Keyhac-<ver>-macos.dmg, Keyhac-<ver>-win-x64.zip, Keyhac-<ver>-win-arm64.zip, the skill bundles - one zip per folder in keyhac/skills/, all attached to the GitHub Release - and the keyhac wheel on PyPI. PuiKit is versioned/released independently on PyPI; Keyhac2 pins a minimum in pyproject.toml.

A bundle built off the release tag, or from a dirty tree, is named and stamped with a dev version (2.7.0+dev.g<sha>), and its links to the repository name the commit. So release-skill uploads only a bundle built from a clean checkout at the tag: from anywhere else, the keyhac-<ver>-skill.zip it looks for is not built.

release-skill is not optional the way it looks. The bundles are the only way a user can obtain the skills — make skill-bundle needs the Makefile and tools/, and neither ships — so a release without it leaves doc/ai-integration.md pointing at an asset that is not there, and leaves anyone who connects the MCP endpoint in the half-installed state that fails quietly: the tools work and the actions come back full of sleep and screen coordinates.

Data & config paths (unified)

Item Path (both OSes)
Config ~/.keyhac/config.py (template copied on first run)
Extensions ~/.keyhac/extensions/ (on sys.path)
Clipboard history ~/.keyhac/clipboard.json
App settings ~/.keyhac/settings.json
Extra libraries ~/.keyhac/requirements.txt → ~/.keyhac/site-packages/X.Y/ (appended to sys.path, not purged on reload)

With --config PATH, clipboard.json and settings.json live beside the config (sandbox isolation). Windows portable mode (everything next to Keyhac.exe) is not implemented yet — issue tracker.

Extra Python libraries: requirements.txt (#272)

The bundles are sealed, so a library Keyhac does not ship reaches config.py through ~/.keyhac/requirements.txt and a user-started sync (keyhac/core/python_packages.py; the user doc is in configuration.md). The design is XeFM’s (crftwr/xefm#664) and the module is a port of xefm/python_packages.py; keep the two in step.

<data dir>/requirements.txt
<data dir>/site-packages/
    3.14/            target, appended to sys.path with site.addsitedir
        .stamp       JSON: requirements sha256, host sha256, python, platform
    .3.14.new/       staging: built by a sync, swapped in whole
    .3.14.old/       the previous target during a swap
    .pip/            pip wheel downloaded from PyPI (Windows app only)

Which interpreter and which pip (keyhac_python(), pip_command()):

Install Interpreter pip
pip / pipx / uv, source checkout sys.executable python -m pip, else ensurepip’s bundled wheel
macOS app sys.base_prefix/bin/python3 (the framework’s; relocate_embedded_interpreter makes it runnable) python3 -m pip: the python.org framework’s site-packages/pip, which build.sh keeps
Windows app (zip, Store) <root>\runtime\python.exe neither pip nor ensurepip in the embeddable CPython: a pip wheel from PyPI, sha256-checked against PyPI’s digest, cached in site-packages/.pip/

pip runs with PYTHONDONTWRITEBYTECODE=1, since a .pyc written into the signed macOS bundle would break its seal. pip still compiles what it installs, into the target.

Verified on macOS (2026-10-22), against a Developer ID–signed, hardened-runtime build: a sync run with the bundle’s python3 installed markupsafe from PyPI, the same interpreter imported its unsigned _speedups .so from the target, and the bundle gained no .pyc. Still open: