Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Sep 10, 2025

🚀 Feature: LiNo Protocol Server Mode (LINO API)

This PR implements a WebSocket server mode for the link-cli tool, enabling remote execution of LiNo queries through a RESTful API.

📋 Issue Reference

Closes #30

✨ Features Added

🖥️ Server Mode Options

  • --server: Start WebSocket server mode
  • --port PORT (alias -p): Specify listening port (default: 8080)

🌐 WebSocket API

  • Endpoint: ws://localhost:PORT/ws
  • Input: LiNo query as plain text
  • Output: Structured JSON response with query results

📊 JSON Response Format

{
  "query": "() ((1 1))",
  "changes": [
    {
      "before": "",
      "after": "(1: 1 1)"
    }
  ],
  "links": [
    "(1: 1 1)"
  ]
}

💡 Usage Examples

Start server on default port:

clink --server

Start server on custom port with database:

clink --server --port 3000 --db mydata.links

JavaScript client example:

const ws = new WebSocket('ws://localhost:8080/ws');
ws.onopen = () => ws.send('() ((1 1))'); // Create link
ws.onmessage = (event) => {
    const response = JSON.parse(event.data);
    console.log(response.changes, response.links);
};

🔧 Technical Implementation

  • ASP.NET Core Minimal APIs for lightweight WebSocket server
  • Full backward compatibility - existing CLI functionality unchanged
  • Concurrent query processing with proper error handling
  • InvocationContext pattern to handle 10+ command-line parameters
  • Dependency injection for proper resource management

🧪 Testing

  • Comprehensive unit tests for WebSocket functionality
  • Integration tests for CLI parameter handling
  • Error handling tests for malformed queries
  • Multi-client connection tests

📚 Documentation

  • Updated README with complete API documentation
  • Added JavaScript client examples
  • Updated developer section with server mode examples
  • Included troubleshooting and usage patterns

⚡ Performance & Reliability

  • Efficient WebSocket handling with proper connection lifecycle
  • Async/await patterns throughout for non-blocking operations
  • Graceful error handling with structured error responses
  • Resource cleanup on connection close

🔄 Version & Compatibility

  • Version bumped to 2.3.0 (new major functionality)
  • Full backward compatibility maintained
  • No breaking changes to existing CLI interface

🎯 Ready for Review

This PR is now complete and ready for review. All tests pass, documentation is updated, and the implementation follows established patterns in the codebase.

🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #30
@konard konard self-assigned this Sep 10, 2025
konard and others added 2 commits September 10, 2025 15:42
Implements WebSocket server functionality to support remote LiNo query execution via a RESTful API.

Features:
- New --server option to start WebSocket server
- New --port option to specify listening port (default: 8080)
- WebSocket endpoint at /ws accepting LiNo queries
- Structured JSON responses with query results, changes, and current link state
- Full backward compatibility with existing CLI functionality
- Comprehensive test coverage for server functionality
- Updated documentation with API examples and usage instructions

The server processes LiNo queries sent via WebSocket and returns JSON responses containing:
- Original query that was processed
- Array of before/after changes made
- Current state of all links in the database

Version bumped to 2.3.0 to reflect new major functionality.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@konard konard changed the title [WIP] LiNo protocol server mode (LINO API) Add LiNo protocol server mode (LINO API) Sep 10, 2025
@konard konard marked this pull request as ready for review September 10, 2025 13:17
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.

LiNo protocol server mode (LINO API)

2 participants