| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
The Prisma 8 language server ignores documents without the use prisma-next directive (#30140) ## Linked issue n/a — no Linear ticket. Part of the extension routing model where both the legacy (Prisma ≤7) and Prisma 8 language servers receive document sync for all `.prisma` files and each decides ownership locally; the legacy server's half is already implemented in `prisma/language-tools`. ## At a glance ```ts // packages/1-framework/3-tooling/language-server/src/schema-directive.ts const PRISMA_NEXT_DIRECTIVE = /^\s*\/\/ *use +prisma-next *(?!\S)/; export function isPrismaNextSchema(text: string): boolean { return PRISMA_NEXT_DIRECTIVE.test(text); } ``` A document whose first non-whitespace content is a `// use prisma-next` line comment is this server's responsibility; everything else belongs to the legacy server and is now ignored — feature requests return the protocol's empty result, and the push path publishes an **empty** diagnostics array (not nothing), so an edit that removes the directive clears this server's stale squiggles as ownership flips back mid-edit. Before this PR, the server diagnosed every configured input regardless of the directive. ## Decision `prisma lsp` decides per request, from current document content, whether a document is a Prisma Next schema: 1. **One ownership gate at the artifacts seam.** `computeDocumentDiagnostics` — the existing "do we own this document" decision that already returns `null` for non-configured inputs — now also returns `null` when the text lacks the directive. Every feature path (push/pull diagnostics, completion, semantic tokens, folding) and multi-file schema composition reads through this seam, so one check covers them all. 2. **No caching of ownership.** The regex is re-tested lazily from the current text at each publish/request, so adding or removing the directive flips ownership immediately in both directions. Document sync itself is untouched — unmarked documents stay tracked. 3. **A local copy of the shared convention.** The regex is the only coupling with the legacy server; it must stay byte-for-byte in sync with the copy in `prisma/language-tools`. This server does not import, spawn, or proxy to the legacy server. ## Reviewer notes - **The bulk of the diff is test-source churn, not behavior.** Every pre-existing test schema gained the directive line, which shifted line-sensitive expectations: semantic-token arrays gained the leading comment token (`0, 0, 18, 9, 0`) plus a line delta, formatting ranges grew a line, and the fabricated interpreter-diagnostic spans moved by the 19-character directive line (interpreter mapping is offset-based). The new behavior is concentrated in the `prisma-next directive gating` describe at the end of [test/server.test.ts](packages/1-framework/3-tooling/language-server/test/server.test.ts). - **Unconfigured documents still publish nothing at all** (pre-existing, still asserted). The explicit empty publish applies to *configured inputs* without the directive — the only case where this server could have stale markers to clear. - **`getProjectSymbolTable` now guards instead of throwing.** With gating, a project can have open configured inputs that are all unmarked; the public accessor returns `undefined` for a document without artifacts rather than reaching the "no readable configured input" invariant throw in [src/project-artifacts.ts](packages/1-framework/3-tooling/language-server/src/project-artifacts.ts). Internal callers (completion, semantic tokens) already only read the symbol table after confirming the requested document's artifacts. - **By the regex's own grammar, `// use prisma-next extra words` matches** (the lookahead only rejects a token *attached* to `prisma-next`, e.g. `prisma-nextgen`). That behavior is pinned in [test/schema-directive.test.ts](packages/1-framework/3-tooling/language-server/test/schema-directive.test.ts) so a well-meaning "fix" can't silently desync us from the legacy server. - The `lsp-playground` sample fixture gained the directive so the playground keeps demonstrating live diagnostics. ## How it fits together 1. **The directive helper** ([src/schema-directive.ts](packages/1-framework/3-tooling/language-server/src/schema-directive.ts)) holds the regex and `isPrismaNextSchema`. 2. **The gate** lands in [src/document-diagnostics.ts](packages/1-framework/3-tooling/language-server/src/document-diagnostics.ts): an unmarked configured input computes to `null`, exactly like a non-input. The project artifacts store therefore never caches artifacts for unmarked documents, which is what makes the check lazy — `documentChanged` drops the cache and the next read re-tests the current text. 3. **Everything downstream falls out of the seam.** The push path already publishes `[]` when a tracked document has no artifacts; pull reports, completion, semantic tokens, and folding already return their empty results; and `symbolTable()` composition skips inputs that yield no artifacts, so an unmarked sibling never becomes part of a Prisma Next schema. 4. **Formatting is the one path that bypasses the store** (it formats raw buffer text), so [src/server.ts](packages/1-framework/3-tooling/language-server/src/server.ts) re-tests the directive there before formatting — a document the legacy server owns must not be reformatted by this server. ## Behavior changes & evidence - A configured input without the directive gets an explicit empty diagnostics publish on open and on every change, and empty results for completion, semantic tokens, folding, formatting, and pull diagnostics ([src/document-diagnostics.ts](packages/1-framework/3-tooling/language-server/src/document-diagnostics.ts); evidence: `prisma-next directive gating` in [test/server.test.ts](packages/1-framework/3-tooling/language-server/test/server.test.ts)). - An edit that removes the directive from a handled document publishes empty diagnostics and stops answering feature requests; an edit that adds it starts diagnosing from the edited content ([test/server.test.ts](packages/1-framework/3-tooling/language-server/test/server.test.ts)). - With a marked and an unmarked file open in the same project, the unmarked file is excluded from schema composition — the project symbol table contains only the marked file's models ([src/project-artifacts.ts](packages/1-framework/3-tooling/language-server/src/project-artifacts.ts); evidence: [test/project-artifacts.test.ts](packages/1-framework/3-tooling/language-server/test/project-artifacts.test.ts)). - The directive grammar itself — leading blank lines and flexible spacing accepted, attached tokens and block comments rejected — is pinned in [test/schema-directive.test.ts](packages/1-framework/3-tooling/language-server/test/schema-directive.test.ts). - The package README ([README.md](packages/1-framework/3-tooling/language-server/README.md)) is trimmed to a short description and now states the directive-ownership rule up front. ## Testing performed - `pnpm test` in `@internal/language-server` — 292 tests, 15 files, all green (includes the new gating suites). - `pnpm typecheck` and `pnpm lint` in the package (lint output identical to baseline). - `pnpm lint:deps` at the root. - `pnpm test:packages` at the root — 1171 files passed; the 5 failing tarball-packaging smoke tests (`pnpm pack`/`pnpm install` in temp dirs) reproduce identically on a clean checkout and are unrelated. ## Skill update n/a — no skill under `packages/0-shared/skills/` documents language-server behavior; the ownership model is documented in the package README instead. ## Alternatives considered - **Gating in each request handler** instead of at the artifacts seam — would need five-plus checks that drift independently; the seam already models "document we own" via its `null` return, so ownership stays a single decision. - **Caching an "owned" flag on open/change** — a cached flag can go stale across edits and config reloads; the regex test is one cheap call per event, so lazy re-evaluation from current text is both simpler and correct by construction. - **Publishing nothing for unmarked configured inputs** — publishing an explicit empty array is what clears stale squiggles when an edit removes the directive mid-session; silence would leave this server's markers stranded while the legacy server takes over. - **Sharing the regex via a common package with the legacy server** — rejected up front: this server must not depend on the legacy server in any way. The shared directive convention is the only coupling, hence a local copy of the regex. ## Checklist - [x] All commits are signed off (`git commit -s`) per the [DCO](../CONTRIBUTING.md#developer-certificate-of-origin-dco). The DCO status check will block merge if any commit is missing a `Signed-off-by:` trailer. - [x] I read [CONTRIBUTING.md](../CONTRIBUTING.md) and the change is scoped to one logical concern. - [x] Tests are updated (or `n/a` if the change is doc-only / refactor with no behavioural delta). - [ ] The PR title is in `TML-NNNN: <sentence-case title>` form — no Linear ticket exists for this change; the title is a plain sentence-case description. - [x] The **Skill update** section above is filled in (or stated `n/a — internal only`). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added opt-in schema processing through the `// use prisma-next` directive. * Unmarked documents are excluded from diagnostics, formatting, tokens, folding, AST results, and symbol tables. * Adding or removing the directive updates language-server processing automatically. * **Bug Fixes** * Prevented unmarked sibling documents from affecting schema composition. * **Tests** * Added comprehensive coverage for directive detection and language-server behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Steven McClankerton <tatarintsev@prisma.io> Co-authored-by: Steven McClankerton <tatarintsev@prisma.io> Co-authored-by: Claude Fable 5 <noreply@anthropic.com> | 16 天前 | |
Bump to version 8.0.0-rc.8: the engine peer moves to @prisma/cli-engine@0.3.0 (#30137) ## Release: 8.0.0-rc.7 → 8.0.0-rc.8 This is the routine release PR per [docs/oss/versioning.md](https://github.com/prisma/prisma/blob/main/docs/oss/versioning.md). It bumps every workspace package to 8.0.0-rc.8 and moves every `@prisma/cli-engine` pin from 0.2.3 to 0.3.0. The engine change: `@prisma/cli-engine@0.3.0` declares `@prisma/management-api-sdk` as a peer dependency (`^1.55.0`) instead of a regular dependency ([prisma/prisma-cli#236](https://github.com/prisma/prisma-cli/pull/236)). The `prisma` CLI shell supplies the SDK at runtime. In this repo pnpm resolves the peer to 1.61.0 in the lockfile. Review surface: [docs/releases/v8.0.0-rc.8.md](https://github.com/prisma/prisma/blob/release/8.0.0-rc.8/docs/releases/v8.0.0-rc.8.md) is the release notes file that becomes the GitHub Release body. The matching `CHANGELOG.md` entry and the `8.0.0-rc.7-to-8.0.0-rc.8` upgrade recipes are included. **Merging this PR ships the release**: the push to `main` carries the bumped root `version`, the `Publish to npm` workflow detects the change and publishes 8.0.0-rc.8 under `latest`, creates a pre-release GitHub Release from the notes file, then publishes `8.0.0-rc.8-dev.1` under `dev`. Local verification: `check:release-notes` (PR mode), `check:upgrade-coverage`, and `test:scripts` pass; the CLI tooling package's typecheck and its 1436 tests pass against the new engine. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added migration-model guidance and an upgrade recipe for Prisma 8.0.0-rc.8. * Added safeguards for planning migrations against existing migrations on empty databases. * **Bug Fixes** * Improved migration planning and corrected structured error links, Windows file URIs, and development release tags. * **Documentation** * Updated Prisma 8 release and upgrade guidance, including CLI tooling requirements. * **Chores** * Published the 8.0.0-rc.8 release across packages and examples. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io> | 16 天前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 16 天前 | ||
| 16 天前 |