Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,39 @@ npm run lint

# Refresh PreTeXt RNG schemas from upstream
npm run refresh:schemas

# Refresh vendored PreTeXt XSL stylesheets (pretext-html package) from upstream
npm run refresh:xsl
```

**Running the extension locally (VS Code):**

1. `npm run build:dev` for an initial build
2. Press F5 to launch the "Run Extension + LSP" compound configuration
3. Reload the extension window to pick up TypeScript recompilation

**LSP debugger:** The LSP server auto-attaches on port 6009 when launched via the compound config. Set breakpoints in `packages/vscode-extension/src/lsp-server/`.

**What `npm test` actually runs:** the root `test` script only covers `completions`, `prettier-plugin-pretext`, and a fixed list of "reliability" spec files (`remark-pretext`, `ptxast-util-to-mdast`, `latex-pretext`). It does **not** run `format`'s or `ptxast`'s own Vitest suites, nor `vscode-extension`'s integration tests — run those with `npm run test -w <package>` directly. `vscode-extension`'s test script (`vscode-test`) launches a real VS Code instance and is also runnable from the editor via the "Extension Tests" debug configuration.
**What `npm test` actually runs:** the root `test` script only covers `completions`, `prettier-plugin-pretext`, `schema`, `pretext-html`, `vscode-extension` unit specs, and a fixed list of "reliability" spec files (`remark-pretext`, `ptxast-util-to-mdast`, `latex-pretext`). It does **not** run `format`'s or `ptxast`'s own Vitest suites, nor `vscode-extension`'s integration tests — run those with `npm run test -w <package>` directly. `vscode-extension`'s test script (`vscode-test`) launches a real VS Code instance and is also runnable from the editor via the "Extension Tests" debug configuration.

**JSPI note (`pretext-html`):** `@pretextbook/pretext-html` runs libxslt as WebAssembly and needs the `--experimental-wasm-jspi` Node flag, which is banned in `NODE_OPTIONS`. Its vitest config passes the flag via `test.execArgv`; its CLI (`cli.mjs`) re-launches itself with the flag; the VS Code extension forks `out/instant-preview-worker.mjs` with the flag in `execArgv`.

## Architecture

### Packages

| Package | Role | Build tool |
|---|---|---|
| `vscode-extension` (`pretext-tools`) | Main VS Code extension: extension host, LSP client, commands, webview | esbuild → `out/extension.js` + `out/lsp-server.js` |
| `visual-editor` | React/TipTap WYSIWYG editor (VS Code webview UI) | Vite |
| `prettier-plugin-pretext` | Prettier plugin for PreTeXt XML | esbuild (ESM + CJS) |
| `completions` | Completion/intellisense engine (consumed by LSP server) | None — exports raw `.ts` source directly (`main`/`types` point at `src/index.ts`) |
| `format` | PreTeXt document formatter library | Vite (ESM + CJS) |
| `latex-pretext` | LaTeX-to-PreTeXt conversion via `unified-latex` | Vite (ESM + CJS, via `vite-plugin-dts`) |
| `ptxast` | TypeScript types for the PreTeXt AST | Vite (ESM + CJS, via `vite-plugin-dts`) |
| `remark-pretext`, `ptxast-util-to-mdast` | AST conversion utilities (Markdown ⇄ PreTeXt AST) | Vite |
| `playground` | Dev-only web playground for testing conversions | Vite |
| Package | Role | Build tool |
| ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| `vscode-extension` (`pretext-tools`) | Main VS Code extension: extension host, LSP client, commands, webview | esbuild → `out/extension.js` + `out/lsp-server.js` |
| `visual-editor` | React/TipTap WYSIWYG editor (VS Code webview UI) | Vite |
| `prettier-plugin-pretext` | Prettier plugin for PreTeXt XML | esbuild (ESM + CJS) |
| `completions` | Completion/intellisense engine (consumed by LSP server) | None — exports raw `.ts` source directly (`main`/`types` point at `src/index.ts`) |
| `format` | PreTeXt document formatter library | Vite (ESM + CJS) |
| `latex-pretext` | LaTeX-to-PreTeXt conversion via `unified-latex` | Vite (ESM + CJS, via `vite-plugin-dts`) |
| `pretext-html` | PreTeXt→HTML in pure JS: official XSLT via `libxslt-wasm`; powers the extension's Instant Preview; vendored `assets/xsl/` + generated `assets/preview-html.xsl` (regenerate with `npm run refresh:xsl`) | Vite (ESM only; needs Node `--experimental-wasm-jspi`) |
| `ptxast` | TypeScript types for the PreTeXt AST | Vite (ESM + CJS, via `vite-plugin-dts`) |
| `remark-pretext`, `ptxast-util-to-mdast` | AST conversion utilities (Markdown ⇄ PreTeXt AST) | Vite |
| `playground` | Dev-only web playground for testing conversions | Vite |

`extension/` (not a package) — extension manifest, TextMate grammar, snippets, and static assets that ship with the published extension.

Expand Down
51 changes: 40 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"build": "npm run build:deps && npm run build -w pretext-tools",
"build:deps": "npm run build:utils && npm run build:libs",
"build:utils": "npm run build -w @pretextbook/ptxast && npm run build -w @pretextbook/remark-pretext && npm run build -w @pretextbook/ptxast-util-to-mdast",
"build:libs": "npm run build -w @pretextbook/format && npm run build -w @pretextbook/latex-pretext && npm run refresh-schema -w @pretextbook/completions && npm run build -w @pretextbook/completions && npm run compile-grammar -w @pretextbook/schema && npm run build -w @pretextbook/schema && npm run build:lib -w @pretextbook/visual-editor && npm run build -w prettier-plugin-pretext",
"build:libs": "npm run build -w @pretextbook/format && npm run build -w @pretextbook/pretext-html && npm run build -w @pretextbook/latex-pretext && npm run refresh-schema -w @pretextbook/completions && npm run build -w @pretextbook/completions && npm run compile-grammar -w @pretextbook/schema && npm run build -w @pretextbook/schema && npm run build:lib -w @pretextbook/visual-editor && npm run build -w prettier-plugin-pretext",
"build:dev": "npm run build:deps && npm run build:dev -w pretext-tools",
"build:packages": "npm run build:deps",
"publish-packages": "changeset publish",
Expand All @@ -26,10 +26,11 @@
"refresh:schemas": "node ./scripts/getSchemas.js && node ./packages/completions/scripts/generate-default-schema.mjs && npm run generate-types -w @pretextbook/ptxast && node ./packages/schema/scripts/compile-grammar.mjs",
"check:schema-generated": "node ./scripts/check-schema-generated.mjs",
"lint": "npm run lint -w prettier-plugin-pretext && npm run lint -w @pretextbook/visual-editor && npm run lint -w pretext-tools",
"test": "npm run test -w @pretextbook/completions && npm run test -w prettier-plugin-pretext && npm run test -w @pretextbook/schema && npm run test:reliability",
"test": "npm run test -w @pretextbook/completions && npm run test -w prettier-plugin-pretext && npm run test -w @pretextbook/schema && npm run test:unit -w pretext-tools && npm run test:reliability && npm run test -w @pretextbook/pretext-html",
"test:reliability": "npm exec vitest run packages/remark-pretext/src/lib/remark-pretext.spec.ts packages/ptxast-util-to-mdast/src/lib/ptxast-util-to-mdast.spec.ts packages/latex-pretext/src/lib/latex-pretext.spec.ts",
"pretest": "npm run build",
"format": "npx prettier -w $(git ls-files 'packages/vscode-extension/*.ts')"
"format": "npx prettier -w $(git ls-files 'packages/vscode-extension/*.ts')",
"refresh:xsl": "npm run refresh-xsl -w @pretextbook/pretext-html"
},
"devDependencies": {
"@changesets/cli": "^2.31.0",
Expand Down
Loading