Skip to content
vifast-ossPublic

About

Bộ gõ tiếng Việt Telex / Simple Telex / VNI / VIQR — lõi Rust nhỏ, chạy local, có C ABI, WASM, API Python và demo UEFI.

Topics

Resources

Contributing

Stars

5 stars

Watchers

0 watching

Forks

Latest commit

 

History

178 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ViFastKey · Bộ gõ tiếng Việt

ViFastKey

Bộ gõ tiếng Việt gọn, thuần logic: chuỗi phím thô → chữ tiếng Việt (Telex, Simple Telex, VNI, VIQR), kèm tầng engine cho IME (preedit/replace, macro, gõ tiếng Anh bằng escape Telex, hồ sơ ứng dụng).

Tính năng nổi bật: allow_coda_k (Đắk Lắk), macro_digits (mp3, k8s), macro nhiều từ, macro undo một phím, đ viết tắt (vcdd), 16 bảng mã (TCVN3, VNI-Windows, VISCII, VIQR, CP1258, NCR... cùng Unicode), app profile ghi đè kiểu gõ/kiểu dấu, preedit sửa từ đã gõ, macro nhiều từ, gợi ý từ/emoji local, FFI C/Python/WASM, macOS IMK universal2, Windows hook-only portable, Linux IBus/Fcitx5 và Wayland standalone (zwp_input_method_v2), Android IME, iOS keyboard extension, playground Preedit + macro + bảng mã, UI cấu hình desktop egui (Windows/Linux) có tray, import preview diff và chụp ảnh giao diện bằng --screenshots.

Đợt phát triển này dựa trên phân tích 21 dự án IME tiếng Việt công khai; xem docs/IME_FEATURE_RESEARCH.md.

Repository gồm hai bản:

