Skip to content

Add CLI tool for River to enable easier testing and debugging #26

@sanity

Description

@sanity

Overview

Create a command-line interface for River that enables rapid testing of core functionality, particularly room creation and invitation flows that are currently failing on the live network.

Motivation

Currently, debugging River issues requires using the browser UI, which makes it difficult to:

  • Reproduce bugs quickly
  • Create automated tests
  • See detailed debug information about contract operations
  • Test specific scenarios in isolation

A CLI tool would provide:

  1. Direct access to River functionality without UI dependencies
  2. Better visibility into Freenet contract operations (PUT/GET)
  3. Scriptable interface for automated testing
  4. Alternative interface that some power users might prefer

Proposed Design

Core Commands

Room Management

river room create --name "Test Room" --description "Debug room"
river room list
river room join <room-id>
river room leave <room-id>
river room info <room-id>

Messaging

river message send <room-id> "Hello world"
river message list <room-id> [--last N]
river message stream <room-id>  # Real-time updates

Member Management

river invite create <room-id> --note "Join our test"
river invite accept <invitation-code>
river member list <room-id>
river member add <room-id> <member-id>

Debugging Commands

river debug contract-put <room-id>  # Test PUT operation
river debug contract-get <room-id>  # Test GET operation
river debug websocket               # Show WebSocket traffic
river debug sync-state             # Show synchronization state

Technical Requirements

  1. Shared Core Logic: Reuse River's existing data structures and Freenet integration from the UI codebase
  2. Configuration Support:
    • Custom Freenet node URLs
    • WebSocket timeout settings
    • Log level configuration
  3. Output Formats:
    • Human-readable (default)
    • JSON (for scripting with tools like jq)
    • Debug mode with full contract data
  4. Error Handling: Clear error messages with debugging suggestions

Example Usage

# Create a room and capture the ID
ROOM_ID=$(river room create --name "Test" --json  < /dev/null |  jq -r .room_id)

# Create an invitation
INVITE=$(river invite create $ROOM_ID --json | jq -r .invitation_code)

# Try to accept the invitation (currently failing on live network)
river --debug invite accept $INVITE

Implementation Priority

Start with the minimal set needed to reproduce current bugs:

  1. room create - Test PUT operations
  2. invite create / invite accept - Test GET operations
  3. --debug flag for verbose contract operation logging

Success Criteria

  1. Can reproduce the room invitation bug without browser UI
  2. Provides clear visibility into PUT/GET contract operations
  3. Shows exact timeout points and error messages
  4. Enables rapid iteration when testing fixes

Future Enhancements

  • Import/export room state for debugging
  • Performance testing commands
  • Batch operations for stress testing
  • Contract state diffs between operations
  • Network topology visualization

Related Issues

  • This would help debug the ongoing invitation bug where PUT/GET operations timeout on the live network
  • Would enable creation of automated integration tests for River

Technical Notes

  • Use tokio for async runtime (consistent with River UI)
  • Share contract types and serialization logic with UI
  • Consider using clap for command parsing
  • Structured logging with tracing crate

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions