An AI-assisted operating-system prototype written in Rust for x86_64.
Website: psydianos.github.io/PsyDian_OS · Community: Discord
PsyDian is a small bare-metal kernel that boots in QEMU, gives you an interactive shell, and turns kernel failures into structured diagnostic records. A host-side AI Bridge reads those records over the serial port and asks an external AI service to explain them. The AI layer never runs inside the kernel and never executes commands on its own.
User -> PsyDian shell -> kernel -> diagnostic record -> serial channel -> AI Bridge -> AI service
On Linux, macOS or Windows (inside WSL), open a terminal and run:
curl -fsSL https://raw.githubusercontent.com/PsyDianOS/PsyDian_OS/main/scripts/install.sh | bashThis installs everything PsyDian needs (QEMU, Rust, git, Python), downloads and builds PsyDian into ~/PsyDian_OS, adds a psydian command and runs a short self-test. The first run takes a few minutes. Running it again updates an existing install.
Then:
| Command | What it does |
|---|---|
psydian |
Boot PsyDian (QEMU window if there is a display, otherwise in the terminal) |
psydian demo |
Boot with a mock AI Bridge: try ai hello, then run 1 |
psydian ai-setup |
Choose the AI service once: free Gemini (default), OmniRoute, OpenRouter or a local Ollama model. Saves the key to ~/.config/psydian/ai.env |
psydian ai |
Boot with the real AI Bridge (ai-bridge/). Add --window for a QEMU window |
psydian ai-check |
AI Bridge self-test with the real kernel (no API key needed) |
psydian check |
End-to-end smoke test (about 30 seconds) |
psydian test |
Full kernel test suite |
psydian update |
Download the latest version and rebuild |
Inside PsyDian, type help to list the shell commands and shutdown to quit.
Windows: run wsl --install in PowerShell (as administrator), restart, open "Ubuntu" from the Start menu and run the command there.
| Week | Scope | Status |
|---|---|---|
| 1 | Requirements, documentation, toolchain | Done |
| 2 | Bootable kernel, serial output, logging | Done |
| 3 | Exceptions, interrupts, paging, heap | Done |
| 4 | Keyboard and serial input, shell | Done |
| 5 | Logger levels, diagnostics, panic handling, message protocol | Done |
| 6 | Host-side AI Bridge | Done |
| 7 | External AI integration and safety validation | Done (free Gemini, OmniRoute, OpenRouter, Ollama; Claude optional) |
| 8 | Integration, testing, demo | In progress (one-command installer, CI and end-to-end self-tests done; demo website and final report left) |
The installer does all of this for you. To set up by hand you need:
- Linux or macOS (on Windows, use WSL), plus git, Python 3 and a C linker (
cc) - rustup. The nightly toolchain,
rust-src,llvm-tools-previewand thex86_64-unknown-nonetarget are installed automatically fromrust-toolchain.toml. - QEMU:
qemu-system-x86_64must be on yourPATH.
cargo buildBuilds the kernel and a bootable BIOS disk image.
cargo runBoots PsyDian in a QEMU window. The serial port is attached to your terminal, so you can type commands either in the QEMU window or directly in the terminal.
cargo run -- --headlessSame, without a window (serial console only). Add --debug to log CPU exceptions and resets to qemu.log.
cargo run -- --serial-tcp 4555Opens the serial port on 127.0.0.1:4555 instead of the terminal, and waits until a client connects. This is how the AI Bridge attaches while QEMU shows its window.
cargo ktestRuns every kernel unit and integration test inside QEMU.
python3 scripts/mock-bridge.pyBoots PsyDian headless with a mock AI Bridge attached, so ai questions get canned answers and you can try run. No AI service or API key is needed. The real AI Bridge is developed separately.
python3 scripts/mock-bridge.py --checkEnd-to-end smoke test: boots the kernel, drives the shell through the mock bridge (answers, AI command safety, bridge errors, invalid answers, cancel) and checks every step.
| Command | What it does |
|---|---|
help [command] |
List commands, or show how to use one |
clear |
Clear the screen |
info |
Kernel and system information |
meminfo |
Physical memory, frame and heap usage |
uptime |
Time since boot |
echo [text...] |
Print text |
history |
Previously entered commands |
logs [count] [level] |
Recent kernel log records |
diag [list | last | <n> | send <n>] |
Show or re-send diagnostic records |
ai <question...> |
Send a question to the AI Bridge and show its answer (waits 3 s without a bridge, 30 s with one; Ctrl+C cancels) |
run [number] |
Run a command the AI suggested in its last answer, after the safety checks; without a number, list them |
panic-test |
Trigger a controlled kernel panic (asks for confirmation) |
fault-test <scenario> |
Inject a fault: breakpoint, heap, page-fault, divide-by-zero, invalid-opcode, stack-overflow (asks for confirmation) |
shutdown |
Stop the system (exits QEMU) |
Tab completes command names, Up/Down browse the history, Ctrl+C abandons the current line and Ctrl+L clears the screen.
The AI never runs anything. Its suggested commands are listed with a number and a risk level, and run only when you type run <number>:
| Risk | Commands | When suggested by the AI |
|---|---|---|
| safe | help, info, meminfo, uptime, logs, diag, ... |
runs |
| sensitive | ai |
asks y/N first |
| privileged | shutdown |
asks y/N first |
| destructive | panic-test, fault-test |
blocked |
help <command> shows a command's risk level. The full policy is in the security design (section 5.2).
Run fault-test heap and confirm with y:
[ERROR][MEMORY][MEM-003] Heap allocation failed (diag-001)
@PSY {"type":"diagnostic","version":1,"id":"diag-001","payload":{"severity":"error","subsystem":"memory","code":"MEM-003","uptime_ms":2070,"message":"Heap allocation failed","context":{"size":"67108864","align":"8","heap_size":"1048576","heap_used":"0"}}}
The first line is the human-readable log record. The line starting with @PSY is a protocol frame for the AI Bridge and only appears on the serial port, never on the screen. The frame format is specified in the protocol reference (section 8.5) and the error codes in observability and error codes (section 11).
Cargo.toml workspace + host-side launcher package
build.rs builds the bootable disk image from the kernel
src/main.rs launcher: runs QEMU for `cargo run` and for kernel tests
scripts/ installer, `psydian` command, mock AI Bridge and smoke test
.github/workflows/ CI: runs the installer, smoke test and kernel tests
kernel/
src/
main.rs kernel entry point
lib.rs boot sequence (kernel::init) and test framework
serial/ COM1 driver
framebuffer.rs pixel text console
console.rs print!/println! (serial + screen)
logger/ levels, subsystems, log history
gdt.rs GDT and TSS (double-fault stack)
interrupts.rs IDT, exception and IRQ handlers
time.rs PIT tick counter
memory/ paging, frame allocator, heap mapping
allocator/ kernel heap allocator
input/ key queue, PS/2 keyboard and serial decoders
shell/ line editor, parser, commands, history, completion
diagnostics/ structured diagnostic records
protocol/ serial frames to and from the AI Bridge (JSON reader, reply validation)
panic/ panic and fatal-exception capture
tests/ integration tests (each boots its own kernel in QEMU)
The full design and reference documentation lives in its own repository, PsyDianOS/docs, and is published at psydianos.github.io/docs.
| Start here | |
|---|---|
| Project overview | What PsyDian is and why |
| High-level design | How the kernel, AI Bridge and AI service fit together |
| Low-level design | Modules, data structures and control flow |
| Protocol and API | The @PSY frames between the kernel and the AI Bridge |
| Roadmap | What was built and what comes next |
- Anurag Singh — kernel, shell, core OS implementation
- Aditya Chauhan — AI Bridge, AI integration, AI testing
Contributions are welcome. See CONTRIBUTING.md for how to set up, test and open a pull request, and CODE_OF_CONDUCT.md for how we work together. To report a security problem, follow SECURITY.md.
PsyDian is dual-licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution you intentionally submit for inclusion in PsyDian, as defined in the Apache-2.0 license, shall be dual-licensed as above, without any additional terms or conditions.
