Repository navigation
feat(cli): add orca ports to list a workspace's detected ports - #32663
manuelmeurer wants to merge 2 commits into
Conversation
Scripts and agents had no way to read the ports Orca already detects for a workspace, so finding a dev server on a random port meant redoing the lsof scan by hand. `orca ports` reuses the host-scoped workspacePorts.scanHost RPC, keeps the rows owned by the current (or --worktree) workspace, and prints port, pid, process, connect host, protocol, how the owner was matched, and the advertised URL. --all shows every listener on that host. An older runtime without scanHost gets an "update Orca" error instead of a raw method_not_found. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Folder-workspace targeting and older-runtime SSH filtering can fail or produce misleading empty results.
3 open issues
What changed in this PR
Adds orca ports so scripts and agents can access Orca’s existing host-scoped port detection without implementing their own scans.
Changes:
- Adds workspace selection, ownership filtering,
--all, and text/JSON output using the existing runtime API. - Handles unavailable scans and runtimes that lack the API.
- Registers the command and adds help, skill documentation, and CLI tests.
| File | Description |
|---|---|
src/main/startup/cli-command-names.ts |
Enables launch redirection for ports. |
src/cli/specs/ports.ts |
Defines command syntax, flags, and examples. |
src/cli/specs/index.ts |
Registers the command specification. |
src/cli/root-help-text-secondary.ts |
Adds command usage to root help. |
src/cli/root-help-text-primary.ts |
Adds the root command summary. |
src/cli/ports-format.ts |
Formats listeners and scan status. |
src/cli/index-ports.test.ts |
Tests selection, output, and error handling. |
src/cli/handlers/ports.ts |
Resolves targets, scans hosts, and filters results. |
src/cli/handler-group-manifest.ts |
Registers the lazy-loaded handler. |
src/cli/command-scoped-flag-help.ts |
Documents --all. |
src/cli/bundled-skill-guides.ts |
Updates bundled CLI documentation. |
src/cli/args.ts |
Excludes browser-page flags from ports. |
skill-guides/orca-cli.md |
Documents port discovery for agents. |
Review effort: Balanced
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
19da759a-a5ca-4cae-abc9-c93756bc0419
📒 Files selected for processing: 13
skill-guides/orca-cli.mdsrc/cli/args.tssrc/cli/bundled-skill-guides.tssrc/cli/command-scoped-flag-help.tssrc/cli/handler-group-manifest.tssrc/cli/handlers/ports.tssrc/cli/index-ports.test.tssrc/cli/ports-format.tssrc/cli/root-help-text-primary.tssrc/cli/root-help-text-secondary.tssrc/cli/specs/index.tssrc/cli/specs/ports.tssrc/main/startup/cli-command-names.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Run inside a native folder, `orca ports` failed with selector_not_found (or picked an enclosing git worktree) because it only searched the worktree list. It now resolves the cwd like `agent launch`, native folders first, and shows that host's listeners. Rows are matched on the owner's path instead of its id, so every instance of a repo-backed folder workspace keeps its ports even though attribution names only the first instance as owner. `--all` adds the worktree id when two owners share a display name, and the skill guide notes that only workspace rows carry `owner` and `advertisedUrl`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thank you @manuelmeurer! This was a well-scoped, clean addition, and it's landing via #33016 with both of your commits kept as-is (authorship preserved). We kept your whole design: the thin CLI over |

ELI5
Orca already knows which ports each workspace is listening on: it shows them on the workspace card, in the status-bar popover and in the Ports panel. Now the CLI can tell you too:
orca portslists them, so a script or agent can find "the dev site of this workspace" without guessing the port.What Changed
Before: the CLI had no way to read the detected ports. A script had to repeat Orca's own scan (
lsof -iTCP -sTCP:LISTEN, thenlsof -d cwdper PID, then compare paths), which is slow and does not work for SSH workspaces.After: a new read-only command.
--worktree, it uses the workspace that contains the current directory, the same wayorca agent launchfinds it (native folders first, then git worktrees).--worktreetakes the usual selectors (active/current,id:,branch:,path:, ...).match=cwdormatch=command), and the URL the dev server printed in an Orca terminal, if Orca saw one:--alllists every listener on that workspace's host, with the owning workspace per row (or(none)for processes Orca could not tie to one), like the status-bar popover. A native folder workspace always gets this view, because Orca only ties listeners to repo-backed workspaces. When two owners share a display name, the row adds the worktree id.unavailableReasoninstead of an empty list.--jsonprints the usual{ id, ok, result, _meta }envelope, withresultin theWorkspacePortHostScanResultshape (platform,scannedAt,ports,unavailableReason?,executionHostId), keeping only the selected workspace's rows unless--allis set. Example:orca ports --json | jq -r '.result.ports[0].advertisedUrl'.Mechanism: the handler calls the existing host-scoped
workspacePorts.scanHost({ worktree })RPC from #27188, so the runtime decides which host the workspace runs on. The CLI then asksworktree.showfor the workspace path, keeps the rows whoseowner.pathmatches, and sorts them by port. Matching on the path rather than the id keeps the rows for every instance of a repo-backed folder workspace, since those instances share one path and attribution names only the first as owner. No new RPC, no runtime changes. The command is registered in the spec list, handler manifest, help text, the launch-redirect command names, and theorca-cliskill guide.Why
Many dev servers (Puma with port 0, Vite when its default port is taken) pick a random port and write it nowhere. Orca already does the hard part, including SSH hosts, so exposing its result is simpler and more reliable than each script redoing the scan. Filtering on the CLI side, rather than adding a per-workspace RPC, keeps this compatible with every runtime that already ships
scanHost.Linked Issue
Fixes #32632
Visual Proof
N/A: CLI-only change, no UI. Sample text output is in "What Changed" above.
Testing
New
src/cli/index-ports.test.tsruns the command throughmain(): default workspace from the cwd (git worktree, standalone native folder, native folder nested in a git worktree), a folder workspace instance that is not the recorded owner, duplicate owner names under--all, explicit selector resolved viaworktree.show, text rows with and without--all, the JSON envelope, an unavailable scan, and the "update Orca" error when an older runtime answersmethod_not_found.pnpm typecheckandpnpm lintpass; the changed-code quality gate reports 0 new findings.pnpm test src/cli src/main/startuppassed on the first commit (4 startup tests timed out at 30s while the typecheck ran at the same time; they pass when run alone). After the follow-up commit,src/cli/index-ports.test.ts,index-agent-launch.test.ts, andhandler-group-manifest.test.tspass; the remainingsrc/clifailures on my machine are in the launch/serve tests, which spawn local Orca binaries and check the real profile path, and do not touch this change.Built the CLI (
pnpm run build:cli) and checkedorca ports --helpand unknown-flag handling. I did not run it against a live Orca runtime.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Written with Claude Code (Claude Opus 5.5), reviewed by me.
Review
Agent skill upstream boundary
Notes
workspacePorts.scanHostgetsincompatible_runtimewith "This Orca runtime cannot list workspace ports yet. Update Orca and try again." rather than a rawmethod_not_found.--environment/--pairing-code, pass an explicit server-side selector, as with other commands;currentis refused there.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Fixes #32632