Skip to content

refactor: decouple kild CLI from kild-daemon server embedding#351

Merged
Wirasm merged 3 commits into
mainfrom
kild/324-decouple-cli-daemon
Feb 11, 2026
Merged

refactor: decouple kild CLI from kild-daemon server embedding#351
Wirasm merged 3 commits into
mainfrom
kild/324-decouple-cli-daemon

Conversation

@Wirasm

@Wirasm Wirasm commented Feb 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Make kild-daemon a standalone binary instead of embedding the server as a library dependency in the CLI crate
  • CLI now spawns kild-daemon as a subprocess for both foreground (--foreground) and background modes
  • Auto-start in kild-core discovers the daemon binary as a sibling executable (same pattern as kild-tmux-shim)
  • Removes tokio and kild-daemon dependencies from the CLI crate

Test plan

  • cargo fmt --check passes
  • cargo clippy --all -- -D warnings passes (zero warnings)
  • cargo test --all passes (all tests green)
  • cargo build --all succeeds (both kild and kild-daemon binaries produced)
  • Manual: kild daemon start starts daemon in background
  • Manual: kild daemon start --foreground spawns kild-daemon with inherited stdio
  • Manual: kild daemon stop / kild daemon status work unchanged
  • Manual: auto-start triggers kild-daemon binary spawn

Closes #324

@Wirasm

Wirasm commented Feb 11, 2026

Copy link
Copy Markdown
Owner Author

PR Review Summary

Critical Issues (1 found)

Agent Issue Location
code-reviewer Binary discovery logic duplicated 3 times (autostart.rs, daemon.rs, handler.rs) — should be a shared utility autostart.rs:31-47, daemon.rs:4-18, handler.rs

Important Issues (1 found)

Agent Issue Location
code-reviewer CLI background daemon polling loop lacks child-process crash detection that autostart.rs has — could wait full 5s timeout when daemon crashes immediately daemon.rs:74-85 vs autostart.rs:62-119

Suggestions (3 found)

Agent Suggestion Location
silent-failure-hunter Add structured logging to kild-daemon/main.rs run() for config load vs runtime init vs server failures main.rs:21-30
silent-failure-hunter Log spawn success with PID before entering socket readiness loop daemon.rs:62-67
silent-failure-hunter Add debug logging inside CLI socket readiness loop for visibility daemon.rs:74-85

Documentation Updates

  • CLAUDE.md — Updated architecture section to reflect kild-daemon as standalone binary (committed to PR branch)

Strengths

  • Clean decoupling — CLI no longer depends on tokio or kild-daemon crate
  • Autostart binary discovery follows the same sibling-binary pattern as kild-tmux-shim
  • Error messages include binary path and actionable guidance ("Run 'cargo build --all'")
  • Autostart polling loop has excellent crash detection and differentiated timeout errors

Verdict: NEEDS FIXES

Recommended Actions

  1. Extract binary discovery into a shared find_sibling_binary(name: &str) utility in kild-core (eliminates 3x duplication, also benefits existing shim discovery in handler.rs)
  2. Consider adding child-process crash detection to CLI background daemon start loop (or document why it's intentionally simpler)
  3. Optionally: add structured logging in daemon main.rs and spawn success events

Make kild-daemon a standalone binary instead of embedding it as a library
dependency in the CLI. The CLI now spawns kild-daemon as a subprocess for
both foreground and background modes, and auto-start discovers the binary
as a sibling executable.

This removes tokio and kild-daemon dependencies from the CLI crate,
resulting in a smaller binary and cleaner dependency separation.

Closes #324
Clarify that kild-daemon is now a standalone binary spawned as a subprocess
by the CLI, rather than being embedded as a library dependency. Auto-start
discovers the binary as a sibling executable.
…startup

- Extract binary discovery logic into `daemon::find_sibling_binary()` in
  kild-core, eliminating duplication across autostart.rs, daemon.rs (CLI),
  and handler.rs (shim)
- Add child process crash detection to CLI background daemon start loop
  (matching autostart.rs behavior)
- Add debug logging to CLI daemon socket readiness loop
- Add structured error logging to kild-daemon main.rs for config load,
  runtime init, and server failures
@Wirasm Wirasm force-pushed the kild/324-decouple-cli-daemon branch from bdf60a5 to 6e7664f Compare February 11, 2026 09:51
@Wirasm Wirasm merged commit 3bb80fd into main Feb 11, 2026
6 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.

refactor: decouple kild CLI from kild-daemon server embedding

1 participant