fix(cli): scope worktree ls and archive by cwd#1652
Conversation
|
| 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
%%{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
Reviews (3): Last reviewed commit: "Merge branch 'main' into codex/fix-workt..." | Re-trigger Greptile
|
@boudra flagging this for priority because it fixes a released CLI regression in 0.1.98.
Related issue: #1649. |
Summary
--cwdonworktree lsandworktree archivefor parity withworktree create.lsandarchivecwd routing.Why
Closes #1649.
paseo worktree lssent an empty worktree-list request, while the daemon requirescwdorrepoRoot. That made the command fail immediately withcwd or repoRoot is required.worktree archiveused the same list request to resolve its target before archiving, so it needed the same cwd scope fix.Testing
npm run build:servernpx vitest run packages/cli/src/commands/worktree/ls.test.ts packages/cli/src/commands/worktree/archive.test.ts --bail=1npm 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.tsnpm run typecheck --workspace=@getpaseo/clinpm run build --workspace=@getpaseo/clinpm 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.tsnode packages/cli/bin/paseo --json worktree ls --cwd /Users/everton/www/ai/paseo --host 127.0.0.1:6767returned[]with exit 0