Skip to content

fix(cli): scope worktree ls and archive by cwd#1652

Open
everton-dgn wants to merge 3 commits into
getpaseo:mainfrom
everton-dgn:codex/fix-worktree-ls-cwd
Open

fix(cli): scope worktree ls and archive by cwd#1652
everton-dgn wants to merge 3 commits into
getpaseo:mainfrom
everton-dgn:codex/fix-worktree-ls-cwd

Conversation

@everton-dgn

Copy link
Copy Markdown
Contributor

Summary

  • Pass the current or explicit cwd into worktree list requests from the CLI.
  • Expose --cwd on worktree ls and worktree archive for parity with worktree create.
  • Add focused CLI tests for ls and archive cwd routing.

Why

Closes #1649.

paseo worktree ls sent an empty worktree-list request, while the daemon requires cwd or repoRoot. That made the command fail immediately with cwd or repoRoot is required.

worktree archive used the same list request to resolve its target before archiving, so it needed the same cwd scope fix.

Testing

  • npm run build:server
  • npx vitest run packages/cli/src/commands/worktree/ls.test.ts packages/cli/src/commands/worktree/archive.test.ts --bail=1
  • npm run lint -- packages/cli/src/commands/worktree/ls.ts packages/cli/src/commands/worktree/index.ts packages/cli/src/commands/worktree/archive.ts packages/cli/src/commands/worktree/archive.test.ts packages/cli/src/commands/worktree/ls.test.ts
  • npm run typecheck --workspace=@getpaseo/cli
  • npm run build --workspace=@getpaseo/cli
  • npm run format:check:files -- packages/cli/src/commands/worktree/ls.ts packages/cli/src/commands/worktree/index.ts packages/cli/src/commands/worktree/archive.ts packages/cli/src/commands/worktree/archive.test.ts packages/cli/src/commands/worktree/ls.test.ts
  • node packages/cli/bin/paseo --json worktree ls --cwd /Users/everton/www/ai/paseo --host 127.0.0.1:6767 returned [] with exit 0

@everton-dgn everton-dgn marked this pull request as ready for review June 21, 2026 21:46
@greptile-apps

greptile-apps Bot commented Jun 21, 2026

Copy link
Copy Markdown

Greptile Summary

Fixes worktree ls and worktree archive crashing with cwd or repoRoot is required by passing the resolved working directory into every getPaseoWorktreeList call, and exposes --cwd on both subcommands for parity with worktree create.

  • ls.ts and archive.ts each grow a getCwd injected dep and resolve cwd from options.cwd ?? deps.getCwd(), defaulting to process.cwd() in the public entry points.
  • index.ts registers --cwd <path> on ls and archive, matching the existing flag on create.
  • New and updated tests use the injected getCwd seam (no global spy) and assert that the exact resolved cwd reaches getPaseoWorktreeList.

Confidence Score: 5/5

Safe to merge — the fix is minimal, the two changed code paths are symmetric, and tests confirm the cwd reaches the daemon in both explicit and fallback modes.

All five changed files contain no logic bugs: the cwd resolution is correctly expressed as options.cwd ?? deps.getCwd(), the getCwd seam defaults to process.cwd() in production callers, the tests confirm both explicit and fallback paths without touching process globals, and the --cwd option is wired consistently across all three worktree subcommands.

No files require special attention.

Important Files Changed

Filename Overview
packages/cli/src/commands/worktree/ls.ts Extracts testable runLsCommandWithDeps from runLsCommand, adds cwd option resolution, and passes cwd to getPaseoWorktreeList. Clean seam addition with no pre-existing logic disturbed.
packages/cli/src/commands/worktree/archive.ts Adds getCwd to deps interface and resolves cwd from option or fallback, then passes it to the list request. Also fixes path import to use node:path. Symmetric with the ls.ts change.
packages/cli/src/commands/worktree/index.ts Adds --cwd <path> option to ls and archive subcommands, matching the already-present option on create. Straightforward registration change.
packages/cli/src/commands/worktree/ls.test.ts New test file covering cwd routing for ls. Uses injected getCwd dep rather than global spy, consistent with the port-and-adapter pattern already used for connectToDaemon.
packages/cli/src/commands/worktree/archive.test.ts Updated archive tests to capture listCalls and assert correct cwd is passed to the daemon, replacing the previous global spy approach. Covers both explicit-cwd and getCwd-fallback paths.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant CLI as CLI (ls / archive)
    participant Cmd as runLsCommandWithDeps / runArchiveCommandWithDeps
    participant Deps as deps.getCwd()
    participant Daemon as DaemonClient

    CLI->>Cmd: options (host, cwd?, ...)
    alt options.cwd provided
        Cmd->>Cmd: "cwd = options.cwd"
    else fallback
        Cmd->>Deps: getCwd()
        Deps-->>Cmd: process.cwd()
    end
    Cmd->>Daemon: connectToDaemon(host)
    Daemon-->>Cmd: client
    Cmd->>Daemon: "getPaseoWorktreeList({ cwd })"
    Daemon-->>Cmd: "{ worktrees, error }"
    Note over Cmd,Daemon: archive also calls archivePaseoWorktree after resolution
    Cmd-->>CLI: result
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant CLI as CLI (ls / archive)
    participant Cmd as runLsCommandWithDeps / runArchiveCommandWithDeps
    participant Deps as deps.getCwd()
    participant Daemon as DaemonClient

    CLI->>Cmd: options (host, cwd?, ...)
    alt options.cwd provided
        Cmd->>Cmd: "cwd = options.cwd"
    else fallback
        Cmd->>Deps: getCwd()
        Deps-->>Cmd: process.cwd()
    end
    Cmd->>Daemon: connectToDaemon(host)
    Daemon-->>Cmd: client
    Cmd->>Daemon: "getPaseoWorktreeList({ cwd })"
    Daemon-->>Cmd: "{ worktrees, error }"
    Note over Cmd,Daemon: archive also calls archivePaseoWorktree after resolution
    Cmd-->>CLI: result
Loading

Reviews (3): Last reviewed commit: "Merge branch 'main' into codex/fix-workt..." | Re-trigger Greptile

Comment thread packages/cli/src/commands/worktree/ls.test.ts Outdated
@everton-dgn

Copy link
Copy Markdown
Contributor Author

@boudra flagging this for priority because it fixes a released CLI regression in 0.1.98.

paseo worktree ls currently fails immediately with cwd or repoRoot is required because the CLI sends an empty worktree-list request. This PR scopes both worktree ls and the archive preflight list request with the current or explicit cwd, keeps the fix CLI-only, and includes focused tests plus a manual runtime check against the daemon.

Related issue: #1649.

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.

paseo worktree ls always fails with "cwd or repoRoot is required" in 0.1.98

1 participant