worktrunk icon indicating copy to clipboard operation
worktrunk copied to clipboard

[Question] is it possible to use worktrunk as a library to integrate in another rust based CLI ?

Open EwenSellitto opened this issue 8 months ago • 3 comments

Well, everything is in the title 😆!

I want to try to make a TUI alternative to Codex UI and T3Code with the same kind of features and Docker integration. I would need good worktree support for that, and worktrunk is the best out of all the CLIs I have used. I'm not that experienced in Rust, and I want to use this project to learn as I go; I will (of course) use agents to help me or write most of the code.

Thank you very much !

EwenSellitto avatar Mar 11 '26 12:03 EwenSellitto

Thanks for reaching out, and cool project idea!

Worktrunk does expose a library crate (worktrunk) alongside the CLI binary — the [lib] target publishes public modules for git operations, config, shell integration, and more. So cargo add worktrunk would compile.

However, the library API is explicitly not stable — from src/lib.rs:

The library API is not stable. If you're building tooling that integrates with worktrunk, please open an issue to discuss your use case.

In practice this means internal types, function signatures, and module structure can change between releases without notice. It's designed as a CLI tool first, with the library target mainly serving the project's own binaries and tests.

For your TUI project, a few options to consider:

  1. Use worktrunk as a library anyway — it would work, but expect breakage on updates since there are no stability guarantees on the Rust API.
  2. Shell out to wt — wt list --format=json provides structured JSON output that's part of the stable external interface. This is more resilient to internal changes.
  3. Use git2 / gix directly — for worktree operations, you could use the same git libraries that worktrunk depends on, giving you full control.

I'll leave it to a maintainer to weigh in on whether stabilizing parts of the library API for external consumers is something they'd consider. Good luck with the project!

worktrunk-bot avatar Mar 11 '26 12:03 worktrunk-bot

I think @worktrunk-bot summarized it well. if you need things made pubic, let us know!

max-sixty avatar Mar 11 '26 16:03 max-sixty

Yes ! Thank you very much :)

EwenSellitto avatar Mar 11 '26 16:03 EwenSellitto