mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-27 07:58:01 +01:00
15 KiB
15 KiB
Hex Agent Guide
Workflow
devis canonical and ships the Rune desktop UI on macOS, Windows, and Linux (GPUI is gone; there is nomain).devandproductionaccept changes only through pull requests..github/,CODEOWNERS,src/updater*,app/update-requirement.txt,*.entitlements, and release/signing scripts require Dax (@thdxr).- Branch from
dev, open a PR todev, and merge once it compiles locally without waiting on CI (compile.ymlrunscargo clippy --locked --bin hex -- -D warningson PRs; full test suites run in Release'scheck/stablechannels and manualcheck-<os>.ymldispatches). - Publish app releases from
dev(release.yml). Fast-forwardproductionfromdevonly to deploy the production site (deploy.yml); never commit directly toproduction. - Any change to what the window draws must update goldens in the same PR: run
HEX_UPDATE_GOLDENS=1 cargo test --locked --bin hex rune_uion Linux (from macOS, dispatchcheck-linux.ymlon the branch and take itsgolden-actualartifact), inspect every changed image, and commit them with the change. - At the start of a work round, bump Hex's Rune pin (
rune,rune-kit,rune-theme-opencode,rune-motioninCargo.tomlandCargo.lock) toanomalyco/runedevhead, adapt to itsCHANGELOG.md, updatecargoGitDependencies."rune-0.0.1"(rev and output hash) innix/package.nix, keepwindowsat0.62.2forgpu-allocatorinCargo.lock, and runscripts/check rune_ui. Report Rune bugs upstream rather than working around them. Never runcargo publish(neither Hex nor Rune is published to crates.io).
Product & Surface Rules
Hex is a local, observable native-Rust voice appliance (anomaly.hex) for macOS with
explicit Linux (X11 and compatible Wayland) and Windows (x64 and ARM64) beta contracts. Keep
consequential behavior explicit and modules deep. User settings persist in <Application Support>/hex/settings.json; deterministic personal transcript transformations live in
~/.config/hex/hex.config.ts (embedded QuickJS; public contract at
site/public/docs/transforms.md).
- Labs gate (
src/labs/feature.rs,docs/features/labs.md): Every build shows General, Output, History, Labs, and Annotate (on by default in every build viacapture.enabled). New, unproven, user-requested, and externally contributed features land in Labs, off by default — never add a master switch or ship them on by default. Eachlabs::Featuredeclares its settings key, group, OSes, and audience (EveryoneorDev; stable builds never list, accept, or runDevlabs). Gate where the feature's work starts (worker, thread, capture), not only its UI. Adding or changing a lab requiresHEX_UPDATE_LABS_JSON=1 scripts/check labs::web(updatessite/src/labs.jsonfor/hex/labs/<id>) andscripts/check labs control::settings. - Feature map (
docs/features/README.md): Read the index and relevant capability maps (dictation.md,capture.md,meetings.md,labs.md,own-models.md,vocabulary.md,control-cli.md,transcript-cli.md,accessibility.md,recovery.md) before designing, changing, debugging, or reviewing user-facing behavior, then verify against the source. Update affected maps in the same PR when behavior, defaults, prerequisites, OS availability, recovery, or verification coverage changes; distinguish implemented behavior, automated checks, and physical-device proof limits. Keep future work inROADMAP.md. - Desktop UI (
docs/design-system.md): Read before touching any pane, capsule, or picker. Composerune-kitcomponents and Hex pieces (src/rune_ui/controls.rs,src/rune_ui/lists.rs) usingrune-theme-opencodetokens — never color literals or off-scale spacing. Keep shared UI in pane modules and OS behavior insrc/rune_ui/{macos,windows,linux}_host.rs.platform::Capabilitiesgates per-OS panes/rows and every OS difference must name a reason inplatform::DIFFERENCES(parity_tests). Use sentence case, "Hex" in copy,desktop::i18n(tr/tr_fill/tr_named— tests fail if any language is missing), AccessKit names on every control (accessibility_tests), and at most one accent Primary button per screen.
Repo Layout
src/audio/,src/dictation/,src/suppression/,src/recognition/,src/keyboard*.rs,src/paste/,src/continuation.rs,src/feedback/: authoritative microphone timeline, bounded stream recovery, pre-roll/release-tail capture, chord state machine, foreground context/mode processing, tones, and clipboard-restoring paste (docs/features/dictation.md,docs/features/recovery.md).src/transcription/,src/parakeet/,src/apple_speech.*: single-threadTranscriptionEngineowning the warm model, speculative GPU streaming with whole-clip fallback, catalog/custom/HuggingFace-found GGUF models, preparation worker, Silero VAD, and/transcriptions+/streams(docs/streams.md,docs/features/own-models.md).src/meeting/,src/calendar*,src/microphone_activity/,src/apple_intelligence.*: dual-track meeting capture, rolling pause-cut Parakeet transcription yielding to dictation, sample-timeline echo suppression, chapters/notes, retention, and read-onlymeeting::query+hex mcp(docs/features/meetings.md).src/capture_host/,crates/capture/,crates/capture-core/,crates/router/: Annotate screen/window/area/iPhone capture (cfg(hex_capture),scrawl-captureexcluded from the Cargo workspace),.hexannotationpackages, dictation-timeline audio sink, and in-process OpenCode session routing (docs/hex-annotation.md,docs/features/capture.md).src/rune_ui/,src/rune_hud/,src/macos_rune/,src/windows/,src/linux/,src/desktop/: shared Rune window/onboarding/capsules, click-through GPU Dot-scope HUD (src/rune_hud.wgsl), and single-instance menu-bar/tray/daemon hosts (docs/linux.md,docs/windows.md,docs/nix.md).src/app_settings/,src/app_paths.rs,src/control/,src/local_api/,src/personal_commands/,src/net/,src/updater/,src/policy.rs: resilientsettings.json, data-root paths, bearer-authenticated loopback API +hexCLI (docs/cli.md,docs/transcript-cli.md), QuickJS user transforms, native TLS/proxy HTTP (docs/downloads.md), release-service updater (docs/plans/release-service.md), and macOS managed-preference locks (site/public/docs/admin.md).sdk/typescript/(@kitlangton/hex,docs/specs/local-transcription-service.md),site/(Cloudflare Worker foranoma.ly/hexand/hex/changelog),perf/(strobe benches,docs/perf.md),ios/andandroid/(Hex Mobile; shared.hexwordscontract indocs/specs/hex-words.md).
Cross-Cutting Invariants
- Code shape (
scripts/code-shape.py): Keep source files under 800 non-test lines (1,500 hard cap; inline#[cfg(test)]excluded; test files warn over 1,000), folders under 40 non-test source files (60 hard cap), and prefix families (x.rs/x/+ 2x_*.rs, or 3x_*.rs) insidex/. Ceilings inscripts/*-exceptions.txtonly ratchet down (python3 scripts/code-shape.py --update-exceptions). - Startup & platform guards: GUI startup must call
keyboard::initialize_layouton the OS main thread before settings, keyboard-using workers, or Rune start (rune::prewarm_gpu()runs on macOS app launches only, never CLI commands). macOSmainsetsGGML_METAL_TENSOR_DISABLEfirst (avoids M5 Metal tensor-API kernel bugs) and exits throughdesktop/process_exit(drains workers under a 5 s deadline, then calls_exitso C++/Metal static destructors never race live threads). LinuxmainsetsDISABLE_RTKITbefore any ALSA/PipeWire stream opens. - Real-time capture & single model owner: Audio capture is lossless against UI, context,
inference, and paste stalls; queues stay bounded and accepted dictation jobs finish in
submission order without cancelling or blocking new captures. One
TranscriptionEnginethread owns the loaded dictation model; meeting chunks, Annotate word chunks, and/streamsyield to dictation and never load a second copy of the dictation model. WidenGGML_VULKAN_SHADER_TYPESin.cargo/config.tomlbefore adding a catalog model whose weights use tensor types beyondf32,f16,q8_0,q5_0. Cohere chunks stay capped at 35 s. - Settings resilience & CLI parity (
src/app_settings/persistence.rs): Settings errors never prevent launch. Invalid fields default in memory and back up the exact original tosettings.json.unreadable-<sha256>(owner-only) before any save; non-object or invalid-JSON files refuse every save until restart. Keep saved JSON backward-compatible (omit unchosenmeetings.retention; never omit optional fields likepaste_last_hotkeywhose absence restores a nonempty default; preserve missing custom-model selections while falling back at runtime). Every persisted setting requires ahex settingskey (every_persisted_setting_has_a_cli_key), and breaking/controlor transcript CLI JSON changes must bumpCONTROL_VERSION/ schema versions (docs/cli.md,docs/transcript-cli.md). Read-only CLIs (hex history,hex meetings list|show|chapters|search,hex mcp) and/controlcallers dispatch before process logging, instance locks, GUI, or permissions, and never launch Hex (onlyhex startandhex restartlaunch it). - Paths, network, OpenCode, and subprocesses: Derive user/data/document directories
through
app_paths(andscrawl_router::user_dirsin Annotate crates), neverdirsdirectly (on Windowsdirsignores redirectedUSERPROFILE/APPDATA/LOCALAPPDATAin tests and benchmarks). Make all outbound HTTPS requests throughsrc/net(OS TLS, system proxy, resumable ranged downloads), never by shelling out tocurl. Construct child processes throughdesktop::background_process(suppresses console flashes on Windows). Never start, probe, or search for an OpenCode binary; connect only to an already running service registered inopencode/service*.jsonviadesktop/opencode_service(docs/opencode-compatibility.md). Userhex.config.tsscripts reachfetchornode:child_processonly after exact content-hash approval (personal_commands/trust). - Privacy & data liability: Never persist captured audio by default
(
HEX_RETAIN_DICTATION_AUDIOand Labs › Keep recordings are explicit owner-only opt-ins). Event logs (live.ndjson,process.log, owner-only and trimmed in place under 10 MB) never record dictated text, full URLs, window titles, or transform payloads —History(7-day default retention, 10k entries / 16 MiB hard caps) is the only dictation text store. Meeting expiry andhex meetings deletemove folders to the Trash (neverrm; expiry never touches exported Markdown). Hugging Face cache scans (found_models) happen on demand, header-only and read-only. Keep private hostnames, devices, paths, accounts, and internal model names out of commits, PRs, fixtures, and screenshots. - Wayland & Linux boundaries (
docs/linux.md): Keep one general Wayland path (portals +wl-copy+wtype/RemoteDesktop; no compositor-specific code, raw input devices, oruinput, and XWayland only for the input-free HUD or explicitgnome-*Labs while XWayland already runs). Bind all GlobalShortcuts in one session with oneBindShortcutscall (KDE wipes shortcuts on a second session) and never bind Escape on the portal. - Release & updater security boundary (
docs/releasing.md,docs/windows-signing.md,docs/test-builds.md): Build jobs run repository code with zero secrets or OIDC tokens; sign/publish/deploy jobs (release,dev,productionenvironments) sparse-checkout only.github/release/, pin every action by SHA, verifySHA256SUMSdigests, and treat build artifacts strictly as data. Never overwrite published artifacts with different bytes, never escalate privileges in updaters, and never deletedocs/releases/*.md(they generate/hex/changelogand gate stable releases). Onboarding gates every stable release (scripts/check-onboarding.sh).
Development & Verification
./scripts/setup.sh && ./scripts/setup-parakeet.sh
scripts/check # fmt, clippy, code-shape, and cargo-nextest (read full output)
scripts/check meeting::query # fmt, then matching nextest cases only
scripts/check labs control::settings # required before merging any lab or persisted setting
HEX_UPDATE_LABS_JSON=1 scripts/check labs::web # regenerate site/src/labs.json after lab changes
cargo run -- status --json # query running Hex over /control (docs/cli.md)
cargo run -- app -- --list-scenes
cargo run -- app -- --snap /tmp/hex-settings.png --scene mac-settings --theme dark
./scripts/test-app-identity.sh # macOS bundle identity check
./scripts/test-install-linux-release.sh # Linux installer + signature check (x86_64/aarch64)
- Tests & headless UI: Always run
scripts/check [filter]rather than rawcargo test(.config/nextest.tomlbounds hung tests).--snaprenders fixtureSCENESinsrc/rune_ui.rswithout starting the runtime or touching user data (on GPU-less Linux, setVK_ICD_FILENAMES=/usr/share/vulkan/icd.d/lvp_icd.json). Never play live audio or wake displays during automated tests;HEX_AUDIO_FIXTURE=<wav>feeds real-time fixture audio without opening a microphone. Usetermctrlto checkhex dev dashboardTUI changes. - Benchmarks (
docs/perf.md):strobe.jsonandperf/*.bench.tsdrive release builds through AccessKit element keys (keep benchmarked keys stable;docs/features/accessibility.md) using isolatedHEX_APPLICATION_SUPPORT_DIR,HEX_DISABLE_UPDATES=1, and redirectedHOME/USERPROFILE. Add a benchmark case alongside performance changes. - TypeScript SDK (
sdk/typescript,@kitlangton/hex): User-facing SDK changes require a Changeset undersdk/.changeset/. Fromsdk/, runbun install --frozen-lockfile, then insdk/typescript/runbun run check && bun run test && bun run build && npm pack --dry-run. Releases publish via Changesets and.github/workflows/release-typescript.yml(--latest=false), never directnpm publish.
Diagnostics
- macOS:
~/Library/Application Support/hex/(logs/live.ndjson,logs/process.log,meetings/,annotations/) - Windows:
%APPDATA%\hexfor settings/install state;%LOCALAPPDATA%\hexfor machine-local logs, models, and annotations - Linux:
~/.local/share/hex(or$XDG_DATA_HOME/hex)