Skip to content

scobru/shogun-cc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SHOGUN CC (Continue Communication)

CC is a terminal-based peer-to-peer encrypted chat application built upon Gun.js and shogun-relays.

It uses SEA (Security, Encryption, Authorization) to exchange end-to-end encrypted messages and timestamps directly to other peers in a fully decentralized way without requiring persistence (localStorage or radisk are disabled).

Features

  • P2P encrypted: Relies on GUN SEA for end-to-end payload encryption. Only users who know the room password can decrypt messages.
  • Decentralized: Uses shogun-relays to discover and connect to available GUN peers over the network.
  • CLI Chat: Real-time terminal interface for chatting.
  • AI Agent & Script Ready: Exposes a clean and fully asynchronous API to easily integrate CC programmatically into any Javascript project or AI backend.

1. CLI Usage

You can install cc globally on your system to use it directly from your terminal.

# From within the cc directory
npm install -g .
# Or use npm link
npm link

This will register the cc binary on both Linux/macOS and Windows, allowing you to run it from anywhere.

Starting a Chat

cc [PASSWORD] [ROOM_NAME] [ALIAS]
  • PASSWORD: The shared password used to encrypt and decrypt messages. Default is CC-PASSWORD.
  • ROOM_NAME: The name of the channel/room you want to join. Default is CC.
  • ALIAS: Your display name inside the chat. Default is your system username.

Examples:

cc                            # Join default room
cc secret general             # Join 'general' room using password 'secret'
cc secret general AgentSmith  # Join as 'AgentSmith'

Special Commands

Inside the chat prompt, you can type special commands:

  • /clear - Locally clears chat messages and clears the console screen.

2. Programmatic Usage (for AI Agents & Scripts)

You can import CC securely initialized without stdout or readline dependencies, and use it autonomously.

Initialization & Messaging

const CC = require("cc"); // or './index' if local

(async () => {
  // 1. Create a new CC instance
  const roomName = "general";
  const password = "my-secret-password";
  const chat = new CC(roomName, password);

  // 2. Initialize connection (returns the array of connected relay peers)
  const peers = await chat.init();
  console.log("Connected to Shogun Relays:", peers);

  // 3. Listen to incoming messages
  chat.onMessage((msg) => {
    console.log(
      `[${new Date(msg.ts).toLocaleTimeString()}] ${msg.sender}: ${msg.content}`
    );
  });

  // 4. Send messages
  await chat.send("Hello from the AI agent!");
})();

API Reference

new CC(roomName = 'CC', password = 'CC-PASSWORD', alias = 'Anonymous')

Initializes the instance parameters. Connections do not start until you execute init().

await chat.init()

Starts the Gun instance and fetches active network relays. Subscribes to new messages. Returns an array of connected string peer URLs.

chat.onMessage(callback)

Registers a listener that is triggered whenever a valid, correctly-decrypted message propagates to your node.

  • callback: Function called with a single object { sender: string, type: string, content: any, ts: number, key: string }.

await chat.send(content, type = 'text')

Encrypts the payload and timestamp using SEA, propagates it to the P2P network, and caches the key locally so the network echo won't replay it on your onMessage handler.

  • content: String payload or structured JSON object.
  • type: Optional string to define the type of the message (defaults to 'text'). Returns a promise that resolves the unique Gun key created for propagation.

chat.clear()

Wipes the local reference map to clear the historical messages.

About

Continue Communication

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors