Skip to content

Lsp refactor#2681

Merged
davydkov merged 18 commits intomainfrom
lsp-refactor
Mar 4, 2026
Merged

Lsp refactor#2681
davydkov merged 18 commits intomainfrom
lsp-refactor

Conversation

@davydkov
Copy link
Copy Markdown
Member

@davydkov davydkov commented Mar 4, 2026

Language Server & CLI Workflow:

  • Added a new likec4 lsp CLI command to start the LikeC4 language server, promoting a unified entry point for LSP usage. (.changeset/add-cli-lsp-command.md)
  • Deprecated the likec4-language-server binary from the @likec4/language-server package; users should now use the likec4 lsp command. The README was updated to clarify that @likec4/language-server is for internal use, and the direct entry point (bundled.ts) was removed from both the build and exports. (.changeset/deprecate-likec4-language-server.md, README.md, build.config.ts, package.json, bundled.ts) [1] [2] [3] [4] [5]

Dependency and Tooling Updates:

  • Upgraded dprint and its plugins to newer versions, and updated the ignore list to include pnpm-workspace.yaml. (.tool-versions, dprint.json, package.json) [1] [2] [3] [4]
  • Cleaned up and reorganized dependencies in @likec4/language-server, removing unused or duplicate dev dependencies and ensuring all runtime dependencies are properly declared. (package.json) [1] [2]

UI/UX and Bug Fixes in Diagram Package:

  • Fixed the LikeC4 tag color issue. (.changeset/fix-likec4tag-text-bg.md)
  • Improved key handling and layout logic in the DriftsSummary component to avoid React key collisions and unnecessary animation props. (DriftsSummary.tsx) [1] [2] [3] [4] [5] [6]
  • Updated the logic for enabling/disabling the "Start Walkthrough" button to better reflect feature availability. (DynamicViewControls.tsx) [1] [2]

Miscellaneous Improvements:

  • Adjusted debounce timings in the language server's RPC batching logic for improved responsiveness. (Rpc.ts)
  • Improved type exports and code organization in the language server. (common-exports.ts)
  • Removed unnecessary peer dependencies for React types in the diagram package. (diagram/package.json)
  • Minor bugfix in handling project IDs in language server requests. (Rpc.ts)

Summary by CodeRabbit

Release Notes

  • New Features

    • Added new CLI command likec4 lsp to start the LikeC4 language server directly from the CLI.
    • Extended grammar support with additional property types.
    • Added configurable logging with --log-level and --verbose options.
  • Bug Fixes

    • Fixed LikeC4 tag color rendering issue.
  • Deprecations

    • Standalone likec4-language-server package deprecated; use likec4 lsp command instead.

- Updated ConfigurableLayouter to accept a Graphviz instance from services.
- Introduced WithWasmGraphviz and WithGraphviz for flexible Graphviz configuration.
- Refactored ProjectsManager to improve project handling and logging.
- Added support for custom logger configuration in InitOptions.
- Improved error handling and logging in Graphviz adapters.
- Enhanced QueueGraphvizLayoter with better task management and logging.
- Updated GraphvizWasmAdapter and GraphvizBinaryAdapter for improved performance and error reporting.
- Cleaned up unused code and improved overall code structure.
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 4, 2026

🦋 Changeset detected

Latest commit: afb8f80

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
Name Type
likec4 Patch
@likec4/language-server Patch
@likec4/style-preset Patch
@likec4/styles Patch
@likec4/docs-astro Patch
@likec4/playground Patch
@likec4/language-services Patch
@likec4/mcp Patch
@likec4/vite-plugin Patch
likec4-vscode Patch
@likec4/core Patch
@likec4/vscode-preview Patch
@likec4/diagram Patch
@likec4/react Patch
@likec4/config Patch
@likec4/generators Patch
@likec4/layouts Patch
@likec4/log Patch
@likec4/tsconfig Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@davydkov davydkov linked an issue Mar 4, 2026 that may be closed by this pull request
@davydkov davydkov merged commit 01f1c03 into main Mar 4, 2026
15 of 16 checks passed
@davydkov davydkov deleted the lsp-refactor branch March 4, 2026 08:53
@likec4-ci likec4-ci bot mentioned this pull request Mar 4, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 4, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR refactors the language server as a CLI-based command, deprecates the standalone likec4-language-server package, introduces pluggable GraphViz backend selection, centralizes logging configuration, and updates multiple packages with dependency reorganization and configuration enhancements.

Changes

Cohort / File(s) Summary
Changesets
.changeset/*
Three new changeset files documenting patch releases: adding likec4 lsp CLI command, deprecating the language-server package, and fixing LikeC4 tag background color.
Tooling & Dependencies
.tool-versions, dprint.json, package.json, pnpm-workspace.yaml
Updated dprint to 0.52.0, bumped formatter plugin versions, updated workspace catalog dependencies (turbo, caniuse-lite, tinyrainbow).
Language Server Deprecation
packages/language-server/README.md, packages/language-server/bin/likec4-language-server.mjs, packages/language-server/build.config.ts, packages/language-server/package.json, packages/language-server/src/bundled.ts
Deprecated standalone language server in favor of CLI; removed bundled server entry point, export, and build configuration; updated package exports and documentation.
Language Server Core Refactoring
packages/language-server/src/index.ts, packages/language-server/src/module.ts, packages/language-server/src/common-exports.ts, packages/language-server/src/configureLogger.ts
Introduced pluggable GraphViz backend system with WithGraphviz and WithWasmGraphviz exports; added centralized logger configuration; exposed new context types and service interfaces.
Language Server Feature Updates
packages/language-server/src/like-c4.langium, packages/language-server/src/Rpc.ts, packages/language-server/src/lsp/SemanticTokenProvider.ts, packages/language-server/src/model-change/ModelChanges.ts, packages/language-server/src/filesystem/LikeC4ManualLayouts.ts, packages/language-server/src/views/*
Extended grammar with new property types; optimized RPC batching; removed asynchronous semantic highlighting methods; added pluggable GraphViz context types; adjusted cache invalidation timing; simplified layout ownership.
Workspace & Project Management
packages/language-server/src/workspace/ProjectsManager.ts
Added URI normalization with strict protocol checks; introduced project ordering by folder depth; enhanced config file discovery and messaging; improved include/exclude validation with overlap warnings.
Layout & Graphviz Integration
packages/layouts/src/graphviz/*
Added runtime name() getters to GraphViz adapters; improved logging with per-call loggers; enhanced error handling with structured logging; removed wasm instance caching in GraphVizWasmAdapter; added backpressure handling in QueueGraphvizLayoter.
Language Services Refactoring
packages/language-services/src/common/*, packages/language-services/src/node/*
Replaced defu merging with explicit DefaultInitOptions; added new logging configuration options; refactored GraphViz wiring to use pluggable WithGraphviz; moved logger configuration from service initialization to explicit setup step.
CLI Command Implementation
packages/likec4/src/cli/lsp/index.ts
New LSP sub-command supporting multiple transport options (node-ipc, stdio, socket, pipe) with configurable logging, manual layouts, watcher, telemetry, and GraphViz mode.
CLI Core & Options
packages/likec4/src/cli/index.ts, packages/likec4/src/cli/options.ts, packages/likec4/src/cli/ensure-libs.ts
Refactored logger configuration to accept explicit log levels; added new CLI options (--log-level, --verbose, --color); introduced ensurePlaywright() helper; updated ensure-libs structure.
CLI Sub-commands
packages/likec4/src/cli/build/index.ts, packages/likec4/src/cli/codegen/*, packages/likec4/src/cli/check-update/utils.ts, packages/likec4/src/cli/export/png/handler.ts, packages/likec4/src/cli/serve/index.ts, packages/likec4/src/cli/mcp/index.ts
Updated import paths for ensure-libs; made update checks asynchronous; added Playwright readiness check for PNG export; added logger configuration for MCP; refactored logging setup.
CLI Utilities
packages/likec4/src/logger.ts
Narrowed hasErrorLogged parameter type from Error | RollupError to Error only.
MCP Server Updates
packages/mcp/src/index.ts, packages/mcp/package.json
Replaced manual logger setup with configureLanguageServerLogger; added new CLI options for GraphViz and log level; switched to workspace-driven initialization via fromWorkspace(); added language-services dependency.
VSCode Extension Language Server
packages/vscode/src/node/language-server.ts, packages/vscode/src/node/mcp-server.ts, packages/vscode/src/node/useLanguageClient.ts
Added logger configuration with LSP connection; set log output to stderr; disabled internal logger configuration; added explicit Node runtime to language server invocation.
VSCode Extension Configuration
packages/vscode/language-configuration.json, packages/vscode/src/const.ts, packages/vscode/src/node/useMcpRegistration.ts, packages/vscode/src/panel/writeHTMLToWebview.ts
Updated auto-closing and surrounding pairs to structured object format with notIn constraints; refined glob pattern to require at least one character in filename; added fonts stylesheet link; added commented code for future configurations.
VSCode Extension Build
packages/vscode/tsdown.config.ts, packages/vscode/turbo.json, packages/vscode/package.json, packages/vscode/scripts/package-vsix.mts
Moved inlineOnly to shared config; added noExternal for browser targets; added likec4#build-cli dependency to build task; introduced new package task; added package script alias.
Vite Plugin & Styles
packages/vite-plugin/src/plugin.ts, styled-system/preset/src/recipes/likec4tag.ts
Added explicit console logger configuration to fromWorkspace; fixed LikeC4 tag background color from inherit to tokenized likec4.tag.bg.
Fonts & Styling
packages/vscode-preview/index.html, packages/vscode-preview/src/fonts.css, packages/vscode-preview/src/index.css, packages/vscode-preview/vite.config.ts
Extracted IBM Plex Sans Variable font-face declarations to separate fonts.css; added stylesheet link; removed font import from index.css; enabled CSS code splitting and added multiple entry points.
Log Package
packages/log/package.json
Moved @logtape/logtape from dependencies to devDependencies.
Language Services Package
packages/language-services/package.json
Added ufo as a dependency.
Diagram Component
packages/diagram/package.json, packages/diagram/src/navigationpanel/*
Removed @types/react and @types/react-dom peer dependencies; removed AnimatePresence propagation/wait mode; improved key stability in drift components; simplified motion div layout handling; removed enableReadOnly dependency from walkthrough controls.

Sequence Diagram

sequenceDiagram
    actor User
    participant CLI as CLI (likec4 lsp)
    participant LSP as LSP Server
    participant Services as Language Services
    participant GraphViz as GraphViz (wasm/binary)
    participant Logger as Logger

    User->>CLI: Run likec4 lsp --transport stdio
    CLI->>Logger: configureLanguageServerLogger(options)
    Logger->>Logger: Setup sinks (stderr/console/telemetry)
    CLI->>Services: createLanguageServices(options)
    Services->>Services: Include WithGraphviz(adapter)
    Services->>GraphViz: Initialize (GraphvizWasmAdapter or GraphvizBinaryAdapter)
    CLI->>LSP: startLanguageServer(connection, options)
    LSP->>Services: Use initialized services with pluggable GraphViz
    LSP->>Logger: Emit trace logs for port name and lifecycle
    User->>LSP: Send LSP requests (didOpen, hover, etc.)
    LSP->>Services: Delegate to language services
    Services->>GraphViz: Layout views with selected adapter
    GraphViz->>GraphViz: Perform layout (dot to JSON)
    Services->>LSP: Return results
    LSP->>User: Send LSP responses
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Poem

🐰 The language server hops into the CLI,
No more bundled standalone—wave bye-bye!
GraphViz adapters now swappable and free,
Loggers configured with grace, structured as can be.
From forest of files emerges clarity,
One command to rule them: likec4 lsp 🎉

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Lsp refactor' is vague and overly generic, using non-descriptive terminology that does not clearly convey the main changes. Use a more specific title that highlights the primary change, such as 'feat: add likec4 lsp CLI command and deprecate standalone language server' or 'refactor: consolidate language server entry point to CLI'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description is comprehensive and well-organized, covering all major changes across multiple areas (CLI/Language Server, Dependencies, UI/UX). However, it does not follow the provided template structure with the required checklist sections.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch lsp-refactor

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

Standalone Language Server fails to run

1 participant