feat: add experimental JavaScript API bridge - #499
Draft
mattiamanzati wants to merge 11 commits into
Draft
Conversation
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.
Summary
etsapitoetsgoapietsjsapibridge throughtsgo --effect-js-apiwith a versioned Content-Length JSON protocolAPI boundaries
etsgoapiis the public in-process API for Go consumers.etsjsapiowns the cross-process protocol for JavaScript consumers. The code under_packages/tsgo/src/experimental/oxlintis the first consumer-specific adapter overetsjsapi; Oxlint lifecycle details are not part of the server package or wire method names.Protocol v2 exposes a synchronous
diagnosticsrequest with optionalincludeFixes. The server retains TypeScript-Go project state, refreshes the base snapshot for every request, layers the exact current file through a temporary snapshot, and invokesrulerunner.Runonly for requested rules. Returned actions contain grouped UTF-16 text edits whose positions are validated against TypeScript-Go before conversion.Oxlint adapter
The plugin coordinates enabled wrappers through
ProgramandProgram:exit. The first exit sends the exact current source text and complete requested-rule set to one persistent child; subsequent wrappers reuse the grouped response.context.settings["effect-tsgo"]supplies Effect options when present, otherwiseetsjsapifalls back to project plugin options. Before execution, every Effect rule is set tooffand requested rules to internalerror, leaving final severity ownership to Oxlint.Effect code fixes are reported through
context.report(... suggest ...);effectDisableactions are excluded. Plainoxlint --fixdoes not apply these suggestions, while--fix-suggestionsmay apply them. The fixture verifies this behavior with a non-BMP character before the edit to exercise UTF-16 conversion.The synchronous channel is adapted from TypeScript-Go under its Apache-2.0 license. It retains blocking pipe I/O, buffering, cleanup, retry handling, and Windows named-pipe support while replacing the general MessagePack API protocol with the narrow Effect JavaScript API protocol.
Validation
pnpm setup-repopnpm lintpnpm checkpnpm test(now includes the Oxlint prototype)pnpm --filter effect-tsgo-oxlint-prototype testGOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build ./...All checks pass.
Current limitations