Skip to content

feat(editor): add language server diagnostics - #59

Merged
haseebahmed248 merged 1 commit into
mainfrom
feat/language-server-diagnostics
Sep 16, 2026
Merged

haseebahmed248 merged 1 commit into
mainfrom
feat/language-server-diagnostics

Conversation

@haseebahmed248

Copy link
Copy Markdown
Owner

Summary

Add guardstep lsp --stdio so editors can show the compiler's diagnostics for unsaved .guard buffers. This is a diagnostics-only prototype; it does not execute workflows or load host code.

Related issue

Closes #19

Changes

  • Reuse compileSource and map its diagnostic codes, messages, severity and ranges to LSP, with UTF-16 positions.
  • Handle open, full-text changes, close, document versions, shutdown and exit over stdio using Microsoft's vscode-languageserver package.
  • Clear stale errors after valid edits and on close; ignore invalid document notifications and stale versions.
  • Report oversized source and unexpected compiler failures without terminating the server or marking the document valid.
  • Add 12 real-process protocol tests, including the existing diagnostic corpus, unsaved source, malformed input, Unicode/CRLF positions and recovery. Rerun them against the installed tarball during package validation.
  • Document Neovim setup, the direct launch command and the prototype's limits. Keep Make the npm alpha easy to find and install #30's install/badge work separate and leave Detect TypeScript name collisions before writing generated contracts #37's code generation work untouched.

Validation

  • npm run check
  • npm run check:generated
  • npm test — 196 tests passed.
  • Additional validation is described below, or was not needed.

Additional validation:

  • npm run test:release — 4 tests passed.
  • npm run test:package — installed-tarball protocol tests passed; 123 files, 7 exports and 2 executables verified.
  • node --test packages/guardstep/dist/test/lsp.test.js — 12 protocol tests passed, including an explicit UTF-16 range assertion.
  • git diff --check passed.
  • Neovim is not installed locally, so its documented configuration has not been exercised manually. The CLI endpoint is covered over the actual stdio protocol.

Risk and compatibility

  • Security or permission effects: document URIs are identifiers only, not read or fetched. The language server compiles editor-provided text; it never imports neighboring host/test modules or invokes tools/providers. Source checks have a 1,048,576 UTF-16 code-unit limit, but synchronous compilation and message reception are not a general resource sandbox.
  • Compatibility or breaking changes: additive CLI command and one pinned runtime dependency (vscode-languageserver 10.1.1, plus its protocol dependencies). Full sync only; no incremental edits, completion, hover, rename, formatting or extension. Compiler semantics, IR and generated contracts are unchanged. No version bump, npm publication or release. The docs explicitly say alpha.1 does not contain this feature.

Checklist

  • This change is focused on one issue.
  • Behavioral changes include tests.
  • User-facing behavior and unsupported constructs are documented.
  • Generated files are current.
  • No credentials, private data, or unredacted model output are included.
  • Commits include the required DCO Signed-off-by line.

Signed-off-by: haseebahmed248 <haseebahmed6157@gmail.com>
@haseebahmed248
haseebahmed248 merged commit a0f6e0a into main Sep 16, 2026
6 checks passed
@haseebahmed248
haseebahmed248 deleted the feat/language-server-diagnostics branch September 16, 2026 11:31
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.

Prototype language-server diagnostics for .guard files

1 participant