Skip to content

✨ Add ws-cli editor commands for editor-state IPC#16

Merged
bdsoha merged 1 commit into
mainfrom
feature/editor-commands
Jun 29, 2026
Merged

✨ Add ws-cli editor commands for editor-state IPC#16
bdsoha merged 1 commit into
mainfrom
feature/editor-commands

Conversation

@bdsoha

@bdsoha bdsoha commented Jun 29, 2026

Copy link
Copy Markdown
Member

What

Adds a ws-cli editor command group that talks to the workspace VS Code
extension over the internal IPC socket ($WS__INTERNAL_IPC_SOCKET),
mirroring the existing clip pasteGET /clipboard pattern.

Command Endpoint
editor list GET /editors
editor diagnostics [--uri] GET /diagnostics
editor selection GET /selection (204 → empty)
editor open <file> POST /open

editor open flags: --reuse-window (default) / --new-window (-n,
mutually exclusive), --preview, --selection LINE:COL[-LINE:COL] (1-based).

Notes

  • SSH: the whole editor group hard-blocks under SSH
    (env.IsSSHSession()). The socket is reachable from an SSH shell, but
    there is no editor surface (the browser VS Code) to act on.
  • Contract: golden fixtures under internals/editor/testdata/*.json
    pin the request/response JSON shapes. The Go test decodes them with
    DisallowUnknownFields so a drift fails fast.
  • DRY: extracted config.Bootstrap() shared by the root and editor
    PersistentPreRunE hooks (cobra runs only the nearest one).
  • No socket-path code — resolved purely via the existing
    WS__INTERNAL_IPC_SOCKET env var.

Scope / sequencing

This is the consumer half of a two-repo change. The matching
extension routes (workspace/src/ws-extension/lib/editor.js), the
open/openn shim rewire, and the live round-trip test ship in a
separate workspace PR that pins this binary. Until that lands, the new
commands report a friendly "workspace editor" error.

Tests

go build / go vet / gofmt clean. New unit tests (real unix-socket
stub) cover request shape, JSON passthrough, 204, non-2xx + server-down
errors, the --new-window body, the contract fixtures, the SSH
short-circuit, and --selection parsing.

@bdsoha bdsoha force-pushed the feature/editor-commands branch 4 times, most recently from a95d898 to 58ebc5f Compare June 29, 2026 09:57
New `editor` group talks to the workspace VS Code extension over the
internal IPC socket, mirroring `clip paste`:

- `editor list` / `diagnostics [--uri]` / `selection` — styled output
  (tables / key-value via internals/styles) like the `show`/`info`
  family; `--raw` emits the verbatim JSON response.
- `editor open <file>` — `--reuse-window` (default) / `--new-window`,
  `--preview`, `--selection LINE:COL[-LINE:COL]`.

The whole group hard-blocks under SSH (`env.IsSSHSession()`): the socket
is reachable but there is no editor surface to act on.

Golden fixtures under `internals/editor/testdata` pin the cross-repo
JSON contract. Extract `config.Bootstrap()` shared by the root and
editor pre-run hooks.

This is the consumer half — the extension routes ship separately, so
the commands report a friendly "workspace editor" error until then.
@bdsoha bdsoha force-pushed the feature/editor-commands branch from 58ebc5f to 81fa487 Compare June 29, 2026 10:10
@bdsoha bdsoha merged commit 442fef6 into main Jun 29, 2026
3 checks passed
@bdsoha bdsoha deleted the feature/editor-commands branch June 29, 2026 10:19
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.

1 participant