Skip to content

karabiner: port config to karabiner.ts generator - #40

Merged
Jish2 merged 6 commits into
mainfrom
feat/karabiner-generator
Oct 8, 2026
Merged

Jish2 merged 6 commits into
mainfrom
feat/karabiner-generator

Conversation

@Jish2

@Jish2 Jish2 commented Oct 7, 2026

Copy link
Copy Markdown
Owner

What

Ports the Karabiner-Elements config to the karabiner.ts generator. generator/karabiner-config.ts is now the source of truth for the Default profile's complex_modifications; the hand-maintained JSON is build output.

How it works

  • npm run build (from .config/karabiner/generator/) regenerates ~/.config/karabiner/karabiner.json
  • npm run verify proves 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's json_writer format). The pre-commit hook already enforces that format, so the two stay in lockstep.

Ported 1:1

All 10 rules, including:

  • the three disabled ones (control+tab, MS RDP, home-row mods) with enabled: false/title preserved
  • per-manipulator descriptions, the g_pressed condition ordering, and the vim 8/11-before-1/11 rule order (the toggle rule's any-key exit must not shadow nav keys)
  • left-sided modifier variants (left_command etc.) kept explicit, matching live

Also folds in drift that hadn't reached main

  • Ctrl+Space EN/Chinese input-source rule — was uncommitted in the live config
  • scripts/toggle-input-source.sh — was untracked
  • earpods + ctrl+space rules re-keyed to the GUI's canonical key order (content unchanged; same approach as commit 519cf5c)

Notes

  • The live karabiner.json was rewritten once with the canonicalized key order; Karabiner-Elements reloaded it cleanly (verified in console_user_server.log).
  • Generator project lives in generator/ (one level down) so the pre-commit karabiner-format check — scoped to top-level *.json — never sees its package.json. .prettierrc's override narrowed to karabiner.json accordingly.
  • npm run verify currently passes: generator output is byte-identical to the live file.

Jish2 added 2 commits October 6, 2026 18:43
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.
@claude

claude Bot commented Oct 7, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@claude

claude Bot commented Oct 7, 2026

Copy link
Copy Markdown

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.
Approved: no open findings, nothing under .github/ or install.sh is touched.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generator port is coherent, no bugs found, and it touches no protected paths.

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

claude Bot commented Oct 8, 2026

Copy link
Copy Markdown

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.
Approved: no open findings, nothing under .github/ or install.sh is touched.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generator port plus accurate docs; no bugs found and no protected paths touched.

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 claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generator port and docs are coherent; the latest commit's duplicate Ctrl+Space rule removal leaves one rule in both generator and JSON.

@claude

claude Bot commented Oct 8, 2026

Copy link
Copy Markdown

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.
Approved: no open findings, nothing under .github/ or install.sh is touched.

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

claude Bot commented Oct 8, 2026

Copy link
Copy Markdown

Claude review: no issues found

Re-read the full diff; since the last approved review the only new commit replaces AGENTS.md with .agents/skills/karabiner/SKILL.md, whose workflow and gotchas match the generator code. I could not run the byte-for-byte verify against the live file.
Approved: no open findings, nothing under .github/ or install.sh.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only change since last approval is docs (AGENTS.md replaced by a karabiner skill) that match the generator; no open findings.

@Jish2
Jish2 merged commit 495c15b into main Oct 8, 2026
1 check passed
@Jish2
Jish2 deleted the feat/karabiner-generator branch October 8, 2026 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant