ClawDOS – An AI coding agent for DOS

Hacker News by 11 min read 54x views
ClawDOS – An AI coding agent for DOS

Share Post

Ricapar/ClawDOS

An AI coding delegate for DOS.
It runs on an IBM PC XT: an 8088 at 4.77 MHz, 640K of RAM, a CGA card.

A (real) human’s note:


Backstory: The IBM PC was my archetypal computer. Rather, it was my parents’ archetypal individual device that I got to use at a extremely first age.

It was already obsolete by the period I was old adequate to use it, but at 5 years old it was a magical equipment that I could create do distinct things depending on what I typed.

I learned how to category and use DOS so that I could initiate several first “Learn the Alphabet” games that my mom had bought me. I learned several elementary-level use of BASIC, but at the period that didn’t advancement much additional than making several figure guessing games and another small projects.

From there, many years passed but I motionless have several of the first parts of that PC. I have a gathering of vintage machines that average item to me, alongside my completely maxed-out IBM PC 5160 being the centerpiece of my collection. It motionless has a operating 20 MB difficult drive, but that’s detached in favor of a PicoMEM that lets me emulate a difficult run off of an SD card, making experimentation and perform much easier.

Old, encounter new. New, encounter old: I affection intersections of old and new technology. What improved way to cross the two than construction an AI coding delegate to run on DOS on first hardware?

And of course, what improved to build it than an AI coding agent?

I (read: Claude) built this for my own entertainment. I wanted to see how far I could shove an AI coding delegate to build item stated out of the (modern) norm of constraints. Also, can that item it built afterward build another somethings? 100% of this repo is written by Claude, alongside the elimination of the content inside this box.

As explained in additional item below, the harness runs on the native OS and hardware and relies on a “bridge” PC in command to grip TLS, which would’ve been additional than what an 8088 could handle.

The ClawDOS beginning screen

Type CLAWDOS at the C:\> immediate and conversation to Claude. It says and edits the files on your disk, writes programs, compiles them alongside Turbo C, runs them and looks at what they diagram on the screen. It keeps notes between conversations and picks up anywhere it remaining off.

The entire harness runs on the PC. HARNESS.EXE is a 176 KB DOS program that speaks the Claude Messages API itself: it writes the requests, parses the streamed reply, runs the tools and keeps all conversation on its own disk. The 8088 does everything but TLS.

See it work

Every display below comes from a 5160 at 4.77 MHz, emulated in 86Box. The conversations are alongside the live API.

From a declaration to a operating program

ClawDOS writes, compiles and runs PRIMES.C

One message: “Write PRIMES.C: imprint the primes below 100. Compile it with Turbo C and run it.” ClawDOS says its guide to the compilers on this machine, writes the source, afterward compiles, links and runs it in a sole tool call. The answer is on the display 64 seconds following Enter, 26 of them spent compiling, linking and running.

The compiler gets the device to itself. For a build, ClawDOS saves its state and leaves memory, Turbo C runs alongside concerning 450K free, and the harness comes back on the identical conversation alongside the program’s output in hand.

WarGames, written on the XT

ClawDOS wrote this tribute to the 1983 movie on the PC itself: a vector world map, missiles arcing complete the pole, a tic-tac-toe endgame, and a mark for the PC speaker or an AdLib card. Five records of Turbo C, 15 KB of source, a WG.EXE under 10 KB.

GREETINGS PROFESSOR FALKEN. SHALL WE PLAY A GAME?  missile arcs complete a earth map

Tic-tac-toe games played to a draw The lone winning move is not to play

Here it is operating on the genuine 5160, filmed off its IBM monitor:

 the WarGames demo operating on a genuine IBM PC 5160 (YouTube)
▶ Watch the WarGames demo on YouTube

It remembers

Start a new conversation and “your WarGames demo” is all it needs. ClawDOS opens the note it saved in C:\MEMORY, finds the latest build, and recalls the palette trick the war environment plays on the CGA.

ClawDOS says its WARGAMES recollection and runs the demo alongside a screenshot

It sees the screen

That Run call asked for a screenshot 25 seconds in. A timer-interrupt hook copies the CGA’s video recollection at that moment, the 8088 encodes it as a PNG, and the image goes to Claude alongside the tool result. This is the document the PC made, 320x200 in four colours, 16 KB:

The PNG screenshot encoded on the 8088

And this is what Claude made of it:

 the map, the missile arcs, the explosions

An delegate at work

Asked to create the demo exit on its own, ClawDOS goes looking. It searches the sources for the keyboard wait, says the file, says what it established and edits one line. Each tool call shows in the copy alongside its result, and between them Claude says what it is concerning to do.

Search, Read and Edit tool calls in the transcript

It plays

Text art in sixteen colours, direct into the transcript, and music on the PC speaker in GW-BASIC’s PLAY language.

ClawDOS draws itself in coloured content art

The harness

A conversation display built for the CGA. Replies stream onto the display as they arrive, word-wrapped at 80 columns in code leaf 437. Writes are timed to the retrace, so there is no snow. The copy scrolls in hardware through the CRTC commencement address, alongside PgUp and PgDn to go back. The spinner and its seconds run from the timer interrupt and keep moving during the PC is busy.

Eighteen tools. Claude plant on the device through these:

Tools What they do
sysinfo, dir, read, search Look at the system, catalog directories, peruse records as content or hex, discover content throughout files
write, edit, delete, mkdir, rename Create and alter files; edit replaces one part of a document in place
run Run DOS programs and lot records and peruse rear what they printed, up to dozen commands in a call, alongside a screenshot on request
peek, poke, port Read and compose recollection and I/O ports
play, textart PC speaker music and coloured CP437 art
memory_list, memory_read, memory_write Its own notes, kept in C:\MEMORY

A betterment kit on the disk. Two assemblers (TINYASM and WASM), Bruce’s C, GW-BASIC and the lDebug debugger, affirmative Turbo C 2.0, installed from your own floppy images in external/. All of them are proven on the 8088, and ClawDOS knows how to run all one.

Memories and skills. Memories are what ClawDOS learns on your PC: what you built together, what worked, what you like. Skills are guides that container with it, specified as the dev tools and CGA demo effects. Both are plain content records on the disk, listed in all conversation’s scheme immediate and peruse whenever they fit the task. F4 browses the memories:

The F4 memories screen

Safe mode. On by default. Anything that changes a file, recollection or a port asks Allow ...? (y/n) first. F3 turns it off.

Conversations that last. Every conversation is a document on the disk in the API’s own message format. F6 lists them, Enter reopens one, and your next message carries it on. A conversation cut off by the power toggle reopens too.

The F6 conversation list

Any model, mid-conversation. /model lists the providers in CLAWDOS.CFG and switches between them and their models without losing the conversation. F5 sets how difficult Claude thinks, from low to max. Any presenter that speaks the Messages API works.

Easy on a dilatory link. The scheme immediate and tools are cached by the API. After a conversation’s archetypal petition the PC uploads lone what is new, so a tool result goes up in concerning 500 bytes. A dropped association or an overloaded API is retried, and the rotate carries on.

A escape recorder. CLAWDOS.LOG has a row for all round: period to first token, upload size and time, tokens in and out, cache reads.

api anthropic claude-opus-5-5 round=1 ttft=2750 total=4015 up=165 len=1784 stop=tool_use in=2 out=221 cr=5543 cw=739 th=cont relaunch: program 61.5 s, CLAWDOS distant 82.3 s 

Under the hood

flowchart LR subgraph DOS["IBM PC XT (8088, 640K, CGA)"] direction TB subgraph APP["HARNESS.EXE"] direction TB UI["Chat screen"] LOOP["Agent loop<br/>Messages API requests, SSE and JSON,<br/>history on disk"] TOOLS["Tools<br/>files, search, DOS programs, screenshots,<br/>memory and ports, speaker"] end NET["mTCP + packet driver"] APP <--> NET end TUNNEL["TLS tunnel<br/>copies bytes"] API["Claude Messages API"] NET <-->|"plain HTTP"| TUNNEL TUNNEL <-->|"HTTPS"| API 
   
