Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Dec 24, 2025

Summary

This PR implements SSH isolation support for executing commands on remote servers via SSH, addressing issue #31.

The implementation follows the same pattern as existing isolation backends (screen, tmux, docker), providing a consistent user experience while enabling remote command execution.

Implementation Details

Core Features

  • SSH Backend: New runInSsh() function in src/lib/isolation.js
  • Attached Mode: Direct SSH connection with interactive session
  • Detached Mode: Background execution using nohup on remote server with log file capture
  • Endpoint Option: New --endpoint CLI option to specify SSH target (e.g., [email protected])
  • Session Support: Custom session names via --session option

Changes Made

  1. src/lib/isolation.js:

    • Added runInSsh() function implementing both attached and detached modes
    • Updated runIsolated() dispatcher to include SSH backend
    • Exported runInSsh in module exports
  2. src/lib/args-parser.js:

    • Added ssh to VALID_BACKENDS array
    • Added --endpoint option parser (both --endpoint value and --endpoint=value formats)
    • Added endpoint property to wrapperOptions
    • Added validation requiring --endpoint when using SSH isolation
    • Added validation ensuring --endpoint is only used with SSH
  3. src/bin/cli.js:

    • Updated help text to include SSH in isolation backends list
    • Added --endpoint option to help output
    • Added SSH usage example
    • Updated runWithIsolation() to pass endpoint option to isolation backend
    • Added endpoint logging when using SSH isolation
  4. README.md:

    • Updated Process Isolation section with SSH backend
    • Added SSH to Supported Backends table
    • Added --endpoint to Isolation Options table
    • Added SSH usage example
  5. test/isolation.test.js:

    • Added SSH availability check test
    • Added error handling tests for SSH (missing ssh command, missing endpoint)
    • Following the same pattern as screen/tmux/docker tests
  6. test/args-parser.test.js:

    • Added --endpoint option parsing tests
    • Added SSH validation tests
  7. test/ssh-integration.test.js (new file):

    • Comprehensive SSH integration tests
    • Tests attached mode, detached mode, error handling
    • Tests command execution with arguments, environment variables, special characters
    • Designed to run in CI with a local SSH server
  8. .github/workflows/release.yml:

    • Added SSH server setup for Linux integration tests
    • Generates SSH keys, configures passwordless localhost SSH
    • Runs SSH integration tests on Linux

Usage Examples

# Run command on remote server (attached mode)
$ --isolated ssh --endpoint [email protected] -- npm test

# Run in background on remote server (detached mode)
$ --isolated ssh --endpoint [email protected] --detached -- npm start

# Short form with custom session name
$ -i ssh --endpoint user@server -s my-session -d npm start

Testing

All tests pass:

  • ✅ Unit tests for SSH isolation (error handling, availability checks)
  • ✅ Unit tests for --endpoint option parsing
  • ✅ Integration tests with local SSH server (Linux CI)
  • ✅ Linting and formatting checks pass
  • ✅ Pre-commit hooks passed

Notes

  • SSH must be installed on the system (openssh-client on Debian/Ubuntu, openssh on macOS)
  • Detached mode logs are saved to /tmp/<session-name>.log on the remote server
  • Follows the same pattern and conventions as existing isolation backends

Fixes #31


🤖 Generated with Claude Code

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

Issue: #31
@konard konard self-assigned this Dec 24, 2025
Implements SSH isolation backend to execute commands on remote servers via SSH,
similar to existing screen/tmux/docker isolation backends.

Changes:
- Add runInSsh() function in isolation.js with attached and detached modes
- Add SSH to VALID_BACKENDS in args-parser.js
- Add --host option parser for specifying SSH target
- Update CLI to pass host option to isolation backend
- Update help output and README.md with SSH examples
- Add comprehensive unit tests for SSH isolation

Implementation details:
- Attached mode: Direct SSH connection with interactive session
- Detached mode: Background execution using nohup on remote server
- Requires --host option (e.g., [email protected])
- Supports custom session names via --session option

Fixes #31

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

Co-Authored-By: Claude <[email protected]>
@konard konard changed the title [WIP] Support ssh isolation feat: Add SSH isolation support for remote command execution Dec 24, 2025
@konard konard marked this pull request as ready for review December 24, 2025 22:41
@konard
Copy link
Member Author

konard commented Dec 24, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $4.665101 USD
  • Calculated by Anthropic: $2.719040 USD
  • Difference: $-1.946061 (-41.72%)
    📎 Log file uploaded as GitHub Gist (929KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Member Author

konard commented Dec 25, 2025

We should rename --host to --endpoint, install our own SSH server locally in GitHub Actions, and test that we can connect to our own SSH server. These tests should be added in CI, so we will be absolutely sure each and and every feature will work as expected, if there any problem with installing SSH server on the host machine of GitHub Actions - we can just use a docker image with ssh server running.

Think of the most reliable way possible to make sure we test everything.

@konard konard marked this pull request as draft December 25, 2025 09:16
@konard
Copy link
Member Author

konard commented Dec 25, 2025

🤖 AI Work Session Started

Starting automated work session at 2025-12-25T09:16:43.788Z

The PR has been converted to draft mode while work is in progress.

This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback.

- Renamed --host option to --endpoint for better clarity (e.g., user@host format)
- Added comprehensive SSH integration tests with local SSH server in CI
- Updated GitHub Actions workflow to set up SSH server for Linux testing
- Created test/ssh-integration.test.js for real SSH connection testing
- Updated all documentation, tests, and code to use --endpoint

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

Co-Authored-By: Claude <[email protected]>
@konard konard marked this pull request as ready for review December 25, 2025 09:25
@konard
Copy link
Member Author

konard commented Dec 25, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $5.717945 USD
  • Calculated by Anthropic: $3.781167 USD
  • Difference: $-1.936779 (-33.87%)
    📎 Log file uploaded as GitHub Gist (900KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard konard marked this pull request as draft December 26, 2025 21:23
@konard
Copy link
Member Author

konard commented Dec 26, 2025

🤖 AI Work Session Started

Starting automated work session at 2025-12-26T21:23:16.335Z

The PR has been converted to draft mode while work is in progress.

This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback.

…-alive features

Resolved merge conflicts by integrating SSH isolation support with newly added features from main:
- User isolation (--isolated-user, --keep-user)
- Keep-alive option (--keep-alive, -k)
- Docker auto-remove (--auto-remove-docker-container)

Changes:
- README.md: Combined isolation options table with SSH endpoint
- src/bin/cli.js: Merged SSH endpoint logging with user isolation logic
- src/lib/args-parser.js: Added endpoint option alongside user isolation options
- test/args-parser.test.js: Combined SSH endpoint tests with new feature tests

All tests passing locally.
@konard konard marked this pull request as ready for review December 26, 2025 21:31
@konard
Copy link
Member Author

konard commented Dec 26, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $2.405637 USD
  • Calculated by Anthropic: $1.285927 USD
  • Difference: $-1.119710 (-46.55%)
    📎 Log file uploaded as GitHub Gist (666KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard konard merged commit 6c0dfab into main Dec 26, 2025
8 checks passed
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.

Support ssh isolation

2 participants