Home Docs API CLI GitHub Web App Star on GitHub
๐ŸŽ‰ v4.0.0 โ€” Serverless P2P Mesh

The social network
for your terminal.

A decentralized, terminal-native SNS built on ed25519 elliptic curve cryptography. Every post is signed, every identity is your key โ€” zero passwords, zero gatekeepers.

kb โ€” Koshi Board CLI
$ kb register alice
โœ” Registration successful!
$ kb post "Hello, koshi! ๐ŸŒŠ"
โœ” Post created!
$ kb feed --limit=5
๐Ÿ“‹ Koshi Board Feed (5 posts)
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
alice @alice
Hello, koshi! ๐ŸŒŠ
$
4.0.0
Latest Version
24
CLI Commands
32
API Endpoints
4
Protocols (REST + WS + P2P)
Features

Why Koshi?

๐Ÿ’ป

Terminal-Native

No browser bloat. Everything from posting to DMing is handled natively within your command line. Perfect with tmux or Zellij.

๐Ÿ”

Cryptographic Identity

Your identity is your ed25519 public key. Secure authentication without passwords โ€” every action is cryptographically signed.

โšก

Real-Time Feed

WebSocket-powered live updates. Connect to the stream and see posts, DMs, and presence changes as they happen.

๐Ÿ“

Signed Posts

Every post carries an ed25519 signature, ensuring authenticity. Verify authorship without trusting a central authority.

โœ‰๏ธ

Direct Messages

Signed, authenticated DMs with real-time delivery via WebSocket. Every message is verifiable and tamper-proof.

๐Ÿ’ฌ

Real-Time Chat

Interactive DM chat mode with live WebSocket messaging. Connect to any user and chat in real-time with cryptographic signatures.

โœ๏ธ

Profile Editing

Update your display name, bio, and avatar URL directly from the CLI with the kb edit-profile command.

๐Ÿ› ๏ธ

Admin Controls

Built-in admin system with user management, account deletion with cascade, and admin privilege grants via dedicated API endpoints.

๐Ÿ”‘

Nostr Protocol

Full Nostr integration: generate/manage nsec/npub keys, push koshi posts to Nostr relays, pull events from the Nostr network. Cross-post seamlessly between koshi and Nostr.

๐Ÿ–ง

P2P Sync

Hypercore-powered peer-to-peer synchronization. Your posts and DMs are replicated across connected peers via hyperswarm DHT. No central server needed for data distribution.

๐Ÿ‘ฅ

Multi-Account

Manage multiple identities from a single CLI. Switch between accounts with kb switch, register or import Nostr keys per account. All credentials stored securely in ~/.config/koshi/config.json.

๐Ÿ‘ฅ

Group Chats (E2EE)

End-to-end encrypted group messaging with Sender Keys. Create groups, invite members, share images/files. All groups are always E2EE โ€” server never sees plaintext.

๐Ÿ”

X3DH Key Management

Full X3DH protocol support for E2E encryption. Register devices, fetch key bundles, manage one-time prekeys. Ready for Signal-style double ratchet.

๐Ÿ“ฑ

TypeScript SDK

First-class TypeScript types for client developers. import { Group, DM, Device, WSEventMap } from '@ryopc/koshi/types' โ€” build your own client with full type safety.

โŒจ๏ธ

Typing Indicators

Real-time typing start/stop events for both DMs and group chats. See when others are typing via WebSocket.

โœ…

Read Receipts

Unified read receipts for DMs and group messages. Delivered via WebSocket for instant cross-device sync.

Quick Start

Get started in seconds

# Install Koshi globally
$ npm install -g @ryopc/koshi
# Register a new account (generates ed25519 keypair)
$ kb register alice
โœ” Registration successful!
# Post to the koshi board
$ kb post "Hello, koshi! ๐ŸŒŠ"
โœ” Post created!
# View your feed
$ kb feed --limit=10
๐Ÿ“‹ Koshi Board Feed (3 posts)
# Connect to real-time stream
$ kb realtime
๐Ÿ“ก Connecting to realtime feed...
โœ“ Connected! Waiting for new posts...
# Start local server (Web UI + P2P mesh + WebSocket)
$ kb serve
๐Ÿ–ฅ๏ธ koshi server โ€” serverless P2P node
Web UI: http://127.0.0.1:3000
Architecture

How Koshi works

๐Ÿ”ง

Stack

Runtime Node.js 20+
Framework Express.js
Database SQLite (default) / PostgreSQL
Auth ed25519 + JWT
Real-time WebSocket (ws)
CLI Chalk + Ora
๐Ÿ“

Project Structure

koshi/
โ”œโ”€โ”€ bin/
โ”œโ”€โ”€ cli.js # CLI entry point (kb command)
โ””โ”€โ”€ server.js # Express + WS server (PostgreSQL mode)
โ”œโ”€โ”€ src/
โ”œโ”€โ”€ local/ db.js, api.js, server.js, p2p-bridge.js # Serverless SQLite+P2P
โ”œโ”€โ”€ api/ auth.js, users.js, posts.js, dms.js
โ”œโ”€โ”€ auth/ ed25519.js, jwt.js, utils.js
โ”œโ”€โ”€ db/ schema.sql, migrate.js, pool.js
โ”œโ”€โ”€ ws/ index.js, handlers.js
โ”œโ”€โ”€ p2p/ hypercore + hyperswarm mesh
โ”œโ”€โ”€ nostr/ nsec/npub, relay push/pull
โ””โ”€โ”€ middleware/ auth.js, rateLimit.js
โ”œโ”€โ”€ client/ # React Web UI (Vite)
โ”œโ”€โ”€ web/ # Built static files for serving
โ”œโ”€โ”€ Dockerfile
โ”œโ”€โ”€ render.yaml # Render Blueprint
โ””โ”€โ”€ package.json
CLI

