Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##!/bin/bash
#!/bin/bash

if ! scripts/lint.sh; then
echo -e "\033[1m\033[31mFailed linting, please fix the reported issues\033[0m\n"
Expand Down
67 changes: 67 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# ls-builder

A Go library for building Language Server Protocol servers: LSP 3.17 types and request
dispatch, and stdio, TCP and WebSocket transports. bluelink's `tools/blueprint-ls` is built on
it, and as a public module on pkg.go.dev it may have users outside NewStack.

## Workspace

This repo is one of NewStack's. NewStack's maintainers develop it alongside the others in a
shared workspace, using the NewStack Claude Code plugin for how work is planned, reviewed,
committed and coordinated across repos. The plugin isn't public, and nothing here depends on it:
this file and the repo's own docs cover what a contribution needs.

## Layout

| Path | Holds |
|---|---|
| `lsp_3_17/` | LSP 3.17 messages and structures; `Handler`, which dispatches client messages to the functions a server sets; `Dispatcher`, which sends server-to-client requests and notifications; `TraceService` |
| `server/` | The server: connections, transports (stdio, TCP, WebSocket), the jsonrpc2 logger adapter |
| `common/` | `LSPContext` and the handler types both use |

Each directory's `README.md` describes it.

## Checks

- **Tools:** Go (`go.mod`; CI uses 1.24) with cgo for `-race`, `staticcheck` on `PATH` (CI
installs `@latest`), and Node with Yarn 1: run `yarn` in each checkout or worktree before
committing, since the commit-msg hook runs commitlint through `npm exec`.
- **Lint:** `scripts/lint.sh` (`staticcheck` and `go vet` per package).
- **Tests:** `bash scripts/run-tests.sh` runs every package with `-race` and coverage. Tests
need no services; the transport tests listen on free local ports. `--update-snapshots` does
nothing. `lsp_3_17/example_test.go` checks its log output, and the root `README.md` example
is copied from it by hand.
- **JSON shapes:** `encoding/json` matches field names case-insensitively when decoding, so a
wrong tag can still decode. Check a new or changed type by marshalling it against the spec.
- **Gates:** with `git config core.hooksPath .githooks`, pre-commit runs `scripts/lint.sh` over
the working tree on every commit, and commit-msg runs commitlint. CI (`ci.yml`) runs lint,
tests and SonarCloud on pull requests and pushes to `main`.

## Compatibility

- **Go API:** blueprint-ls and any outside users build against tagged releases. Breaking
changes have shipped as patch releases so far (v0.2.1, v0.2.2, v0.2.4, per `CHANGELOG.md`);
a breaking change says in its pull request what blueprint-ls needs.
- **Protocol:** types aim to match the LSP 3.17 specification's field names and JSON shapes,
which clients such as VS Code send and expect; new or changed types use the spec's names.
Known deviations: `ServerCapabilities.NotebookDocumentSync` marshals as `notebookSync`,
`TextDocumentClientCapabilities.Diagnostics` decodes `diagnostics` rather than `diagnostic`,
and `DocumentRangeFormattingParams.Range` marshals as `Range`. `window/showDocument` isn't
implemented.
- **Persisted state:** none.

## Conventions

- Commits: conventional commits, checked by commitlint (`commitlint.config.js`). Scopes are
allowed but unused.
- Releases are manual: a `CHANGELOG.md` entry on `main`, then a `vX.Y.Z` tag and GitHub
release, as [CONTRIBUTING.md](CONTRIBUTING.md) sets out. There is no release automation.

## Safety

- Don't create or push tags, create releases, or edit `CHANGELOG.md` for a release unless
asked.

## Known mistakes

<!-- One line per mistake an agent has made here, phrased as the rule that prevents it. -->
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@AGENTS.md
11 changes: 6 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

### Prerequisites

- [Go](https://golang.org/dl/) >=1.22.2
- [Node.js](https://nodejs.org/en/download/) >=18.17.0 (For pre-commit hooks)
- [Yarn](https://yarnpkg.com/getting-started/install) >=1.22.21 (For pre-commit hooks)
- [Go](https://golang.org/dl/) >=1.22.2 (`go.mod`; CI uses 1.24)
- [staticcheck](https://staticcheck.dev/docs/getting-started/) (For the pre-commit hook, which runs `scripts/lint.sh`)
- [Node.js](https://nodejs.org/en/download/) >=18.17.0 (For the commit-msg hook)
- [Yarn](https://yarnpkg.com/getting-started/install) >=1.22.21 (For the commit-msg hook)

Dependencies are managed with Go modules (go.mod) and will be installed automatically when you first
run tests.
Expand Down Expand Up @@ -66,7 +67,7 @@ See [here](https://go.dev/wiki/Modules#publishing-a-release).

```bash
git tag -a v0.2.0 -m "chore: Release v0.2.0"
git push --tags
git push origin v0.2.0
```

Be sure to add a release for the tag with notes following this template:
Expand All @@ -91,7 +92,7 @@ GOPROXY=proxy.golang.org go list -m github.com/newstack-cloud/ls-builder@v0.2.0

## Commit scope

**blueprint**
Scopes are optional, and commits here don't use them.

Example commit:

Expand Down
Loading