Thư mục Vai trò
python/ Bản chính, chạy được. Là đặc tả tham chiếu (oracle) cho toàn bộ hành vi. Chỉ dùng thư viện chuẩn.
rust/ Bản port sang Rust. Đạt khi vượt qua 100% bộ conformance/*.jsonl sinh từ bản Python.

Cấu trúc

ViFastKey/
├── python/                     # bản tham chiếu
│   ├── vi_syllable/            # tách âm tiết, chính tả 3 trạng thái, đặt thanh
│   ├── vfk_core/               # rules + transform (hàm thuần)
│   ├── vfk_engine/             # ImeSession, ports, Config
│   ├── vfk_ffi/                # API phẳng kiểu FFI
│   ├── adapters/               # port mẫu, từ điển, ô nhập giả lập
│   ├── apps/                   # CLI demo + REPL + vfk-charset + vfk-suggest + vfk-emoji
│   ├── vfk_suggest/            # gợi ý từ local
│   ├── tests/                  # 623 test, golden, corpus
│   ├── tools/                  # export conformance, bench
│   ├── conformance/            # core.jsonl + engine.jsonl (oracle cho Rust)
│   ├── vfk_core/data/          # bảng mã legacy (bamboo-core MIT)
│   ├── README.md               # đặc tả hành vi chi tiết
│   ├── PORTING.md
│   └── EDGE_CASES.md
├── rust/                       # bản port
│   ├── crates/
│   │   ├── vi-syllable/
│   │   ├── vfk-core/           # transform + charset
│   │   ├── vfk-engine/
│   │   ├── vfk-config/         # đọc/merge/validate/atomic save config cho UI
│   │   ├── vfk-adapter-core/   # field policy, surrounding guard, action plan, timing
│   │   ├── vfk-ffi/            # C ABI + include/vifastkey.h
│   │   └── vfk-wasm/           # wasm-bindgen cho web demo
│   ├── apps/vfk-cli/           # CLI demo + REPL
│   ├── apps/vfk-charset/       # chuyển bảng mã
│   ├── apps/vfk-suggest/       # gợi ý từ
│   ├── apps/vfk-settings/      # UI cấu hình desktop (egui, Windows/Linux)
│   ├── apps/vfk-settings/src/hook.rs # Windows hook trong cùng binary Settings
│   ├── apps/vfk-wayland/       # adapter Wayland standalone (zwp_input_method_v2)
│   ├── apps/vfk-windows-replace/ # legacy adapter hook (không đóng gói)
├── windows/
│   ├── tsf/                    # TSF legacy/reference, không build/đóng gói mặc định
│   ├── installer/              # cài hook-only một binary
│   └── README.md               # tổng quan component Windows
├── linux/
│   ├── ibus/                   # adapter IBus (engine Python)
│   ├── fcitx5/                 # adapter Fcitx5 (C++ + C ABI)
│   └── wayland/                # adapter Wayland standalone (Rust + protocol)
├── android/                    # IME Android (Java + JNI/Rust)
├── ios/                        # host app + keyboard extension (Swift + C ABI)
├── chrome-extension/           # tiện ích web (MV3 + WASM)
│   ├── crates/vfk-suggest/     # lexicon gợi ý
│   ├── conformance/            # bản sao dữ liệu oracle
│   ├── testdata/               # golden + corpus
│   ├── tools/sync_conformance.sh
│   └── README.md
├── docs/                       # nghiên cứu, hợp đồng, adapter, config
├── macos/                      # adapter IMK thật (Swift + C ABI)
├── web/                        # landing page + playground
├── design/                     # token thiết kế
└── resources/                  # brand + font

Ngoài hai bản engine, repo còn có:

  • web/ — landing page + playground gõ thử chạy WASM trong trình duyệt.
  • uefi/ — demo app UEFI x86_64 (Telex/VNI, GOP + font nhúng); xem uefi/README.md, test bằng make uefi-test.
  • resources/brand/ — logo, favicon, OG; resources/fonts/ — Be Vietnam Pro (OFL).
  • design/tokens.json — màu/font/spacing dùng chung cho desktop, web, extension, mobile.

Hai bản tự chứa dữ liệu conformance/, tests/golden/, tests/data/ để chạy test độc lập. Khi sửa hành vi, sửa bản Python trước rồi đồng bộ sang Rust bằng rust/tools/sync_conformance.sh.

Chạy bản Python

Yêu cầu Python 3.10+. Có thể cài như package (kèm pytest/ruff):

cd python
pip install -e ".[dev]"
python -m pytest -q               # 623 test
python -m tools.export_conformance
python -m tools.bench
python -m apps.vfk_cli --demo
python -m apps.vfk_cli            # REPL tương tác
python -m apps.vfk_cli --text "Tieengs Vieejt"
python -m apps.vfk_cli --method vni --tone new --text "Vie65t Nam"
python -m apps.vfk_charset --to tcvn3 --text "Tiếng Việt"
python -m apps.vfk_charset --from tcvn3 --file vi.tcvn --to unicode
python -m apps.vfk_charset --clipboard --to tcvn3
python -m apps.vfk_suggest nguoi
python -m apps.vfk_emoji "cười"
# Android IME
./android/build.sh
adb install -r android/app/build/outputs/apk/debug/app-debug.apk

# Chrome extension (MV3)
./chrome-extension/build.sh
# Load unpacked: chrome://extensions -> developer mode -> chrome-extension/dist

Build bản Rust

Yêu cầu Rust stable (MSRV 1.89, đã kiểm tra 1.99.1); rust/rust-toolchain.toml ghim stable + wasm target.

cd rust
cargo build --workspace
cargo test --workspace
cargo run -p vfk-cli -- --demo
cargo run -p vfk-cli
cargo run -p vfk-cli -- --method vni --tone new --text "Vie65t Nam"
cargo run -p vfk-charset -- --to tcvn3 --text "Tiếng Việt"
cargo run -p vfk-suggest-cli -- nguoi
cargo run -p vifastkey-settings        # UI cấu hình desktop (Windows/Linux)
cargo run -p vifastkey-settings -- --check --config /tmp/config.json
cargo run -p vifastkey-settings -- --screenshots /tmp/vfk-shots

macOS input method

Adapter IMK thật, gọi engine Rust qua C ABI:

./macos/build.sh          # build app + self-test
./macos/install.sh        # cài vào ~/Library/Input Methods
./macos/doctor.sh         # chẩn đoán permission/input source
./macos/package.sh        # đóng gói universal2 (arm64 + x86_64)
./linux/ibus/install.sh   # cài IBus engine trên Linux
# Release: tag v* -> .github/workflows/release.yml (CLI/WASM/header/lib)
# Web:     .github/workflows/pages.yml (GitHub Pages)

Chi tiết cài, menu, config và giới hạn: macos/README.md. Adapter dùng preedit, app profile, menu Telex/VNI, macro undo; chưa ký Developer ID/notarize nên bản phát hành cần bổ sung.

Web demo

Bản đang chạy: https://key.vifast.org/

Playground gõ thử chạy engine Rust qua WASM, không cần server API:

rustup target add wasm32-unknown-unknown
cargo install wasm-bindgen-cli --version 0.2.130
./web/build.sh
python3 -m http.server 8080 -d web
# mở http://127.0.0.1:8080/

Playground mô phỏng cả REPLACE và PREEDIT, có macro, NFC/NFD và các tuỳ chọn mới. Trang production còn có API Python (/api/type, /api/charset) chạy engine oracle, thống kê ẩn danh và góp ý; xem deploy/vifastkey_web/README.md.

# chạy đầy đủ landing page + API Python
python3 -m venv /private/tmp/vifastkey-venv
/private/tmp/vifastkey-venv/bin/pip install -r deploy/vifastkey_web/requirements.txt
PYTHONPATH=python STATIC_DIR=web \
  /private/tmp/vifastkey-venv/bin/uvicorn app:app \
  --app-dir deploy/vifastkey_web --reload --port 8091

Chi tiết hành vi, giới hạn và cách deploy tĩnh: web/README.md.

Kiểm tra nhanh

make test     # pytest + cargo test
make check    # thêm ruff, rustfmt, clippy, kiểm tra conformance không lệch
make web      # dựng lại WASM + asset

Đồng bộ hai bản

cd rust
PYTHON=python3 tools/sync_conformance.sh ../python
cargo test --workspace

Tải và cài đặt

Bản Windows hiện tại là hook-only một binary, không cần ký: vifastkey-windows-hook-0.1.2.zip trên https://key.vifast.org/#tai-ve. Hướng dẫn mọi nền tảng: docs/INSTALL.md.

Tài liệu

  • python/README.md — đặc tả hành vi, mô hình tính toán, danh sách bất biến.
  • python/PORTING.md — hướng dẫn port và mô tả bộ conformance.
  • python/EDGE_CASES.md — tổng hợp edge case từ các dự án IME khác.
  • rust/README.md — kiến trúc crate, khác biệt có chủ đích, C ABI.
  • docs/IME_FEATURE_RESEARCH.md — tổng hợp 21 dự án IME, ma trận tính năng, quyết định.
  • docs/ime-survey/ — khảo sát 31 IME (snapshot 2026-11-01), sổ tay kỹ thuật Areca và so sánh với ViFastKey.
  • docs/research/ — 8 báo cáo phân tích chi tiết (+ ViFastTts, Areca IME).
  • docs/research/08-areca-ime.md — bài học adapter Fcitx5 từ Areca: queue/barrier, backend, trust probe, timing/ACK, app compatibility.
  • docs/VIFASTTTS_LESSONS.md — bài học kỹ thuật từ ViFastTts cho adapter macOS.
  • docs/COMPATIBILITY.md — hợp đồng hành vi (tone, undo, đ, VNI số, charset, Action).
  • docs/ARCHITECTURE.md — ranh giới engine/adapter-core/platform và quy ước chống lặp logic.
  • docs/ADAPTER_GUIDE.md — hợp đồng viết adapter macOS/Windows/Linux, dùng vfk-adapter-core/vfk_plan_action_with_fallback.
  • adapter-conformance/ — scenario JSON dùng chung cho mọi port (surrounding, selection, emoji/NFD, pass-key, fail-safe).
  • docs/CONFIG.md — toàn bộ trường config và app profile.
  • docs/DESKTOP_UI.md — UI cấu hình desktop (egui), hợp đồng ghi config và tích hợp adapter.
  • docs/IME_TEST_VECTORS.md — bộ ví dụ hành vi dùng để port/regression.
  • macos/README.md — build/cài/test adapter macOS IMK.
  • docs/INSTALL.md — cài đặt Windows hook-only, macOS, Linux, Android, iOS, extension, WASM.
  • windows/tsf/README.md — TSF legacy/reference; không đóng gói mặc định.
  • docs/PLATFORMS.md — trạng thái adapter từng nền tảng và hợp đồng tối thiểu.
  • packaging/ — script đóng gói Windows/Linux và README cài đặt/giới thiệu tính năng cho người dùng.
  • THIRD_PARTY_NOTICES.md — ghi công bảng mã bamboo-core MIT.
  • CONTRIBUTING.md — quy trình sửa hành vi, chạy test, đồng bộ conformance.
  • CHANGELOG.md — thay đổi theo phiên bản.
  • ROADMAP.md — việc còn lại: test tương tác tray/toast Windows, game/anti-cheat, Wayland desktop/app thật, ký/notarize...

Giấy phép

Mã nguồn phát hành theo giấy phép kép MIT HOẶC Apache-2.0 — người dùng chọn một trong hai:

  • LICENSE-MIT — bản ngắn gọn, tương thích GPLv2.
  • LICENSE-APACHE — có điều khoản cấp phép bằng sáng chế (§3).

Biểu thức SPDX: MIT OR Apache-2.0. Logo, wordmark và tài nguyên thương hiệu không thuộc phạm vi hai giấy phép trên — xem TRADEMARKS.md. Bảng mã lấy từ bamboo-core, font Be Vietnam Pro và các dependency vẫn giữ giấy phép gốc — xem THIRD_PARTY_NOTICES.md.

About

Bộ gõ tiếng Việt Telex / Simple Telex / VNI / VIQR — lõi Rust nhỏ, chạy local, có C ABI, WASM, API Python và demo UEFI.

Topics

Resources

Contributing

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages