Tasksd is a daemon providing JSON-RPC API to spawn processes. As a daemon it detaches execution from the client allowing the spawned process to run even if the client is down.
It is created as a companion for Neovim but it doesn't have anything specific for Neovim. Tasksd can be used as a general purpose terminal multiplexer with an API.
Warning
Tasksd is still under development. There could be bugs, API-breaking changes, and any other sort of instability.
Requirements:
- Linux or macOS (Windows is not supported)
- Rust 1.97 or newer
For now cargo is the easiest way to install tasksd:
cargo install --git https://github.com/kuznetsss/tasksdOnly one parameter - unix socket path is required to start tasksd, e.g.:
tasksd --unix-socket-path /tmp/tasksd_socketOnce tasksd is started it will listen for unix socket connections. See API doc on how to interact with tasksd.
Press Ctrl-C or send SIGINT to start graceful shutdown (shutting down all the running tasks before exiting tasksd itself).
Second Ctrl-C (or SIGINT) will force tasksd to exit immediately.
Use --help flag to see all the available options.
- tasksd is a daemon - tasks keep running after client disconnects
- (Not implemented yet) PTY is allocated for each task - spawned command sees a real terminal
- output capture - each task output is captured into a ring buffer (by default tasksd keeps last 10 000 lines)
- streaming JSON-RPC API - clients subscribe to live output and exit notifications over a unix socket
- list of tasks - clients can get a list of running or recently finished processes
API is documented in docs/API.md.
A few reasons:
- I was curious to try applying the idea of LSP to task running
- I didn't like any existing Neovim code runners and I wanted to shift as much logic as possible from Lua to Rust
0.3.0 or later:
- Switch output stream to Vec
- Implement different task type PtyTask: - It should render screen from stream of bytes from pty using (libghostty-vt or vt100) - Share screen state via watch channel - Each subscriber calculates diff and sends it to the client
- For piped task reading should be similar to pty_reader: after child process finished drain buffers until got blocking and exit. This will prevent tasksd from hanging on detached grand child processes but it will stop capturing detached process' output
- Separate stdout and stderr in output notifications and in
OutputBuffer - Use
thiserrorcrate - Tasks chains
- Limit log file size
- Support graceful shutdown by
SIGTERM - Add a parameter to adjust RecentFinishedTasks size
Future ideas:
- Add suggestion module (history, runnables, tasks.json)
- Output search/filter
- TCP sockets support
- pty-process crate for an example of how to open ptys using rustix