Skip to content

fix: grove up should generate nexus.yaml directly without shelling out to nexus CLI #196

@windoliver

Description

@windoliver

Problem

grove up relies on nexus init (external CLI binary) to generate nexus.yaml. This breaks when:

  1. nexus CLI isn't on PATH or is broken — e.g., /opt/anaconda3/bin/nexus shadows the real one, nexus --version fails
  2. Multiple worktrees share the same Nexusnexus init hardcodes data_dir to ~/.grove/nexus-data and default port 2026, so all worktrees connect to the same instance, leaking sessions across unrelated workspaces

Equivalent issue on koi: windoliver/koi#1129

Current state (partial fix in PR #185)

PR #185 moved the health-check fast path before the CLI check in ensureNexusRunning(), so existing running Nexus instances are discovered even when the CLI binary is broken. But this only works when Nexus is already running — cold start still fails.

Proposed fix

  1. Generate nexus.yaml directly in startServices() when it's missing, instead of shelling out to nexus init. The file is simple YAML with known fields.

  2. Derive port from workspace path (e.g., hash of cwd mapped to ephemeral range 10000-60000) so each worktree gets a stable unique port without collisions.

  3. Set data_dir to worktree-local path so each worktree has isolated Nexus data — no cross-worktree session leaking.

  4. discoverRunningNexus should verify data_dir matches before reusing a running Nexus instance. Currently it only checks if the port responds healthy, which can match another worktree's Nexus.

Files to change

  • src/cli/nexus-lifecycle.ts — generate YAML directly, derive port, per-worktree data_dir
  • src/shared/service-lifecycle.ts — fallback YAML generation when CLI unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions