
Luoke IME handles the keys, the candidate window and committing text; an engine decides which candidates to offer. One folder with two files is an engine.
{
"protocol": 1,
"name": "Minimal example",
"kind": "typing",
"run": ["luoke-python", "engine.py"],
"input_keys": "abcdefghijklmnopqrstuvwxyz"
}import json, sys
TABLE = {"ni": ["你", "呢"], "hao": ["好", "号"], "nihao": ["你好"]}
for line in sys.stdin:
msg = json.loads(line)
if msg.get("type") != "query":
continue
keys = msg["input"]
cands = [{"text": t, "consume": n}
for n in range(len(keys), 0, -1) for t in TABLE.get(keys[:n], [])]
print(json.dumps({"type": "answer", "id": msg["id"],
"candidates": cands}, ensure_ascii=False), flush=True)Put it in ~/.luoke/ime/engines/ and pick it from the input method menu. Edit a file, and your next keystroke uses the new version.
Any double-pinyin layout, shape-based input, or a shorthand you invented yourself.
Kana, kaomoji, math symbols: each can be its own engine.
A company glossary, or the names you type all the time.
Third-party engines can’t reach the internet or use the GPU. Installing one doesn’t turn it on; you have to confirm.
It can write only to its own directory. It can’t read your keychain, passwords, browser or email, nor Luoke Memory or the IME’s settings.
To rank candidates by context or continue a sentence, ask Luoke (luoke-core) instead of installing a model of its own.
If your engine works well, we’d love to get it to more people.