Machine IBM PC XT 5160: 8088 at 4.77 MHz, 640K, CGA. A PicoMEM cardstock supplies the disk (an depiction on microSD), WiFi as an NE2000, EMS and a power division clock
Code 13,000 lines of C and C++, built alongside Open Watcom for the 8086 education set
Programs HARNESS.EXE, 176 KB, the entire harness. CLAWDOS.EXE, 29 KB, the launcher you type
System FreeDOS 1.4 alongside mTCP for TCP/IP
API The Claude Messages API, streamed: tool use, images, immediate caching, communication threads
TLS A tunnel on another machine, tunnel/tunnel.py, socat or stunnel. It copies bytes between a plain harbor and api.anthropic.com:443. It can additionally clasp the API key, so the key never touches the PC’s disk
Memory A program ClawDOS runs gets 200K beside the harness, or 450K whenever the harness steps out
Tests 31 footwear tests in DOSBox-X against a imitate API, component tests that run on DOS, and runs on 86Box’s 8088

docs/API.md has exactly what ClawDOS sends and what it expects back.

Run it

You need a Mac or a Windows PC alongside Python 3, and an Anthropic API key. On Windows the command is python.

python3 scripts/setup-tools.py # fetch the compilers, FreeDOS, mTCP and the emulators echo ANTHROPIC_API_KEY=sk-ant-... > .env python3 scripts/build.py # build/CLAWDOS.IMG, a bootable disk python3 tunnel/tunnel.py # the TLS tunnel, on harbor 8443 python3 scripts/run86box.py # footwear an IBM PC XT 

At the C:\> prompt, category CLAWDOS.

No key? python3 tunnel/mockapi.py plays the API offline: type CLAWDOS 10.0.2.2:18023 and dispatch !help.

On a genuine PC: build alongside the location of the device operating the tunnel (python3 scripts/build.py --tunnel 192.168.1.10:8443), copy CLAWDOS.IMG to the PicoMEM’s microSD card, choice it as the difficult disk in the PicoMEM’s menu, boot, and category CLAWDOS. Later builds update the card’s depiction in location and keep its memories and chats (python3 scripts/build.py --update /path/to/CLAWDOS.IMG).

At the keyboard

Key  
Enter Send
Esc Stop a reply, or apparent the input
Up / Down Recall before messages
PgUp / PgDn Scroll back
F1 Help
F2 New chat
F3 Safe manner on or off
F4 Memories
F5 Effort: low, medium, high, xhigh, max
F6 Earlier chats
F10 Quit

/model, /chats, /memories, /new and /quit activity from the input box. CLAWDOS -m "..." sends a communication from the command row and -c NAME reopens a chat.

More

   
docs/MANUAL.md Setup in full, genuine hardware, the depiction updater, another providers, all setting
docs/API.md What ClawDOS sends to the API and expects back
docs/ROADMAP.md The plan, the benchmark and the recollection map
Path What
src/harness/ HARNESS.EXE: the conversation screen, the turn, the tools
src/clawdos/ CLAWDOS.EXE, the launcher
lib/ The pieces: screen, console, network and HTTP, the API petition author and stream parser, JSON, history, the tool executors, screenshots and the PNG encoder
tunnel/ The TLS tunnel and the imitate Messages API
image/ What goes on the disk: the manifest, the scheme prompt, the tool schemas, the skills, the tests
scripts/ Build, disk depiction tools, the emulator runners and test harnesses
tests/unit/ DOSUNIT.EXE, the component tests that run on DOS

License

ClawDOS is liberated application under the GNU General Public License, type 3 or (at your option) any afterward version: see LICENSE. HARNESS.EXE links mTCP, which is GPLv3. The FreeDOS boot field in src/boot/freedos is vendored unmodified under its own GPLv2-or-later license (its COPYING). Disk images you build clasp another people’s application (FreeDOS, mTCP, and Turbo C from your own floppies): don’t redistribute an depiction alongside Turbo C on it.

ClawDOS stands on mTCP, FreeDOS, Open Watcom, the PicoMEM, 86Box and DOSBox-X.

Other Article Hacker News
↑
Close Right Ads
Close Left Ads