char/avril

(wip) why'd you have to go and make things so complicaaaaated?

git clone https://git.t4t.associates/char/avril

Charlotte Somdocument the new tsc + lsp setupec2ae4a

main
3.7 KiB82 linesraw

Native TypeScript backend

The language server requires the in-tree TypeScript patch, pinned to upstream commit b5c34ba0c61a756c8abaf133236dddf982c27f45 (version 7.1.0-dev.20261013.1). The executable is a trusted host tool; filesystem callbacks are not an OS sandbox. Project code and compiler plugins are not executed.

Build

Build separately from Avril; Node/npm installation is not required. These commands require Git, Bash, and Go and start at the Avril repository root:

typescript_src=$(mktemp -d)
git clone --filter=blob:none --no-checkout \
  https://github.com/microsoft/TypeScript.git "$typescript_src"
git -C "$typescript_src" checkout --detach b5c34ba0c61a756c8abaf133236dddf982c27f45
bash lib/lsp/typescript/build.sh "$typescript_src" "/absolute/path/to/avril-tsc"
cargo build --locked -p avril-cli --bin avril

If Go is not on PATH, replace the build.sh invocation with:

nix shell nixpkgs#go --command bash lib/lsp/typescript/build.sh \
  "$typescript_src" "/absolute/path/to/avril-tsc"

The upstream Go module selects its toolchain and may download it. Standard-library declarations are embedded in the binary, so the temporary source checkout is not needed at runtime. The build script verifies the revision and patch applicability before modifying the checkout, runs native tests, and leaves the checkout patched; use a fresh checkout for each build.

For editor installation and user settings, follow the VS Code setup. Configure avril.lsp.backend with the expanded absolute path to this binary—not an npm TypeScript package, a directory, or a JavaScript tsc.js file. The extension starts avril lsp for you.

The frontend checks both the TypeScript version and bridge protocol version. An unpatched binary fails LSP initialization with installation guidance. avril check still works with the pinned stock API, but using the same patched binary for checking and editing is recommended.

Contract

Avril creates immutable API snapshots, supplies source text, compiler-option groups and authoritative static resolution tables, and denies unrelated filesystem reads. Unknown module imports remain unresolved rather than falling back to compiler filesystem discovery. The patch invokes native language-service providers on those exact programs. It does not start the stock LSP's config discovery, package discovery, typings installation, or content-mapper execution.

The bridge uses UTF-16 positions independently of the ordinary API's UTF-8 snapshot converter. Results contain LSP objects rather than AST/checker handles. Rust translates compiler document identities, binds deferred items to their originating generation, and rejects edit sets touching immutable sources. The patch README describes the wire protocol and limits.

Validate

Start at the Avril repository root, with typescript_src still pointing to the patched checkout from the build above:

AVRIL_TEST_TYPESCRIPT="/absolute/path/to/avril-tsc" cargo nextest run --workspace
cargo test --workspace --doc
cd "$typescript_src/tsc"
go test ./internal/api ./internal/ipc ./internal/ls/autoimport

Backend-dependent Rust tests return early without AVRIL_TEST_TYPESCRIPT; a run without it does not validate this integration. native_api independently checks the underlying stock API contracts. CLI LSP tests exercise the patched bridge through framed editor messages, including resolution denial, live edits, completion resolve, signatures, navigation, rename, and cancellation.

VS Code unit and actual editor-host tests are separate; see editor validation.

1# Native TypeScript backend
2
3The language server requires the in-tree [TypeScript patch](typescript/README.md),
4pinned to upstream commit `b5c34ba0c61a756c8abaf133236dddf982c27f45`
5(version `7.1.0-dev.20261013.1`). The executable is a trusted host tool;
6filesystem callbacks are not an OS sandbox. Project code and compiler plugins
7are not executed.
8
9## Build
10
11Build separately from Avril; Node/npm installation is not required. These
12commands require Git, Bash, and Go and start at the Avril repository root:
13
14```sh
15typescript_src=$(mktemp -d)
16git clone --filter=blob:none --no-checkout \
17  https://github.com/microsoft/TypeScript.git "$typescript_src"
18git -C "$typescript_src" checkout --detach b5c34ba0c61a756c8abaf133236dddf982c27f45
19bash lib/lsp/typescript/build.sh "$typescript_src" "/absolute/path/to/avril-tsc"
20cargo build --locked -p avril-cli --bin avril
21```
22
23If Go is not on PATH, replace the `build.sh` invocation with:
24
25```sh
26nix shell nixpkgs#go --command bash lib/lsp/typescript/build.sh \
27  "$typescript_src" "/absolute/path/to/avril-tsc"
28```
29
30The upstream Go module selects its toolchain and may download it. Standard-library
31declarations are embedded in the binary, so the temporary source checkout is not
32needed at runtime. The build script verifies the revision and patch applicability
33before modifying the checkout, runs native tests, and leaves the checkout
34patched; use a fresh checkout for each build.
35
36For editor installation and user settings, follow the
37[VS Code setup](../../editors/vscode/README.md#build-and-install). Configure
38`avril.lsp.backend` with the expanded absolute path to this binary—not an npm
39TypeScript package, a directory, or a JavaScript `tsc.js` file. The extension
40starts `avril lsp` for you.
41
42The frontend checks both the TypeScript version and bridge protocol version.
43An unpatched binary fails LSP initialization with installation guidance.
44`avril check` still works with the pinned stock API, but using the same patched
45binary for checking and editing is recommended.
46
47## Contract
48
49Avril creates immutable API snapshots, supplies source text, compiler-option
50groups and authoritative static resolution tables, and denies unrelated filesystem
51reads. Unknown module imports remain unresolved rather than falling back to
52compiler filesystem discovery.
53The patch invokes native language-service providers on those exact programs.
54It does not start the stock LSP's config discovery, package discovery, typings
55installation, or content-mapper execution.
56
57The bridge uses UTF-16 positions independently of the ordinary API's UTF-8
58snapshot converter. Results contain LSP objects rather than AST/checker handles.
59Rust translates compiler document identities, binds deferred items to their
60originating generation, and rejects edit sets touching immutable sources.
61The [patch README](typescript/README.md) describes the wire protocol and limits.
62
63## Validate
64
65Start at the Avril repository root, with `typescript_src` still pointing to the
66patched checkout from the build above:
67
68```sh
69AVRIL_TEST_TYPESCRIPT="/absolute/path/to/avril-tsc" cargo nextest run --workspace
70cargo test --workspace --doc
71cd "$typescript_src/tsc"
72go test ./internal/api ./internal/ipc ./internal/ls/autoimport
73```
74
75Backend-dependent Rust tests return early without `AVRIL_TEST_TYPESCRIPT`;
76a run without it does not validate this integration. `native_api` independently
77checks the underlying stock API contracts. CLI LSP tests exercise the patched
78bridge through framed editor messages, including resolution denial, live edits,
79completion resolve, signatures, navigation, rename, and cancellation.
80
81VS Code unit and actual editor-host tests are separate; see
82[editor validation](../../editors/vscode/README.md#validation).