Repository navigation
karabiner: port config to karabiner.ts generator - #40
Conversation
karabiner-config.ts is now the source of truth for the Default profile's complex_modifications. `npm run build` regenerates ~/.config/karabiner/karabiner.json; `npm run verify` proves the generator reproduces the live file byte-for-byte (same pipeline: canonical key order + prettier-plugin-karabiner, i.e. the Karabiner-Elements json_writer format). All 10 rules ported 1:1 — including the three disabled ones (control+tab, MS RDP, home-row mods) and their per-manipulator descriptions. Also folded in what had drifted from main: - Ctrl+Space EN/Chinese input-source rule (was uncommitted) - scripts/toggle-input-source.sh (was untracked) - the earpods + ctrl+space rules re-keyed to the GUI's canonical order (content unchanged), matching commit 519cf5c's approach Rule order note: live config has Vim 8/11 (nav) before Vim 1/11 (toggle); kept as-is since the toggle's any-key exit must not shadow nav keys. .pretierrc override narrowed from *.json to karabiner.json (so the generator's package.json uses normal prettier JSON formatting), and the generator project lives in generator/ — one level down from the karabiner config dir — so the pre-commit karabiner-format check (scoped to top-level *.json) never sees it.
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
|
Claude review: no issues found Read the full diff (generator, write/verify libs, package.json, .prettierrc, karabiner.json changes) and checked for bugs and CLAUDE.md compliance; I could not run the byte-for-byte verify against the live file. |
Two docs so any agent asked to "edit my Karabiner config" lands on the generator instead of hand-editing the JSON: - root AGENTS.md — repo guidance index; the Karabiner pointer fires on any request touching key remaps or ~/.config/karabiner/ - .config/karabiner/AGENTS.md — the actual workflow: edit generator/karabiner-config.ts, then build + verify (verify passing is the completion criterion), the byte-exactness link to the pre-commit hook, recovery for hand-edited JSON, and the load- bearing rule order (vim nav before toggle). Without these the obvious-but-wrong path is editing karabiner.json directly; npm run build would silently discard that work.
|
Claude review: no issues found Re-read the full diff; since the last approved review the only new commit adds the AGENTS.md docs, which match the generator code (build target, rule order, verify flow). I could not run the byte-for-byte verify against the live file. |
The merge of main into this branch kept both copies of the Ctrl+Space input-source rule — the generator's canonical-keyed one and main's hand-written one — leaving two semantically identical rules in karabiner.json. Karabiner matches the first, so behavior was unchanged, but npm run verify (and the build-must-reproduce-live invariant) caught the drift. Keep the canonical-ordered copy; dedupe restores verify to byte-identical.
|
Claude review: no issues found Re-read the full diff; the new commit (drop duplicate Ctrl+Space rule from merge) leaves a single Ctrl+Space rule in both the generator and karabiner.json. I could not run the byte-for-byte verify against the live file. |
The generator-setup docs lived in two AGENTS.md files (repo root + .config/karabiner/). Root AGENTS.md is machine-global context loaded by every session under $HOME — too broad a place for one tool's workflow — and a subdirectory AGENTS.md is only auto-loaded when a session starts inside that directory, so an agent started elsewhere (and given a file path) could still miss it. A model-invoked skill fires on any karabiner mention from anywhere: one always-loaded description line instead of two always-loaded docs, and the full workflow loads only when the skill triggers. . agents/skills/karabiner/SKILL.md carries the workflow: edit generator/karabiner-config.ts, build, verify (verify passing is the completion criterion), the hand-edited-JSON recovery path, and the load-bearing gotchas (rule order, disabled rules, $HOME write target, device IDs).
|
Claude review: no issues found Re-read the full diff; since the last approved review the only new commit replaces AGENTS.md with |
What
Ports the Karabiner-Elements config to the karabiner.ts generator.
generator/karabiner-config.tsis now the source of truth for the Default profile'scomplex_modifications; the hand-maintained JSON is build output.How it works
npm run build(from.config/karabiner/generator/) regenerates~/.config/karabiner/karabiner.jsonnpm run verifyproves the generator reproduces the live file byte-for-byte — same pipeline as the repo's existing format tooling: canonical key order +prettier-plugin-karabiner(Karabiner'sjson_writerformat). The pre-commit hook already enforces that format, so the two stay in lockstep.Ported 1:1
All 10 rules, including:
enabled: false/titlepreservedg_pressedcondition ordering, and the vim 8/11-before-1/11 rule order (the toggle rule's any-key exit must not shadow nav keys)left_commandetc.) kept explicit, matching liveAlso folds in drift that hadn't reached main
scripts/toggle-input-source.sh— was untrackedNotes
karabiner.jsonwas rewritten once with the canonicalized key order; Karabiner-Elements reloaded it cleanly (verified inconsole_user_server.log).generator/(one level down) so the pre-commit karabiner-format check — scoped to top-level*.json— never sees itspackage.json..prettierrc's override narrowed tokarabiner.jsonaccordingly.npm run verifycurrently passes: generator output is byte-identical to the live file.