DEV Community

为由崎司献上心脏
为由崎司献上心脏

Posted on

I Built an OS That Runs Any File Format Using AI — Including Ones You Just Invented

What if your OS could run a file format you just invented?

I created a file called app.icm with this content:

PRINT Hello from ICM format
PRINT 2+2=4
Enter fullscreen mode Exit fullscreen mode

.icm is not a real programming language. No interpreter has ever existed for it. I typed:

icm> run /data/app.icm
Enter fullscreen mode Exit fullscreen mode

And got:

[SANDBOX] AI: Custom DSL detected. PRINT maps to Python print(). Converting...
Result: Hello from ICM format
        2+2=4
Enter fullscreen mode Exit fullscreen mode

No hardcoded parser. No pre-built interpreter. The AI read the file, understood what it was trying to do, converted it, and ran it.

This is ICM-OS — a research prototype of an intent-driven operating system I've been building over the past few months.


The Core Idea

Current operating systems assume you know exactly what tool you need:

Intent → Find the right software → Install it → Learn it → Use it → Get result
Enter fullscreen mode Exit fullscreen mode

ICM-OS tries to collapse this into:

Intent → Result
Enter fullscreen mode Exit fullscreen mode

You express what you want in natural language — any language — and the system figures out the rest.


How It Actually Works

ICM-OS boots as a real operating system (Linux 6.1.82 kernel, GRUB2 bootloader, Intel e1000 NIC driver, real TCP/IP stack). It's not a Docker container or a fancy Python REPL. It's an OS you can boot from an ISO.

The architecture has three layers:

Layer 1: CDM (Capability Decomposition Model)

When you type an intent, the AMS (Intent Decomposer) calls DeepSeek to break it down into a DAG of primitives — small, composable units that each do one thing.

"fetch https://example.com and summarize the content"

→ DNS_RESOLVE
    → TCP_CONNECT
        → TLS_HANDSHAKE
            → HTTP_GET
                → HTML_PARSE
                    → NLP_SUMMARIZE
Enter fullscreen mode Exit fullscreen mode

Each primitive is a Python class implementing invoke(). The output of each node flows into the next. The graph is validated for type safety and acyclicity before execution.

Layer 2: DynGen (Dynamic Primitive Generation)

Here's where it gets interesting. If a needed primitive doesn't exist in the registry, the system:

  1. Asks DeepSeek to generate a Python class for it
  2. exec()s it into the runtime
  3. Registers it in the Capability Primitive Registry (CPR)
  4. Caches the generated code to /data/primitives/

On the next boot, all cached primitives are restored automatically — zero API calls needed.

icm> calculate the SHA256 hash of "hello world"

[DynGen] Generating primitive: SHA256_HASH
[DynGen] Generated:
  import hashlib
  class SHA256_HASHPrimitive(CapabilityPrimitive): ...
[DynGen] Cached: /data/primitives/SHA256_HASH.py
Result: b94d27b9934d3e08a52e52d7...
Enter fullscreen mode Exit fullscreen mode

Next time you boot and ask for SHA256, it loads instantly from cache. The system gets smarter over time.

Layer 3: SANDBOX_EXEC

This is the "run anything" primitive. It:

  1. Reads the file content
  2. Checks the extension — if it's .py or .sh, runs directly
  3. If unknown format: asks AI to analyze content, identify the language/format, and either run directly or convert to Python first

This is how .icm files work. This is how a file with no extension works. This is how a file written in a language you invented 5 minutes ago works.


Real Working Examples

Actual DNS resolution and HTTP:

icm> fetch https://httpbin.org/ip

[DNS_RESOLVE]   ip='34.235.67.238'      real gethostbyname()
[TCP_CONNECT]   status=CONNECTED
[TLS_HANDSHAKE] cert_valid=True
[HTTP_GET]      status_code=200
Result: {"origin": "38.150.15.31"}      real response
Enter fullscreen mode Exit fullscreen mode

Multilingual intent — no configuration needed:

