feat: VS Code / Cursor preview extension#18
Open
exilis wants to merge 13 commits into
Open
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
startServer attached no 'error' listener on the spawned child. When spawn
fails to launch the binary (bad/missing binaryPath, ENOENT, permissions),
Node emits an 'error' event with no listener, producing an uncaught
exception that crashes the host process; 'exit' never fires so the existing
early-exit detection never engaged.
Add a child.on('error') listener that marks the child as exited and records
the error, and surface it in the rejection ("reefdoc failed to start: ...").
Add a regression test asserting startServer rejects (rather than crashing)
on a bad binary path.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…e failure Derive the webview CSP frame-src from the actual server URL origin instead of a hardcoded loopback allowlist, so a non-loopback reefdoc.host doesn't get silently blocked. Thread the host into findFreePort so the port probe binds the same interface the server will use. Also stop the spawned server if panel creation throws, so the child process doesn't leak.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a VS Code / Cursor extension (new self-contained npm project under
editor/vscode/) that opens the existingreefdocpreview inside an editor panel instead of a separate browser tab.It's a thin launcher + embedder: on the
reefdoc: Open Previewcommand it picks a free port, spawns the bundledreefdocbinary (reefdoc --addr 127.0.0.1:<port> <workspaceRoot>), waits until it serves, and frames that localhost server in a webview panel. The Go backend and JS frontend are reused verbatim —main.gois untouched (the--addrflag it needed already existed). One extension works in both VS Code and Cursor.How it's structured
src/server.ts— pure Node (novscodeimport, unit-testable): per-platform binary resolution, free-port selection, spawn/poll/stop lifecycle.src/panel.ts— webview panel with a full-bleed iframe and a CSP scoped to the server's exact origin.src/extension.ts— wires the command: single-instance, error notifications (no workspace / unsupported platform / start failure), kills the child on panel dispose and on deactivate.scripts/bundle-binaries.mjs— cross-compiles the binary fordarwin-arm64,darwin-x64,linux-arm64,linux-x64,win32-x64intobin/;npm run packageproduces a local.vsix(no marketplace).Testing
cd editor/vscode && npm test→ 6/6 pass. Includes a smoke test that builds the real Go binary, spawns it, and assertsGET / → 200— plus a regression test thatstartServerrejects (not crashes) on a bad binary path.reefdoc.binaryPath(override bundled binary) andreefdoc.host(default127.0.0.1).Not yet done (needs a human at a GUI — can't run headless)
.vsixvia "Install from VSIX…" and confirm the bundled binary is used with noreefdoc.binaryPathset.Follow-ups (non-blocking)
reefdoc.host(e.g.::1) would need a bracketed URL — currently unreachable (server probe fails first).Design & plan
docs/specs/2026-07-10-vscode-extension-design.mddocs/superpowers/plans/2026-07-10-vscode-extension.mdBuilt via subagent-driven development: each task TDD'd, task-reviewed, with a final whole-branch review (verdict: ready to merge). Three review findings were caught and fixed — spawn-error host crash, a double-invocation double-spawn race, and the
reefdoc.host/CSP inconsistency.🤖 Generated with Claude Code