Imported from hieple7985/hip-key (
AGENTS.md). Install upstream withnpx skills add hieple7985/hip-key. Copyright stays with the author.
AGENTS.md
Guidance for AI agents (and human contributors) working in the hip-key repository.
hip-key is a language-agnostic input method engine (IME) written in Rust, with the initial focus on Vietnamese (Telex/VNI). Local-first, low-latency, no mandatory cloud. Designed for longevity (10+ year horizon).
Repo Layout
hip-key/
├── core/ # hip-key-core — language-agnostic engine (NO language rules here)
│ └── src/
│ ├── engine.rs # Engine + EngineEvent (buffer state, keystroke routing)
│ ├── keystroke.rs # Keystroke, Key, Modifiers
│ ├── buffer.rs # Composition buffer (insert/backspace/delete)
│ ├── candidate.rs # Candidate, CandidateList
│ ├── langpack.rs # LanguagePack trait, ProcessResult, DynLanguagePack
│ ├── config.rs # Config (toggles for spell-check, agent, macros…)
│ ├── macro_expander.rs # Snippet/macro expansion (opt-in)
│ ├── learning.rs # LearningStore (frequency, accept/reject feedback)
│ ├── agent.rs # Intent detection + action automation (time/date/calc…)
│ └── spell.rs # SpellCorrector + Correction/ErrorType
├── lang/vi/ # hip-key-lang-vi — Vietnamese pack (Telex, VNI, dictionary, trie)
├── ffi/ # hip-key-ffi — C-compatible API (cdylib + staticlib) + hip-key.h
├── cli/ # hip-key-cli — `hip-key` testing harness
├── platform/macos/ # Xcode project (InputMethodKit/Swift) + build-ffi.sh
└── docs/ # architecture.md, principles.md, language-pack-guide.md
Workspace is declared in the root Cargo.toml (members: core, ffi, lang/vi, cli). Edition 2021, stable toolchain, MIT OR Apache-2.0.
Common Commands
cargo build # Build whole workspace
cargo test # All tests across workspace
cargo test -p hip-key-core # Core crate only
cargo test -p hip-key-lang-vi # Vietnamese pack only
cargo clippy --all-targets -- -D warnings # Lint (treat warnings as errors)
cargo bench -p hip-key-lang-vi # Benchmarks (criterion)
cargo run --bin hip-key # CLI harness (Telex)
cargo run --bin hip-key -- vni # CLI harness (VNI)
# macOS platform adapter (requires Xcode + XcodeGen)
bash platform/macos/build-ffi.sh # Builds FFI, stages artifacts into Frameworks/
Inviolable Principles (do NOT violate these)
These hold for the project's lifetime. See docs/principles.md for the full rationale.
- Core is language-agnostic. Never put Vietnamese (or any language) rules, dictionaries, or assumptions inside
core/. All language logic lives inlang/<code>/crates via theLanguagePacktrait. - Language packs are independent crates. No cross-pollination; core must not depend on a specific language pack.
- No forced auto-correction. Everything "smart" (spell-check, candidates, macros, agent actions) must be opt-in via
Configand respect user intent. Never silently "fix" user input. - Local-first, no mandatory cloud. Engine must work fully offline. Any network feature must be explicitly opt-in.
- Latency > intelligence. Keep the keystroke hot path allocation-free where possible. No blocking or network calls before the UI update. Profile, don't prematurely optimize.
When in doubt about a design choice, apply the decision framework in docs/principles.md.
Code Conventions
- Rust edition 2021, stable toolchain.
- No unnecessary comments — code is self-documenting; add comments only for non-obvious design intent (existing files use
//!module docs and a few inline//notes). - No external dependencies in
core/unless absolutely necessary; it currently has zero runtime deps. - Every public API has tests. Use
#[cfg(test)]modules for unit tests. - Match the existing module style: small focused files, trait-based extension points (
LanguagePack,AgentAction). - Prefer
&str/Cow<str>over ownedStringon hot paths.
Commit Messages
Format: type: description #issue (Conventional Commits style).
feat: add new feature #123
fix: resolve bug in buffer #124
docs: update contributor guide #125
refactor: simplify trie lookup #126
test: add edge case tests for VNI #127
Scopes are allowed when helpful (e.g. fix(macos): ..., feat(core): ...).
Workflow
- Fork → branch off
mainasfeat/...,fix/..., etc. - Make changes with tests.
cargo test+cargo clippy --all-targets -- -D warningsmust pass.- Ensure benchmarks do not regress (
cargo bench). - Open a Pull Request against
main.
Adding a Language Pack
See docs/language-pack-guide.md. Summary:
- Create
lang/<code>/withCargo.tomldepending onhip-key-core. - Implement the
LanguagePacktrait (process,generate_candidates,is_valid_composition,id,name). - Add input-method rules and dictionary data.
- Add tests + a criterion bench if relevant.
FFI / Platform Bridge Notes
ffi/exposes a C API (hip-key.h) compiled ascdylib+staticlib. When changing the public C surface, update bothffi/src/lib.rsandffi/hip-key.htogether.- The macOS adapter (
platform/macos/) is an Xcode project generated fromproject.yml(XcodeGen). It linkslibhip_key_ffi.astatically and bridges viaHipKeyBridge.h. Re-runbuild-ffi.shafter any FFI change before opening Xcode.
Things to Avoid
- Do not add Vietnamese-specific constants/maps/dictionaries in
core/. - Do not introduce runtime dependencies into
core/casually — discuss first. - Do not add comments that restate what the code obviously does.
- Do not commit
target/,.claude/,.DS_Store, or editor swap files (see.gitignore).
Issue & Pull Request Rules (mandatory)
Every issue and PR created by an agent MUST:
- Be assigned to
hieple7985(the repo owner). No unassigned issues or PRs. - Carry at least one label from the priority ladder:
p0— must have, blocks releasep1— should havep2— nice to have And at least one category label (e.g.,security,ffi,platform,documentation,enhancement,bug,config,ci).
- Use the existing label set. If a needed label does not exist, create it before opening the issue/PR.
Commands:
gh issue create --assignee hieple7985 --label "p0,security" --title "..." --body "..."
gh pr create --assignee hieple7985 --label "p0,ffi" --title "..." --body "..."
Never open an issue or PR without an assignee and at least one label.