๐Ÿ“˜ Khy-OS ๆ–‡ๆกฃ็ซ™ ๐Ÿงญ ๆ–ฐๆ‰‹ๅ…ˆ่ฏป๏ผšๆ ธๅฟƒๆฆ‚ๅฟต

๐Ÿคฏ What is khy

<!--
README owner/repo slug note (maintainer):
Badges and clone URLs below use kodehu03/khy-os as the GitHub slug.
Confirm/replace with the real GitHub owner/repo before publishing.
-->

๐Ÿ–ผ๏ธ khy โ€” the AI-native operating system

khy

<b>The AI-native operating system.</b><br>
A hand-written OS kernel + a Claude-Code-class agentic CLI + a 16-backend AI gateway.<br>
One install, batteries included.
</p>

PyPI npm CI CodeQL
License Python Node Platforms Made with C / JS / Python / MoonBit

60-Second Tour ยท What is khy ยท Quickstart ยท The Three Pillars ยท Compare ยท ไธญๆ–‡


๐Ÿคฏ What is khy#

khy is a full AI-native operating system โ€” written almost entirely by one
person.
It spans every layer most projects only touch one of:

  • a hand-written OS kernel in C (preemptive scheduler, demand paging,

copy-on-write fork, POSIX-style signals, pipes, per-process fd tables, a
dual ELF + PE loader) that boots and runs under QEMU;

  • a Claude-Code-class agentic CLI โ€” streaming TUI, tool-calling loop,

permission gating, sub-agents, workflows, goal mode, context compaction;

  • a 16-backend AI gateway that fronts Claude, Qwen, Cursor, Kiro, Windsurf,

Warp, Trae, Ollama, Codex and more behind one API, with cascade failover and
circuit breaking โ€” no vendor lock-in;

  • shipped through two parallel package channels (pip install khy-os /

npm i -g @khy-os/khy-os) with a self-healing, multi-language dev environment.

It's the kind of project that usually takes a team and a few years. Here it's
one repo you can pip install in 30 seconds and run today.


โšก 60-Second Tour#

pip install khy-os        # or:  npm install -g @khy-os/khy-os
khy                       # launch the agentic terminal
โ”Œโ”€ khy โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ 18% ctx โ”€โ”
โ”‚ โ€บ refactor the gateway adapter cascade and add a test          โ”‚
โ”‚                                                                โ”‚
โ”‚ ๐Ÿ’ญ ๆ€่€ƒ ยท 142 ๅญ— (Ctrl+O ๅฑ•ๅผ€)                                 โ”‚
โ”‚ โ–ธ ่ฏปๅ– ยท ็ผ–่พ‘ ยท ๆ‰ง่กŒๅ‘ฝไปค ยท 4 ไธชๆญฅ้ชค  โœ“โœ“โœ“โœ“                       โ”‚
โ”‚   โœ“ ๅฎŒๆˆ                                                        โ”‚
โ”‚ โ น ็”Ÿๆˆไธญโ€ฆ ยท 12s ยท ~340 tok                                      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ฝ๏ธ Demo recording: drop an asciinema cast or GIF at assets/demo.gif
and it renders here. See docs/launch/DEMO.md for the
exact 45-second script that shows the kernel booting and the agent coding.


๐Ÿš€ Quickstart#

Install (pick one channel โ€” both ship the identical workshop)#

# pip channel
python3 -m pip install -U khy-os

# npm channel
npm install -g @khy-os/khy-os

Run#

khy                       # agentic terminal (the headline experience)
khy preflight             # diagnose PATH / Node / deps / claude before first run
khy ai "summarize this repo"      # one-shot AI, no REPL
khy gateway status        # see which of the 16 AI backends are live

Boot the actual OS#

khy iso build --output dist/khy-os.iso     # build a bootable ISO
# then attach dist/khy-os.iso in QEMU / VMware / VirtualBox

New here? Follow the 0-to-power-user ladder: ๆ–ฐๆ‰‹ๆˆ้•ฟ่ทฏ็บฟ (post-install checklist โ†’ configure AI โ†’ daily use โ†’ advanced โ†’ mastery).

Full guides: ๆ–‡ๆกฃ็ดขๅผ• ยท Windows + VMware: windows-vmware-ๆธ…ๅ•


๐Ÿงฑ The Three Pillars#

1. A real, hand-written kernel#

Not a wrapper around Linux โ€” a kernel built from boot sector up, validated under
QEMU at every phase:

CapabilityStatus
Preemptive scheduler + PS/2 keyboard + line-edited shellโœ… QEMU-tested
Demand paging ยท copy-on-write fork ยท fault isolationโœ… QEMU-tested
POSIX-style signals (sigaction/sigreturn) ยท pipes ยท per-process fd tablesโœ… QEMU-tested
Standard streams (fd 0โ€“2) ยท shell pipelines (`\`)
Dual binary loader: ELF + PEโœ… QEMU-tested

Hybrid micro/monolithic design โ€” performance paths in kernel space, I/O through
IPC. Roadmap: real keyboard stdin and block-device persistence.

2. A Claude-Code-class agent in your terminal#

  • Streaming Ink TUI with collapsible process groups, persisted thinking,

real context-fill meter, and a live token/stall indicator.

  • A full tool-calling loop with structured results, loop detection, and

max_tokens recovery โ€” benchmarked against Claude Code / Qwen Code / OpenCode.

  • Permission gating, AskUserQuestion, sub-agents, goal mode, and a

visual workflow editor with a native execution engine.

3. A 16-backend AI gateway#

One endpoint in front of every model you already pay for โ€” bring your own
keys, keep your data local
:

Claude ยท Qwen ยท Cursor ยท Kiro ยท Windsurf ยท Warp ยท Trae ยท Ollama ยท Codex ยท โ€ฆ

Cascade failover, circuit breakers, transient-error cooldown, and per-user
multi-tenant isolation. Falls back automatically when a channel goes down.


๐Ÿ—บ๏ธ Architecture#

            โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
            โ”‚  khy CLI  ยท  Ink TUI  ยท  agent loop  ยท  goals โ”‚   โ† what you touch
            โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ”‚
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ”‚   AI Gateway (16 adapters, failover)    โ”‚   โ† bring your own keys
        โ”‚   Claude ยท Qwen ยท Cursor ยท Ollama ยท โ€ฆ   โ”‚
        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ”‚
   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
   โ”‚  Node backend  ยท  tools  ยท  workflows  ยท  services  โ”‚   โ† runtime
   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ”‚
            โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
            โ”‚  khy kernel (C)  ยท  ELF/PE loader โ”‚   โ† the OS underneath
            โ”‚  scheduler ยท paging ยท IPC ยท fork  โ”‚
            โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

   Shipped as one workshop through two channels:  pip install khy-os  /  npm i -g @khy-os/khy-os

๐Ÿ†š How It Compares#

khyClaude CodeOllamaA Linux distro
Agentic coding CLIโœ…โœ…โŒโŒ
Multi-provider, no lock-inโœ… (16)โŒ (1)โœ… (local only)โ€”
Self-hostable / bring-your-own-keysโœ…โŒโœ…โ€”
Built-in AI gateway w/ failoverโœ…โŒโŒโŒ
Hand-written OS kernelโœ…โŒโŒโœ… (a team)
One-command installโœ…โœ…โœ…โŒ

khy isn't trying to beat any one of these โ€” it's the only project that is all
of them at once
, from the kernel to the agent.


๐Ÿ“ฆ What's in the box#

platform/    Python launcher + bundled runtime + shared JS    (pip entrypoint)
services/    Node backend: CLI, gateway, adapters, tools, workflows
apps/        Vue management UI + upper-layer apps
kernel/      The OS: boot, src, ELF/PE loader, MoonBit WASM, ISO build
software/    khyquant โ€” the default built-in app (quant trading)
docs/        ๆžถๆž„ (architecture) ยท ๆŒ‡ๅ— (guides) ยท ไฟฎๅค่ฎฐๅฝ• (changelogs)
packaging/   npm channel (@khy-os/khy-os) mirroring the pip workshop

๐Ÿ›ฃ๏ธ Roadmap#

  • [ ] Real keyboard stdin + block-device persistence in the kernel
  • [ ] Recorded boot-to-agent demo (assets/demo.gif)
  • [ ] More gateway adapters + adapter capability matrix in docs
  • [ ] Hosted playground

Changelog: CHANGELOG.md


โญ Star history#

Star History Chart


๐Ÿค Contributing & community#

  • Read CONTRIBUTING.md before opening a PR.
  • Be kind โ€” see CODE_OF_CONDUCT.md.
  • Found a vulnerability? See SECURITY.md (please don't open a public issue).

๐Ÿ“œ License#

Source-available. khy is free to download, run, study, and use
non-commercially
โ€” see LICENSE. Copying, modifying, or
redistributing the source, and commercial use, require written permission from
the author (ๅญ”ๆตฉๅŽŸ / Kong Haoyuan). For commercial licensing or collaboration,
reach out.


<b>If a one-person AI-native OS is the kind of thing you want to exist,</b><br>
โญ <b>star the repo</b> โ€” it's the cheapest way to tell the author to keep going.
</p>