Skip to content

evoleinik/ai-9p

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ai-9p

Expose Claude as a Plan 9 filesystem.

Philosophy

"For 40 years, Unix piped static text. Now we can pipe dynamic queries to intelligence."

This project exposes Claude CLI as a 9P filesystem, letting you interact with AI using standard Unix tools.

Filesystem Structure

/claude/
├── ask              # Stateless query (write prompt, read response)
├── stream           # Streaming responses
├── chat/
│   ├── new          # Write to create session, read to get session ID
│   └── {id}/        # Session directory (created dynamically)
│       ├── prompt   # Write message, read response
│       └── history  # Read conversation history
├── config/
│   ├── model        # Read/write model name
│   └── system       # Read/write system prompt
└── log              # Read interaction history (last 100)

Requirements

Install

# Clone and build ai-9p
git clone https://github.com/yourusername/ai-9p
cd ai-9p
go build -o ai-9p .

# Install plan9port (if not already installed)
git clone https://github.com/9fans/plan9port ~/projects/plan9port
cd ~/projects/plan9port
./INSTALL

Usage

Start the 9P server:

./ai-9p &
# ai-9p serving on localhost:5640

Stateless queries

# Simple question
echo "What is 2+2?" | 9p -a localhost:5640 rdwr claude/ask
# → 4

# Streaming response
echo "Write a haiku" | 9p -a localhost:5640 rdwr claude/stream
# → A circuit hums low / Binary rivers flowing / Silicon dreams wake

Stateful chat sessions

# Create a new session
echo "start" | 9p -a localhost:5640 rdwr claude/chat/new
# → 51000

# Send messages (Claude remembers context)
echo "My name is Alice" | 9p -a localhost:5640 rdwr claude/chat/51000/prompt
echo "What is my name?" | 9p -a localhost:5640 rdwr claude/chat/51000/prompt
# → Your name is Alice

# Read conversation history
9p -a localhost:5640 read claude/chat/51000/history

Configuration

# Read current model
9p -a localhost:5640 read claude/config/model

# Set system prompt
echo "You are a pirate" | 9p -a localhost:5640 write claude/config/system

Interaction log

# View recent interactions (timestamped)
9p -a localhost:5640 read claude/log

Shell Helpers

Add to ~/.zshrc:

export PLAN9=~/projects/plan9port
export PATH=$PATH:$PLAN9/bin

# Quick AI query
ai() {
    echo "$*" | 9p -a localhost:5640 rdwr claude/ask
}

# Example usage
ai "What is the capital of France?"
git diff | ai "summarize these changes"

Architecture

┌─────────────┐     ┌──────────────┐     ┌───────────┐
│  User/Shell │────▶│  9P Server   │────▶│ Claude CLI│
│  9p/cat/echo│◀────│  (Go)        │◀────│           │
└─────────────┘     └──────────────┘     └───────────┘

Why?

Plan 9's vision: everything is a file. The filesystem is the universal API.

LLMs communicate via text streams. The intersection is natural:

  • No SDKs or libraries needed
  • Standard Unix tools work (cat, echo, pipes)
  • Composable with other programs
  • Network transparent via 9P
  • Stateful sessions as directories

License

MIT

About

Expose Claude as a Plan 9 filesystem. Query AI with cat, echo, and pipes.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages