Skip to content

Conversation

@ymc9
Copy link
Member

@ymc9 ymc9 commented Jun 16, 2025

Summary by CodeRabbit

  • New Features
    • Introduced a VSCode extension providing language support for ZenStack ZModel, including syntax highlighting, language configuration, and language server integration.
  • Chores
    • Added new configuration and build files for the VSCode extension and updated workspace settings to include new packages.
    • Updated licensing information and improved package publishing configuration.
  • Refactor
    • Improved directory resolution for better cross-environment compatibility.
    • Enhanced language service injection and workspace management for the language server.
  • Style
    • Updated .gitignore to exclude new directories from version control.

@coderabbitai
Copy link

coderabbitai bot commented Jun 16, 2025

Walkthrough

This update introduces a new VSCode extension for the ZenStack ZModel language, including its extension and language server implementations, configuration, and packaging. The build and workspace setups are expanded to support the new IDE package. Enhancements to the language package improve module system compatibility and workspace management, notably with a custom workspace manager for loading standard libraries.

Changes

File(s) Change Summary
.vscode/launch.json Added debug configurations for running the extension and attaching to the language server.
package.json Changed license from "ISC" to "MIT".
pnpm-workspace.yaml Included all subdirectories under packages/ide in the workspace.
packages/ide/vscode/package.json Added VSCode extension manifest for ZenStack ZModel language support.
packages/ide/vscode/LICENSE Added LICENSE file referencing the root license.
packages/ide/vscode/.gitignore Added "syntaxes/" to ignore syntax files in version control.
packages/ide/vscode/language-configuration.json Added language configuration for comments, brackets, auto-closing, and word patterns.
packages/ide/vscode/src/extension/main.ts Added extension activation/deactivation logic and language client setup for VSCode.
packages/ide/vscode/src/language-server/main.ts Added language server entry point initializing and starting the server for ZModel.
packages/ide/vscode/tsconfig.json Added TypeScript configuration extending base config and outputting to dist.
packages/ide/vscode/tsup.config.ts Added build configuration for bundling extension and language server with tsup.
packages/ide/vscode/res, packages/ide/vscode/syntaxes Added files referencing shared resources and syntaxes.
packages/language/package.json Updated exports for ESM/CJS compatibility and included "res" in published files.
packages/language/src/index.ts Refactored to use a cross-environment compatible directory resolution for standard library path.
packages/language/src/module.ts Added ZModelSharedModule, type alias, and injected custom workspace manager into service creation.
packages/language/src/zmodel-workspace-manager.ts Added ZModelWorkspaceManager class to load standard library from installed package or fallback.
packages/language/tsup.config.ts Simplified build config, removed resource copying, and added CJS output format.

Sequence Diagram(s)

sequenceDiagram
    participant VSCode
    participant Extension (main.ts)
    participant LanguageClient
    participant LanguageServer (main.ts)
    participant Services

    VSCode->>Extension (main.ts): Activate extension
    Extension (main.ts)->>LanguageClient: Initialize with server module path
    LanguageClient->>LanguageServer (main.ts): Start language server process
    LanguageServer (main.ts)->>Services: Create language services (includes custom workspace manager)
    LanguageClient-->>VSCode: Provide language features (completion, diagnostics, etc.)
    VSCode->>Extension (main.ts): Deactivate extension
    Extension (main.ts)->>LanguageClient: Stop language client
Loading

Poem

In the warren of code, a new path appears,
With ZModel support for VSCode, let's cheer!
Language server hops in, extension takes flight,
Syntax and comments now colored just right.
The workspace expands, the stdlib is found—
A bunny’s delight as new features abound!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🔭 Outside diff range comments (1)
packages/ide/vscode/LICENSE (1)

1-2: ⚠️ Potential issue

License file should include actual text instead of a relative path
Referencing ../../../LICENSE won’t resolve in the published extension package. Please embed or copy the full MIT license text here so it’s properly included.

🧹 Nitpick comments (9)
packages/ide/vscode/syntaxes (1)

1-1: Ensure this is a valid symlink or packaged correctly
This appears to be a pointer to the shared syntax definitions, but VSCode expects concrete grammar files under a syntaxes directory. Confirm that this is committed as a filesystem symlink (not a plain text file) and that your build/publish process resolves the link so that the extension includes the actual JSON grammars. Otherwise, consider adding a copy step in your build to place the language/syntaxes files into the extension's syntaxes folder.

packages/ide/vscode/src/language-server/main.ts (1)

1-7: Nit: import from vscode-languageserver/node instead of node.js

The file extension can be omitted; vscode-languageserver/node is the documented entry and avoids potential bundler resolution quirks.

-import {
-    createConnection,
-    ProposedFeatures,
-} from 'vscode-languageserver/node.js';
+import { createConnection, ProposedFeatures } from 'vscode-languageserver/node';
packages/ide/vscode/language-configuration.json (1)

15-22: Block‐comment pair is not auto-closed

autoClosingPairs contains a special entry for /** … */ but omits the ordinary /* … */ block comment that users will type far more often. Align this list with the language’s comment syntax to avoid a jarring authoring experience.

         ["(", ")"],
         ["\"", "\""],
         ["'", "'"],
+        ["/*", "*/"],
         { "open": "/**", "close": " */", "notIn": ["string"] }
packages/language/src/index.ts (1)

48-56: Avoid recomputing _dirname on every loadDocument invocation

_dirname is a module-level constant; putting the calculation inside the function means it is recomputed every time the helper is called. Moving it to the top scope shaves unnecessary work (and clarifies intent).

-    // isomorphic __dirname
-    const _dirname =
-        typeof __dirname !== 'undefined'
-            ? __dirname
-            : path.dirname(fileURLToPath(import.meta.url));
+// isomorphic __dirname
+const _dirname =
+    typeof __dirname !== 'undefined'
+        ? __dirname
+        : path.dirname(fileURLToPath(import.meta.url));
+
+
+
+    // load standard library
.vscode/launch.json (1)

48-70: Globs in outFiles lack a wildcard and may break source-map lookup

"${workspaceFolder}/packages/ide/vscode/node_modules/langium" points to a folder, not to compiled .js files.
VS Code’s debugger expects a glob such as **/*.js; without it, breakpoints inside Langium sources won’t bind.

-                "${workspaceFolder}/packages/ide/vscode/node_modules/langium"
+                "${workspaceFolder}/packages/ide/vscode/node_modules/langium/**/*.js"
packages/language/src/module.ts (1)

55-64: Redundant type alias can be dropped

export type ZModelSharedServices = LangiumSharedServices; is a straight alias with no added semantic meaning and risks bit-rot if the upstream type changes. Unless it’s required by external consumers, consider removing the alias and using LangiumSharedServices directly.

packages/language/src/zmodel-workspace-manager.ts (3)

55-58: Avoid console.log in library code

Language-server output should be routed through the LSP connection’s logger or services.logger so that messages appear in the client’s output channel and respect user log-level preferences.

-                    console.log(
-                        `Found installed zenstack package stdlib at: ${installedStdlibPath}`
-                    );
+                    this.services.shared.logger.debug(
+                        () => `Found installed zenstack package stdlib at: ${installedStdlibPath}`
+                    );

60-63: Redundant continue statement

The continue at the end of the catch block is unnecessary; control flow proceeds to the next iteration anyway.

-            } catch (error) {
-                // Package not found or other error, continue to next folder
-                continue;
-            }
+            } catch {
+                // Package not found, try next folder
+            }
🧰 Tools
🪛 Biome (1.9.4)

[error] 62-62: Unnecessary continue statement

Unsafe fix: Delete the unnecessary continue statement

(lint/correctness/noUnnecessaryContinue)


80-82: Potential duplicate loading of stdlib document

loadAdditionalDocuments is invoked for every workspace refresh. Without a guard, the same stdlib document can be collected repeatedly, wasting memory and analysis time. Consider caching the URI or checking documents.has(uri) before collecting.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 53bf171 and 949f63c.

⛔ Files ignored due to path filters (4)
  • packages/ide/vscode/asset/logo-256-bg.png is excluded by !**/*.png
  • packages/ide/vscode/asset/logo-dark-256.png is excluded by !**/*.png
  • packages/ide/vscode/asset/logo-light-256.png is excluded by !**/*.png
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (18)
  • .vscode/launch.json (1 hunks)
  • package.json (1 hunks)
  • packages/ide/vscode/.gitignore (1 hunks)
  • packages/ide/vscode/LICENSE (1 hunks)
  • packages/ide/vscode/language-configuration.json (1 hunks)
  • packages/ide/vscode/package.json (1 hunks)
  • packages/ide/vscode/res (1 hunks)
  • packages/ide/vscode/src/extension/main.ts (1 hunks)
  • packages/ide/vscode/src/language-server/main.ts (1 hunks)
  • packages/ide/vscode/syntaxes (1 hunks)
  • packages/ide/vscode/tsconfig.json (1 hunks)
  • packages/ide/vscode/tsup.config.ts (1 hunks)
  • packages/language/package.json (2 hunks)
  • packages/language/src/index.ts (1 hunks)
  • packages/language/src/module.ts (4 hunks)
  • packages/language/src/zmodel-workspace-manager.ts (1 hunks)
  • packages/language/tsup.config.ts (1 hunks)
  • pnpm-workspace.yaml (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (4)
packages/language/src/index.ts (1)
packages/language/src/constants.ts (1)
  • STD_LIB_MODULE_NAME (30-30)
packages/language/src/module.ts (2)
packages/language/src/zmodel-workspace-manager.ts (1)
  • ZModelWorkspaceManager (15-83)
packages/language/src/generated/module.ts (1)
  • ZModelGeneratedSharedModule (17-19)
packages/language/src/zmodel-workspace-manager.ts (1)
packages/language/src/constants.ts (1)
  • STD_LIB_MODULE_NAME (30-30)
packages/ide/vscode/src/language-server/main.ts (1)
packages/language/src/module.ts (1)
  • createZModelLanguageServices (81-105)
🪛 Biome (1.9.4)
packages/language/src/zmodel-workspace-manager.ts

[error] 62-62: Unnecessary continue statement

Unsafe fix: Delete the unnecessary continue statement

(lint/correctness/noUnnecessaryContinue)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build-test (20.x)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (9)
pnpm-workspace.yaml (1)

7-7: Approve inclusion of IDE packages
Adding packages/ide/** ensures the newly introduced VSCode extension and any future IDE tools are recognized by pnpm workspace.

packages/language/package.json (2)

8-10: Include resource directory for packaging
Adding "res" to the files array guarantees the standard library assets are bundled alongside dist.


23-42: Verify dual module export mappings
Ensure that both ESM (.js/.d.ts) and CJS (.cjs/.d.cts) files exist post-build for the . and ./ast exports. Mismatches will cause runtime resolution failures.

package.json (1)

16-16: Update project license to MIT
Changing the root license field from ISC to MIT aligns with the repository’s license and downstream packages.

packages/ide/vscode/res (1)

1-1: Verify resource link and packaging configuration.

Ensure the relative path (../../language/res) resolves correctly in the published VSCode extension across all platforms. Confirm that both this file and the target language/res directory are included via your package.json files field and bundler settings.

packages/ide/vscode/.gitignore (1)

1-1: Verify .gitignore exclusion does not drop grammar files from the VSIX

vsce uses .gitignore as a basis for packaging filters.
If the syntaxes/ directory (or a symlink pointing to the grammar) is ignored here, the compiled VSIX may miss the zmodel.tmLanguage.json, breaking syntax highlighting for users.

Confirm that the grammar is still included in the published extension (or move the rule to .vscodeignore, which is safer for VSIX packaging).

packages/ide/vscode/tsconfig.json (1)

1-7: Looks good – baseline TS config is minimal but sufficient

The file cleanly extends the repo-level tsconfig.json and only overrides outDir, keeping the IDE package simple.
No issues spotted.

packages/language/tsup.config.ts (1)

13-13: Double-check package.json exports after adding CommonJS build

format: ['esm', 'cjs'] will emit two artifact sets. Ensure packages/language/package.json now exposes a require path (e.g. "./dist/index.cjs" or "./dist/index.js" under "default" / "require" fields) so downstream Node consumers resolve the intended file instead of the ESM build by accident.

packages/ide/vscode/package.json (1)

18-19: Bundle vsce locally or call it via pnpm dlx

The publish / package scripts assume that vsce is globally installed. CI/CD or new contributors may not have it, causing the task to fail.

Either:

-    "vscode:publish": "pnpm build && vsce publish --no-dependencies --pre-release --follow-symlinks",
-    "vscode:package": "pnpm build && vsce package --no-dependencies"
+    "vscode:publish": "pnpm build && pnpm dlx vsce publish --no-dependencies --pre-release --follow-symlinks",
+    "vscode:package": "pnpm build && pnpm dlx vsce package --no-dependencies"

or add "vsce": "^3.23.0" to devDependencies.

@ymc9 ymc9 merged commit c519480 into dev Jun 16, 2025
5 checks passed
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.

2 participants