Logo Langium

Langium

Tổ chức
eclipse-langium
langium

Build, fix, and improve Langium 4.x languages. Recipes, best practices, and troubleshooting for `.langium` grammars, scoping and cross-references, validation, LSP features (formatting, semantic tokens, code actions, hover, completion), code generators, `langium/test` tests, `langium-config.json`, and multi-language projects. Use when working in any project that depends on `langium` or `langium-cli`, or when a Langium language misbehaves (parse errors, unresolved references, missing diagnostics or editor features).

Tổng quan

Nhà phát hànheclipse-langium
Kho mãlangium-ai
Tên kỹ nănglangium
Sao
31
Bản fork
4
Tệp đi kèm
10
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI là Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 10 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được eclipse-langium công bố trên GitHub. Hãy đọc nội dung nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Langium trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL thư mục kỹ năng bên dưới và xác nhận.
    https://github.com/eclipse-langium/langium-ai/tree/main/skills/langium
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/eclipse-langium/langium-ai.git /tmp/langium-ai
mkdir -p .claude/skills
cp -r /tmp/langium-ai/skills/langium .claude/skills/langium
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Langium trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự tải Langium ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên Langium không bị giới hạn ở mô hình mà kỹ năng này được viết cho. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên kỹ năng chưa dùng không tốn chi phí.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Langium

Recipes, best practices, and fixes for building languages with Langium. This file routes you to the right reference. Read only the references your task needs.

Version

Written for Langium 4.x, verified against 4.4.0.

Check the version first: node_modules/langium/package.json (or the langium dependency in package.json). If the project uses Langium 3.x or earlier, this skill does not apply. Say so, and recommend upgrading to 4.x before using these recipes. Differences between 4.x minor versions are listed in references/troubleshooting.md.

Orienting in a project

A typical project (scaffolded with yo langium) contains:

WhatWhere to look
Grammarsrc/**/*.langium (path set in langium-config.json)
Generator configlangium-config.json if it exists, otherwise the "langium" key in package.json. If both exist, the CLI ignores the package.json key (unless --file points elsewhere)
Generated codesrc/**/generated/ (ast.ts, grammar.ts, module.ts). Never edit by hand
DI modulesrc/**/<language>-module.ts with create<Language>Services
Validatorssrc/**/<language>-validator.ts
Language server entrysrc/**/main.ts calling startLanguageServer
CLI entry and generatorsrc/cli/main.ts, src/cli/generator.ts
Teststest/**/*.test.ts (vitest)

Regenerate after every grammar or config change: npm run langium:generate (runs langium generate), or npm run langium:watch while editing.

Task router

If you need to...Read
Diagnose any misbehavior (parse errors, unresolved references, silent validators, missing editor features, slowness)references/troubleshooting.md
Write or change grammar rules, expressions (infix), cross-references, types, terminalsreferences/grammar.md
Fix keyword/terminal conflicts, keywords as identifiers, indentation-sensitive or case-insensitive lexing, value conversionreferences/grammar.md
Scaffold a project, configure langium-config.json, run the CLI, wire DI modules, override a service, bundlereferences/project-setup.md
Pick the right import (langium, langium/lsp, langium/node, ...) or file systemreferences/project-setup.md
Add qualified names, imports between files, member access (a.b.c), a builtin library, custom scopingreferences/scoping.md
Fix "Could not resolve reference"references/scoping.md (after references/troubleshooting.md)
Add validation checks, uniqueness checks, document hooks, slow or custom categories, diagnostic codesreferences/validation.md
Add a formatter, semantic tokens, code actions, hover, completion tweaks, inlay hints, signature help, code lensreferences/lsp-features.md
Generate code or text from the AST, write a CLI generator, add tracingreferences/code-generation.md
Write tests for parsing, linking, validation, or LSP featuresreferences/testing.md
Put several languages in one project, reference across languagesreferences/multi-language.md
Understand build phases, DocumentState, DI cycles, generated ast.ts, AST utilitiesreferences/how-langium-works.md