# Chinese
icm> 把"你好世界"写入文件 /data/notes/test.txt
Result: wrote "你好世界" to disk ✓

# German  
icm> Schreibe "Hallo Welt" in die Datei /data/notes/german.txt
Result: wrote "Hallo Welt" to disk ✓

# Japanese translation
icm> 把 你好 翻译成日文
Result: こんにちは ✓
Enter fullscreen mode Exit fullscreen mode

The AMS extracts intent parameters regardless of input language. No regex, no language-specific parsing — DeepSeek handles it.

Webpage summarization:

icm> 抓取 https://example.com 并总结内容

[HTML_PARSE]    title='Example Domain'
[NLP_SUMMARIZE] 此域名仅用于文档示例,无需授权,请勿用于实际操作。
Enter fullscreen mode Exit fullscreen mode

Running a fibonacci script:

icm> run /data/examples/fib.py
Result: Fibonacci sequence:
0 1 1 2 3 5 8 13 21 34
Enter fullscreen mode Exit fullscreen mode

Reading real kernel data:

icm> show current memory usage
MemTotal: 1023272 kB  MemFree: 841840 kB
Enter fullscreen mode Exit fullscreen mode

The Boot Process

It's a real bootable system:

qemu-system-x86_64 \
  -kernel iso-build/work/iso/boot/vmlinuz \
  -initrd iso-build/work/initrd.img \
  -append "console=ttyS0,115200n8 rdinit=/init" \
  -m 1024M -nographic \
  -netdev user,id=net0 -device e1000,netdev=net0
Enter fullscreen mode Exit fullscreen mode

What happens at boot:

  1. Linux kernel initializes
  2. Custom C init (PID 1) mounts proc/sys/devtmpfs/tmpfs
  3. Restores cached primitives from initramfs to /data/primitives/
  4. Auto-configures eth0 (10.0.2.15, gateway 10.0.2.2, DNS 8.8.8.8)
  5. Starts Python ICM shell

What's Not Finished (Being Honest)

  • No security sandbox for dynamically generated primitives. exec()ing AI-generated code is dangerous in production. This is the most important thing to fix.
  • Rendering primitives (CSS_LAYOUT, JS_EXECUTE, WINDOW_RENDER) are stubs
  • Persistent disk is tricky — the Linux Kconfig system keeps dropping my ATA/EXT4 config during make oldconfig
  • GBT (Generic Binary Translator, ARM64→x86-64) works for simple cases but the behavioral verifier is a stub
  • No package manager yet

What I Learned Building This

1. Kernel configuration is painful. make oldconfig silently drops options that don't have their dependencies satisfied. I spent hours debugging why CONFIG_E1000=y kept disappearing.

2. exec() is genuinely powerful and genuinely dangerous. Dynamic code generation opens up the system in ways that are hard to reason about. The upside is incredible flexibility. The downside is obvious.

3. Intent extraction is harder than intent execution. Getting the AI to reliably pull target_lang, url, path, and content out of arbitrary natural language inputs — in any language — required more iteration than I expected.

4. Caching is underrated. The first version regenerated every primitive from scratch on each boot. Switching to disk-cached primitives made the system feel dramatically more responsive.


What's Next

  • Wasm or seccomp sandbox for AI-generated primitives
  • Auto-dependency installation: run a Flask app → system automatically pip installs Flask
  • Replace Linux with a microkernel (seL4 or custom)
  • Local inference to remove the DeepSeek API dependency

Try It

git clone https://github.com/jinbohao1688/icm-os.git
cd icm-os
echo "DEEPSEEK_API_KEY=your_key" > .env
pip install -r requirements.txt
python3 cli.py  # dev mode, no kernel needed
Enter fullscreen mode Exit fullscreen mode

For the full bootable experience, see the build instructions in the README.

GitHub: https://github.com/jinbohao1688/icm-os
Paper (CDM/GBT theory): https://jinac.vxni.ink


I'd love

Top comments (0)