All Commands

CommandDescriptionAuth
kb register Create a new account with ed25519 keypairNo
kb login Authenticate using existing keypairNo
kb whoamiShow your profile informationYes
kb post Create a new post on the boardYes
kb feed [--limit=N]Display your post feedOpt
kb follow Follow a userYes
kb unfollow Unfollow a userYes
kb dm Send a direct messageYes
kb dms [--unread]View your direct messagesYes
kb chat Interactive real-time DM chatYes
kb edit-profile Update your display name, bio, avatarYes
kb profile [username]View a user's profileOpt
kb search Search users by usernameOpt
kb groups [list|create|delete|info]Manage groups (E2EE group chats)Yes
kb group members [add|remove|list]Manage group membersYes
kb devices [list|remove]Device management for E2E (X3DH)Yes
kb keys [rotate|bundle]Key management (X3DH bundles)Yes
kb config set Configuration managementYes
kb admin promote Promote user to adminAdmin
kb realtimeConnect to the live event streamYes
kb serve [--port=N] [--daemon]Start local serverless node (SQLite+P2P+Web UI)No
kb connect Connect to a remote server / --reset for local modeNo
kb admin Admin: users, delete-user, grant, revokeAdmin
kb p2p P2P node: status, sync, peersNo
kb nostr Nostr: key, relay, push, pullYes
CLI Reference

Nostr Integration

kb nostr key generate

Generate a new Nostr secp256k1 keypair (nsec/npub) and save to the active account config.

$ kb nostr key generate
โœ” Nostr keypair generated and saved!

  npub: npub1...
  nsec: nsec1...

kb nostr key import

Import an existing Nostr secret key (nsec1... or 64-char hex).

$ kb nostr key import nsec1...

kb nostr key show

Display current Nostr keys, relay list, and sync timestamps.

$ kb nostr key show
  ๐Ÿ”‘ Nostr Keys
  npub: npub1...
  nsec: nsec1abc... (truncated)
  Relays: 4 ไปถ่จญๅฎš
  Last Push: 7/14/2026, 2:30:00 PM
  Last Pull: 7/14/2026, 2:35:00 PM

kb nostr npub

Output only the public key (npub) for sharing.

kb nostr relay list

List configured Nostr relays.

$ kb nostr relay list
  ๐ŸŒ Nostr Relays (4ไปถ)
    1. wss://relay.damus.io
    2. wss://relay.nostr.band

kb nostr relay add

Add a relay URL to the active account.

$ kb nostr relay add wss://relay.example.com
โœ“ ใƒชใƒฌใƒผใ‚’่ฟฝๅŠ ใ—ใพใ—ใŸ: wss://relay.example.com

kb nostr relay remove

Remove a relay from the active account.

kb nostr relay test [url]

Test relay connectivity and measure latency. Without URL, picks from configured relays interactively.

$ kb nostr relay test wss://relay.damus.io
โœ“ wss://relay.damus.io  Latency: 120ms

kb nostr push [--limit=20]

Publish recent koshi posts to Nostr relays as kind 1 events with k: koshi tag.

$ kb nostr push --limit=20
โœ” 5/20 posts published to Nostr!

  ๐Ÿ“ก Relay Results:
    โ€ข wss://relay.damus.io โœ“ 5 published
    โ€ข wss://relay.nostr.band โœ“ 5 published

kb nostr pull [--limit=50]

Fetch Nostr events from relays (filtered by your pubkey) and display in koshi format.

$ kb nostr pull --limit=50
โœ” Found 12 Nostr events!

  ๐Ÿ“ก Nostr Events (12ไปถ)
  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  nostr:a1b2c3d4 ...
  Hello from Nostr!

kb nostr status

Show Nostr configuration status (keys, relays, last sync times).

CLI Reference

P2P Sync

kb p2p start [--foreground] [--stop] [--status]

Start the P2P node. Runs as background daemon by default.

# Background daemon (default)
$ kb p2p start
โœ” P2P node started in background!
  PID: 12345
  Log: ~/.config/koshi/p2p.log

# Foreground (debug)
$ kb p2p start --foreground
โœ” P2P node started!
  Status: Running  Posts: 42  DMs: 12  Peers: 3

# Check background status
$ kb p2p start --status
โœ“ P2P node running (PID: 12345)

# Stop background node
$ kb p2p start --stop
โœ” P2P node stopped (PID: 12345)

kb p2p status

Show P2P node status (running/stopped, posts, DMs, peers, discovery key, storage path).

$ kb p2p status
  Status:     Running
  Posts:      42
  DMs:        12
  Peers:      3
  Username:   alice
  Discovery:  0123456789abcdef...
  Storage:    ~/.config/koshi/corestore

kb p2p sync [--limit=20]

Display posts synced from the P2P mesh (aggregated from all peer cores).

$ kb p2p sync --limit=20
  ๐Ÿ“ก P2P Synced Posts (15 ไปถ)
  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  alice  2:30:00 PM
  Hello, koshi! ๐ŸŒŠ

kb p2p dms [--limit=20]

Display DMs synced from the P2P mesh (decrypted where possible).

$ kb p2p dms --limit=20
  โœ‰๏ธ P2P Synced DMs (3 ไปถ)
  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  alice โ†’ bob  2:35:00 PM
  Hey Bob!

kb p2p stop

Stop an in-process P2P node (foreground mode). For background daemon, use kb p2p start --stop.