Fast Alfred Script Filters
Use Python 3.15 or newer. Keep the cached entry point separate from the full
builder: subclassing AlfredWorkflow loads Pydantic even with lazy imports.
A small entry script can serve cached results without loading Pydantic or HTTPX:
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.15"
# dependencies = ["we-love-alfred"]
# ///
import sys
from pathlib import Path
from we_love.alfred.fast import serve
__lazy_modules__ = ("builder",)
from builder import main
if not serve(" ".join(sys.argv[1:]), script=Path(__file__).with_name("builder.py")):
main()
builder.py is a regular Python module using the same interpreter and installed
dependencies as the entry script. Its main() should build and print the menu.
When launched with --no-cache, it must rebuild instead of reading the cache.
The detached refresh uses sys.executable, passes arguments directly without a
shell, and sets PYDANTIC_DISABLE_PLUGINS=__all__ in the child environment.
Only use that setting when the builder does not need Pydantic plugins.
serve() returns False for a missing, malformed, or unreadable cache. For a
valid cache it filters each query token as a case-insensitive subsequence of the
item's match value, falling back to title, prints the result, and returns
True. It omits Alfred's cache field from filtered responses so Alfred cannot
reuse one query's results for another query. It keeps serving stale data while
refreshing; the .refresh.pid file throttles attempts to once per minute,
including failed launches. A file lock prevents simultaneous launches.
Caches live under $XDG_CACHE_HOME/alfred/, otherwise ~/.cache/alfred/ when
~/.cache exists, otherwise /tmp/alfred/.
The filename uses alfred_workflow_bundleid; outside Alfred the compatibility
fallback is maxcare-menu.json. Use serve(name="my-workflow") with
AlfredWorkflow(cache_name="my-workflow") and
AlfredWorkflow.read_cache("my-workflow") to select a name explicitly.
The builder's clear-cache action uses the same cache and refresh marker paths.
Both the fast writer and the builder replace completed cache files atomically. The fast path validates the menu envelope and item titles with the stdlib; the full builder validates the complete menu with Pydantic.
Do not add --refresh-package to a Script Filter shebang: it reinstalls the
package on every keystroke. Use it once from a terminal after changing a local
package. HTTPX and editor discovery are lazy imports; favicon discovery uses
async HTTPX without favicon, Requests, or Beautiful Soup.
we_love.alfred.github.PullRequestCache.load() also stays on the cached path:
it serves stale data while refreshing and returns an empty list on a cache miss
or malformed data. All automatic retries use the same warming throttle.
Call fetch() explicitly when a caller needs to wait for current PR data.
The clear-cache action also clears Alfred's own cache directory for this workflow
and .cache files in its data directory, while preserving settings and other
workflow data. Paths are resolved when building the menu, before zsh:// dispatch.
Without a bundle ID or explicit workflow paths, shared workflow roots are never
selected for deletion.
Okta app tiles (opt-in)
we_love.alfred.okta.OktaAppsMixin lists the signed-in user's Okta app tiles,
each opening its Okta SSO link. Mix it into the builder's workflow, set
okta_org and a client ID, pass add_okta_items to builder(), and handle
okta-login in the script by awaiting okta_login() before rebuilding:
class MyWorkflow(OktaAppsMixin, AlfredWorkflow):
okta_org: str = "https://example.okta.com"
okta_client_id: str = "0oa..."
The Okta app must be a public native OIDC app with the device authorization
and refresh token grants and the okta.users.read.self API scope granted.
Until the user connects, the menu shows one connect item that runs the device
flow. The rotating refresh token is stored in the macOS Keychain under
okta_keychain_service, and the app list is refetched once okta_apps_ttl
(one day) has passed, keeping the old tiles through an Okta outage. Override
resolve_okta_client_id() to read the client ID from somewhere else.
Verified API examples and boundaries
>>> menu = {"items": [{"title": "Hello"}, {"title": "Other"}]}
>>> filter_menu(menu, "hello")["items"]
[{'title': 'Hello'}]
The fast path stays stdlib-only. Full workflows require Python 3.15. Okta cache timestamps must be timezone-aware, cache replacement uses unique temporary files, failed Keychain writes raise, and device-flow slow_down responses increase the polling interval by five seconds. See RFC 8628 section 3.5: https://www.rfc-editor.org/rfc/rfc8628#section-3.5 .
Metadata
Release files for we-love-alfred 0.7.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| we_love_alfred-0.7.1.tar.gz | 24.9 kB | Without provenance | Details for we_love_alfred-0.7.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| we_love_alfred-0.7.1-py3-none-any.whl | Python 3 | none | any | Details for we_love_alfred-0.7.1-py3-none-any.whl |
Total release size: 57.1 kB
Release files / we_love_alfred-0.7.1.tar.gz
| Download URL | we_love_alfred-0.7.1.tar.gz |
|---|---|
| Size | 24.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fbc69361c2dcd3d575f86d48f6ecc2545141df3affb4f9ef84923a2dcf4f14e7
|
|
BLAKE2b-256 checksum How to use checksums |
185133f0260f8527669be8a0534992848e44f9cc7b6f111ac9099fea3cce9944
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / we_love_alfred-0.7.1-py3-none-any.whl
| Download URL | we_love_alfred-0.7.1-py3-none-any.whl |
|---|---|
| Size | 32.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f98ff894034f40d23c098800e1cccad4376430f1537e8325ec5f18e869ec8595
|
|
BLAKE2b-256 checksum How to use checksums |
8b201933f0e58b1b7778c2f96eb9166fb281d9f4fd4b58991736289d91ad1ab6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for we-love-alfred 0.7.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.