Metadata-Version: 2.4
Name: khy-os
Version: 0.1.94
Summary: Khy OS — AI platform operating system with an extensible default app runtime
Author-email: khy-qqb <2578974124@qq.com>
License: MIT
Project-URL: Homepage, https://khyquant.top
Project-URL: Documentation, https://khyquant.top/docs
Project-URL: Repository, https://github.com/khyquant/khy-quant
Project-URL: Issues, https://github.com/khyquant/khy-quant/issues
Keywords: khy,ai-os,agent-os,platform-cli,extensible-runtime
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: JavaScript
Classifier: Topic :: Office/Business :: Financial :: Investment
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.25.0
Requires-Dist: cffi<3.0.0,>=1.15.0
Provides-Extra: data
Requires-Dist: akshare>=1.12.0; extra == "data"
Requires-Dist: pandas<3.0.0,>=2.0.0; extra == "data"
Requires-Dist: numpy<3.0.0,>=1.24.0; extra == "data"
Provides-Extra: ml
Requires-Dist: khy-os[data]; extra == "ml"
Requires-Dist: scikit-learn==1.8.0; extra == "ml"
Requires-Dist: xgboost==3.2.0; extra == "ml"
Requires-Dist: lightgbm==4.6.0; extra == "ml"
Requires-Dist: joblib==1.5.3; extra == "ml"
Requires-Dist: scipy>=1.10.0; extra == "ml"
Requires-Dist: ta>=0.11.0; extra == "ml"
Requires-Dist: tqdm>=4.65.0; extra == "ml"
Requires-Dist: pyyaml>=6.0; extra == "ml"
Requires-Dist: loguru>=0.7.0; extra == "ml"
Provides-Extra: doc
Requires-Dist: pdf2docx>=0.5.6; extra == "doc"
Requires-Dist: pytesseract>=0.3.10; extra == "doc"
Requires-Dist: Pillow>=10.0.0; extra == "doc"
Provides-Extra: frontend
Requires-Dist: khy-quant-frontend>=1.6.0; extra == "frontend"
Provides-Extra: backend
Requires-Dist: khy-quant-backend>=1.6.0; extra == "backend"
Provides-Extra: quant
Requires-Dist: khy-quant>=0.1.78; extra == "quant"
Provides-Extra: full
Requires-Dist: khy-os[data]; extra == "full"
Requires-Dist: khy-os[ml]; extra == "full"
Requires-Dist: khy-os[doc]; extra == "full"
Provides-Extra: all
Requires-Dist: khy-os[full]; extra == "all"
Provides-Extra: dev
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Dynamic: license-file

<!--
  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.
-->

<p align="center">
  <img src="assets/banner.svg" alt="khy — the AI-native operating system" width="100%">
</p>

<h1 align="center">khy</h1>

<p align="center">
  <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>

<p align="center">
  <a href="https://pypi.org/project/khy-os/"><img alt="PyPI" src="https://img.shields.io/pypi/v/khy-os?logo=pypi&logoColor=white&label=pip%20khy-os"></a>
  <a href="https://www.npmjs.com/package/@khy/os"><img alt="npm" src="https://img.shields.io/npm/v/@khy/os?logo=npm&label=npm%20%40khy%2Fos"></a>
  <a href="https://github.com/kodehu03/khy-os/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/kodehu03/khy-os/actions/workflows/ci.yml/badge.svg"></a>
  <a href="https://github.com/kodehu03/khy-os/actions/workflows/codeql.yml"><img alt="CodeQL" src="https://github.com/kodehu03/khy-os/actions/workflows/codeql.yml/badge.svg"></a>
  <br>
  <img alt="License" src="https://img.shields.io/badge/license-Source--Available-blue">
  <img alt="Python" src="https://img.shields.io/badge/python-%E2%89%A53.8-3776AB?logo=python&logoColor=white">
  <img alt="Node" src="https://img.shields.io/badge/node-%E2%89%A520-339933?logo=node.js&logoColor=white">
  <img alt="Platforms" src="https://img.shields.io/badge/platform-Linux%20%7C%20macOS%20%7C%20Windows-lightgrey">
  <img alt="Made with C / JS / Python / MoonBit" src="https://img.shields.io/badge/built%20with-C%20%C2%B7%20JS%20%C2%B7%20Python%20%C2%B7%20MoonBit-orange">
</p>

<p align="center">
  <a href="#-60-second-tour">60-Second Tour</a> ·
  <a href="#-what-is-khy">What is khy</a> ·
  <a href="#-quickstart">Quickstart</a> ·
  <a href="#-the-three-pillars">The Three Pillars</a> ·
  <a href="#-how-it-compares">Compare</a> ·
  <a href="README.zh-CN.md">中文</a>
</p>

---

## 🤯 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`) 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

```bash
pip install khy-os        # or:  npm install -g @khy/os
khy                       # launch the agentic terminal
```

```text
┌─ 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`](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)

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

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

### Run

```bash
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

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

Full guides: [`docs/指南/`](docs/指南) · Windows + VMware: [`docs/指南/windows-vmware-清单.md`](docs/指南/windows-vmware-清单.md)

---

## 🧱 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:

| Capability | Status |
|---|---|
| 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 (`\|`) | ✅ QEMU-tested |
| 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

```text
            ┌──────────────────────────────────────────────┐
            │  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
```

---

## 🆚 How It Compares

| | **khy** | Claude Code | Ollama | A 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

```text
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) 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`](CHANGELOG.md)

---

## ⭐ Star history

<p align="center">
  <a href="https://star-history.com/#kodehu03/khy-os&Date">
    <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=kodehu03/khy-os&type=Date" width="640">
  </a>
</p>

---

## 🤝 Contributing & community

- Read [`CONTRIBUTING.md`](CONTRIBUTING.md) before opening a PR.
- Be kind — see [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md).
- Found a vulnerability? See [`SECURITY.md`](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`](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.

---

<p align="center">
  <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>
