Skip to content

feat: pure .ws parser with zod validation (#40) - #43

Merged
rwrife merged 1 commit into
mainfrom
feat/issue-40-ws-parser
Jul 11, 2026
Merged

feat: pure .ws parser with zod validation (#40)#43
rwrife merged 1 commit into
mainfrom
feat/issue-40-ws-parser

Conversation

@rwrife

@rwrife rwrife commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Closes #40 (partial — first slice)

What changed

  • New src/core/ws.ts — pure .ws file parser with zero VS Code / undici dependencies. Returns a zod-validated ParsedWebSocketRequest (url, scheme, headers, directives, send/recv frames).
  • 13 new vitest cases in test/ws.test.ts covering target parsing, ws/wss schemes, directive + header preamble, interleaved --- send/--- recv frames, multi-line frame bodies, case-insensitive markers, and every error path.

Format shipped

# @name subscribeToTicker
# @auth my-bearer
wss://stream.example.com/v1/ticker?symbol=BTC
Authorization: Bearer {{token}}
Sec-WebSocket-Protocol: json

--- send
{"op":"subscribe","channel":"trades"}
--- recv
{"op":"subscribed"}

Mirrors the .grpc precedent: dedicated file kind, pure parser first, thin extension layer on top later.

What's left for #40 (follow-up PRs)

  • src/core/wsClient.tsundici-backed WS wrapper (thin, no VS Code)
  • src/extension/wsView.ts — Preact webview with frame log + send box
  • .ws file association + syntax highlighting (reuse header grammar)
  • Tree view integration + ▶ Open WebSocket codelens
  • Auth reuse (bearer/basic/apiKey/mTLS) on the handshake
  • "Save transcript" to .requests/.history/
  • README example

Keeping this PR small and reviewable per PLAN.md philosophy.

Verification

  • npm run lint
  • npm run typecheck
  • npm run test:unit ✅ (366 tests, +13)

First shippable slice of WebSocket support: pure parser in src/core/ws.ts, no VS Code or undici deps, plus 13 vitest cases covering target, headers, directives, interleaved send/recv frames, multi-line bodies, and error paths. Extension wiring, undici WS client, and webview land in follow-up PRs.
@rwrife
rwrife merged commit bf9a0ef into main Jul 11, 2026
8 checks passed
@rwrife
rwrife deleted the feat/issue-40-ws-parser branch July 11, 2026 09:01
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.

[feature] WebSocket (.ws) request support

1 participant