3.8 KiB
3.8 KiB
| title | state | created_at | updated_at |
|---|---|---|---|
| CLI: make insomnia crate own binary entrypoint and CLI dispatch | closed | 2026-05-31T11:19:56Z | 2026-05-31T13:20:02Z |
Background
The single-binary migration currently exposes the installed command as insomnia, but the binary target and CLI dispatch are still owned by the tui package (cargo run -p tui -- ..., crates/tui/src/main.rs). The helper crate now named insomnia was originally introduced for Pod runtime command resolution, which creates a responsibility mismatch.
The desired architecture is that the insomnia crate owns the product CLI and binary entrypoint. The tui and pod crates should be libraries with no main.rs, and CLI/tool subcommand routing should happen at the insomnia boundary.
Requirements
- Move product CLI ownership to the
insomniacrate:- binary target
insomniabelongs to package/crateinsomnia; - CLI argument parsing and top-level mode/subcommand dispatch live in
insomnia; - development entrypoint becomes
cargo run -p insomnia -- ....
- binary target
- Make
tuia library implementation crate rather than binary/CLI owner.tuishould expose an API for launching the terminal UI with already-parsed options/configuration.tuishould not owninsomnia pod ...dispatch or headless CLI tool routing.
- Keep
podas a library runtime crate with no dependency oninsomnia.podmay expose its runtime entrypoint/parser API forinsomnia pod ..., but it must not know the product CLI crate.
- Move or relocate
PodRuntimeCommandresponsibility out of the currentinsomniahelper role if needed to avoid inverted dependencies.pod -> insomniais not acceptable.- Prefer passing the runtime command from the top-level CLI/orchestrating layer into TUI/client spawn paths.
- If a shared type is still needed, place it in a lower-level crate whose responsibility is process/client mechanics, not in the product CLI crate by accident.
- CLI tools/headless commands should be routed by
insomnia, not bytui.- Examples:
memory lint,pod ..., future non-TUI commands.
- Examples:
- Preserve observable behavior:
- installed command remains
insomnia; insomnia -r,insomnia --multi,insomnia <podname>, andinsomnia pod ...keep their behavior;- no
insomnia-podalias is reintroduced; - Pod runtime remains a separate process.
- installed command remains
- Do not add compatibility layers for
cargo run -p tui -- ...; updating docs/dev commands is sufficient.
Non-goals
- Renaming the user-facing command away from
insomnia. - Merging Pod runtime into the TUI process.
- Reintroducing
INSOMNIA_POD_COMMANDor test-only env command overrides. - Redesigning Pod protocol, profile semantics, or manifest semantics.
- Broad TUI module-layout refactors beyond what is necessary to make
tuilibrary-callable.
Acceptance criteria
cargo run -p insomnia -- --helpandcargo run -p insomnia -- pod --helpwork as the main development entrypoints.- Package
tuino longer owns a binarymain.rsentrypoint, or any remaining binary target is explicitly temporary and not the product CLI owner. - No active code path requires
pod -> insomniaortui -> insomniadependency. insomniacrate owns top-level CLI parsing/dispatch for TUI launch, Pod runtime launch, and headless CLI tools.- Pod spawn/restore still launches runtime subprocesses as
insomnia pod ...through typed command injection from the top-level owner. - Nix/package outputs still expose only
bin/insomnia. - Current docs/dev instructions no longer tell developers to use
cargo run -p tui -- ...as the primary product CLI path. - Focused CLI/parser/spawn tests,
cargo fmt --check, relevantcargo check/cargo test,nix build .#insomniaif packaging changed,./tickets.sh doctor, andgit diff --checkpass.