Skip to content

feat: point Try It panels at localhost with editable port, format all API output#36

Merged
BunsDev merged 1 commit into
mainfrom
docs/openapi-localhost-port
Jul 21, 2026
Merged

feat: point Try It panels at localhost with editable port, format all API output#36
BunsDev merged 1 commit into
mainfrom
docs/openapi-localhost-port

Conversation

@BunsDev

@BunsDev BunsDev commented Jul 21, 2026

Copy link
Copy Markdown
Member

What

Server URL → localhost, never docs.opencoven.ai

  • OpenAPI servers is now http://localhost:{port}/api/v1 with an editable port variable (default 3000) — the playground server selector renders it as an input (persisted per-reader). 3000 matches the documented daemon standard coven daemon serve --tcp 127.0.0.1:3000.
  • Previously the relative /api/coven-proxy/api/v1 server resolved against the docs origin, so hosted pages displayed and targeted https://docs.opencoven.ai/....

Proxy bridge (both app/api/coven-proxy routes + lib/coven-proxy-dial.ts)

  • Socket-first dial ($COVEN_HOME/coven.sock), fallback to loopback TCP on the chosen port.
  • Playground route validates absolute targets: http: only, loopback hosts only, paths under /api/; legacy /api/coven-proxy-prefixed URLs still work.
  • Self-dial guard: if the fallback port is the docs site itself, return a clear 503 daemon_unreachable hint instead of a confusing Next.js 404.

Formatted output everywhere

  • Bridge pretty-prints all application/json / +json responses (Try It panels, status banner).
  • Code samples: curl pipes | jq .; TS/Python/Rust print pretty JSON (JSON.stringify(...,null,2), json.dumps(indent=2), serde_json::to_string_pretty).

Prose: openapi/index.mdx (port selector, TCP fallback row, jq sanity check), daemon/socket-api.mdx + reference/api.mdx (standard port 3000).

Verified

  • npx tsc --noEmit and full pnpm build (all check scripts) green
  • Live matrix against dev server + running daemon: socket 200 pretty JSON; legacy and absolute URLs OK; non-loopback / https / non-/api/ → 400
  • TCP fallback to a mock daemon → 200 pretty-printed; self-dial → 503 cause:'self' + hint; no listener → 503 ECONNREFUSED
  • Regenerated .built.yaml + endpoint MDX via openapi:build (gitignored artifacts)

… API output

- OpenAPI servers: http://localhost:{port}/api/v1 with editable port
  variable (default 3000, the documented coven daemon serve --tcp standard)
  so hosted docs never display/resolve docs.opencoven.ai
- Proxy bridge: socket-first dial with loopback TCP fallback on the chosen
  port; validates absolute targets (http + loopback + /api/ paths), keeps
  legacy /api/coven-proxy URLs, self-dial guard returns a clear 503 hint
- Pretty-print all JSON responses through the bridge; code samples pipe
  curl through jq and pretty-print in TS/Python/Rust
- Prose: port selector + TCP fallback + standard port 3000 in openapi
  index, socket-api, and reference/api pages

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 21, 2026 23:54
@vercel

vercel Bot commented Jul 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
coven-docs Ready Ready Preview Jul 21, 2026 11:55pm

@BunsDev
BunsDev merged commit dcc9f4e into main Jul 21, 2026
2 checks passed
@BunsDev
BunsDev deleted the docs/openapi-localhost-port branch July 21, 2026 23:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the docs-site OpenAPI “Try It” experience to target localhost with an editable port, bridge requests to the local daemon (Unix socket first, TCP loopback fallback), and present consistently pretty-printed JSON output across the proxy and generated code samples.

Changes:

  • Switch OpenAPI servers to http://localhost:{port}/api/v1 with a port variable defaulting to 3000, and refresh related prose.
  • Extend the proxy dialer to attempt $COVEN_HOME/coven.sock first, then fall back to 127.0.0.1:<port> with a self-dial guard and JSON pretty-printing.
  • Update generated OpenAPI code samples (curl/TS/Python/Rust) to print formatted JSON output.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
scripts/build-openapi-samples.mjs Pretty-prints API output in generated code samples (adds jq and language-specific formatting).
openapi/coven.daemon.v1.yaml Sets localhost server with editable port and refactors repeated event cursor params into reusable components.
lib/coven-proxy-dial.ts Adds TCP fallback dialing, self-dial avoidance, and JSON response formatting for the proxy bridge.
app/api/coven-proxy/route.ts Validates absolute loopback targets, extracts port for fallback, and preserves legacy /api/coven-proxy/... behavior.
app/api/coven-proxy/[...path]/route.ts Passes selfHost into the dialer for self-dial guarding on path-prefix proxy calls.
content/docs/openapi/index.mdx Documents the server URL/port selector behavior, fallback transport, and jq sanity check.
content/docs/daemon/socket-api.mdx Updates transport prose and examples to reflect formatted output and standard port 3000.
content/docs/reference/api.mdx Notes the standard loopback TCP address/port in the reference transport description.

Comment on lines +22 to +23
const LEGACY_PROXY_PREFIX = '/api/coven-proxy';
const LOOPBACK_HOSTNAMES = new Set(['localhost', '127.0.0.1', '[::1]']);
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.

2 participants