Mental model

.langium grammar ──langium generate──▶ generated/ast.ts, grammar.ts, module.ts
                                              │
create<Language>Services: inject(default modules, generated modules, your module)
                                              │
DocumentBuilder runs each document through:
  Changed → Parsed → IndexedContent → ComputedScopes → Linked → IndexedReferences → Validated
                                              │
LSP requests (hover, completion, ...) wait for the state they need, then call providers

Every behavior is a service. To change behavior, extend the Default* class and register it in your module. Details: references/how-langium-works.md.

Golden rules

  • Regenerate after every grammar edit. Never edit files in generated/.
  • Change behavior by overriding services in your DI module, never by patching Langium or generated code.
  • Extend the Default* implementation and override one method instead of reimplementing an interface.
  • Never resolve references (ref) inside collectExportedSymbols or collectLocalSymbols. Scopes aren't ready yet, so the result is undefined or bound to the wrong target.
  • In an infix rule the first operator group binds tightest. Right associativity is written right assoc '^'.
  • Optional LSP providers (formatter, semantic tokens, code actions, ...) do nothing until registered in the lsp section of your module.
  • Language servers use createDefaultModule / createDefaultSharedModule from langium/lsp. Headless tools may use the Core variants from langium.
  • slow and custom validation categories never run on document updates (updates run only built-in and fast). Trigger them explicitly.
  • Add a langium/test test for every scoping or validation change.
  • Check parser and lexer errors before trusting an AST. After errors the AST is partial.

Entry points

Import fromUse for
langiumCore types and services, inject, Module, AstUtils, CstUtils, URI, EmptyFileSystem, createDefaultCoreModule
langium/lspcreateDefaultModule, createDefaultSharedModule, startLanguageServer, LSP provider base classes (AbstractFormatter, AbstractSemanticTokenProvider, DefaultCompletionProvider, ...)
langium/nodeNodeFileSystem for Node.js language servers and CLIs
langium/testparseHelper, validationHelper, expectError, expectCompletion, ...
langium/generateexpandToNode, joinToNode, toString, tracing
langium/grammarServices for the Langium grammar language itself (rarely needed)

Use NodeFileSystem for language servers and CLIs that read files from disk. Use EmptyFileSystem in the browser and in all tests, including vitest tests, which run in Node.js but work on in-memory documents.

Reading the source and examples

Langium publishes its TypeScript sources, so read node_modules/langium/src/<area>/ to see the Default* implementation before overriding it (references/, validation/, lsp/, workspace/, parser/, generate/, test/).

Canonical examples at eclipse-langium/langium/examples:

ExampleShows
domainmodelQualified names, custom scoping, formatter, rename, builtin library
arithmeticsinfix expressions, code actions, case-insensitive keywords, interpreter
requirementsTwo languages in one project with cross-language references
statemachineMinimal language with a code generator

Related skills

  • lai: the langium-ai CLI for descriptors, system prompts, and evaluations of LLM output in Langium projects.

Tệp đi kèm

Mô hình đọc các tệp này khi cần trong lúc kỹ năng được tải. Các tệp được cung cấp ở dạng có thể đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Langium làm được gì?

Build, fix, and improve Langium 4.x languages. Recipes, best practices, and troubleshooting for `.langium` grammars, scoping and cross-references, validation, LSP features (formatting, semantic tokens, code actions, hover, completion), code generators, `langium/test` tests, `langium-config.json`, and multi-language projects. Use when working in any project that depends on `langium` or `langium-cli`, or when a Langium language misbehaves (parse errors, unresolved references, missing diagnostics or editor features).

Vì sao nên dùng Langium trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Langium là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Langium trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/eclipse-langium/langium-ai/tree/main/skills/langium. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm và cài đặt thành một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Langium?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Bạn có thể dùng Langium với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Langium với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Langium có miễn phí không?

Có. Kỹ năng này được eclipse-langium phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp cho mô hình các công cụ mới để gọi — mã được chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và tiêu chí của đầu ra tốt. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