Skip to content

Conversation

@drdoc-bot
Copy link

@drdoc-bot drdoc-bot bot commented Jan 14, 2026

Overview

This PR adds a command-line interface (CLI) client for YSTP, allowing you to share files directly from the terminal without needing to use the web interface.

Features

Commands

  • ystp send <file> - Sends a file and returns a shareable 5-word mnemonic code
  • ystp receive <code> - Receives a file using the shareable code
  • --output <filename> - Optional flag to specify output filename when receiving

Options

  • --host <hostname> - Connect to a different host (default: localhost)
  • --port <port> - Connect to a different port (default: 8787)

Protocol Implementation

The CLI follows the exact WebSocket protocol:

  • 64KB chunk size for file transfers
  • JSON metadata (filename and size)
  • EOF marker to signal end of transfer
  • LET_IT_RIP approval mechanism for receiver consent
  • Progress display during transfers (percentage and MB transferred)

Usage Examples

Send a file:

node cli/ystp.js send myfile.txt

Or after running npm link:

ystp send myfile.txt

Output:

✓ Connected to server
✓ Sending file: myfile.txt (12345 bytes)
✓ Share this code with the receiver:
  kitchen-alpha-bravo-charlie-delta-echo

Waiting for receiver to approve...
✓ Receiver approved!
  Progress: [===========>] 95% (11.7 KB / 12.3 KB)
✓ File sent successfully!

Receive a file:

node cli/ystp.js receive kitchen-alpha-bravo-charlie-delta-echo

Or with a custom output filename:

ystp receive kitchen-alpha-bravo-charlie-delta-echo --output downloaded.txt

Output:

✓ Connected to server
✓ File ready: myfile.txt (12345 bytes)
✓ Transfer approved
  Progress: [===========>] 95% (11.7 KB / 12.3 KB)
✓ File received: myfile.txt

Connect to a different server:

ystp send myfile.txt --host myserver.com --port 3000

Changes Made

New Files

  • cli/ystp.js - Full-featured CLI client implementation

Modified Files

  • package.json - Added ws dependency and bin entry point

Installation

After merging, users can:

  1. Install dependencies:
npm install
  1. For global usage (optional):
npm link
ystp send myfile.txt
  1. Or use directly with node:
node cli/ystp.js send myfile.txt

Technical Details

  • Uses ws package for WebSocket client implementation in Node.js
  • Supports both wss:// (secure) and ws:// (insecure) protocols
  • Properly handles binary data chunks (ArrayBuffer) vs text messages (JSON/strings)
  • Graceful error handling and connection management
  • Works seamlessly without any additional setup

    - Add ws package as dev dependency for WebSocket client
    - Create cli/ystp.js with full CLI support:
      * ystp send <file> - sends a file and returns shareable code
      * ystp receive <code> [--output filename] - receives a file using code
    - Features:
      * Configurable host/port with defaults (localhost:8787)
      * Progress display during transfers
      * Proper WebSocket protocol handling (64KB chunks, JSON metadata, EOF marker, LET_IT_RIP approval)
      * Error handling and connection management
    - Add bin entry point to package.json for global ystp command usage
    - CLI can be used via 'node cli/ystp.js' or after npm link as 'ystp'
@drdoc-bot drdoc-bot bot mentioned this pull request Jan 14, 2026
@deathbyknowledge
Copy link
Owner

@drdoc what if I wanted to do npx ystp, would this work as is?

Repository owner deleted a comment from drdoc-bot bot Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants