lai
Guide for using the langium-ai (LAI) CLI to generate language descriptors, synthesize system prompts, run evaluations, and iteratively refine AI-powered tooling in Langium projects. Use when working with lai commands, descriptors, or evaluation files.
eclipse-langium · 已有静态检查记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add eclipse-langium/langium-ai --skill lai技能说明
name: lai description: Guide for using the langium-ai (LAI) CLI to generate language descriptors, synthesize system prompts, run evaluations, and iteratively refine AI-powered tooling in Langium projects. Use when working with lai commands, descriptors, or evaluation files. user-invocable: false
langium-ai CLI (LAI) - Usage Guide
A CLI for bootstrapping AI-powered tooling in Langium projects. It generates language descriptors from your project structure, synthesizes system prompts from those descriptors, and runs evaluations to measure prompt quality — forming a refinement loop where you iteratively improve your descriptor and prompts based on evaluation results.
Workflow Overview
The core workflow is a loop:
init → generate descriptor → refine descriptor → generate sysprompt → evaluate → analyze results → refine → repeat
- Initialize (
lai init) — one-time project setup - Generate descriptor (
lai gen descriptor) — map your Langium project into a structured YAML descriptor - Validate descriptor (
lai validate) — check the descriptor schema and verify all referenced files exist - Refine the descriptor — manually correct and enrich the generated descriptor so it accurately represents your language
- Generate system prompt (
lai gen sysprompt) — produce a system prompt from the descriptor - Evaluate (
lai evaluate) — run evaluation cases against the system prompt via your configured LLM - Analyze results — use
lai show,lai compare,lai stats,lai historyto understand what passed and failed - Refine and repeat — adjust the descriptor, or evaluation cases, then regenerate and re-evaluate
Step 1: Initialize
lai init
Interactive setup that:
- Detects your Langium project structure (grammar files, langium-config.json, custom services)
- Detects your registered languages from
langium-config.json - Creates
lai.config.jsoncwith detected paths - Sets up an
evals/directory with starter template files (utils.tsandbasic.eval.ts)
Your LLM provider (OpenAI, Anthropic, Ollama, etc.) is not configured here — it's wired up in evals/utils.ts by implementing generateResponse(). Pass -y/--yes to skip all prompts and use defaults (non-interactive/CI).
Reinitializing Parts of the Setup
If you need to reinitialize just the config or just the evals without running the full init flow:
# reinitialize only the lai.config.jsonc file (re-detects project structure)
lai init config
# reinitialize only the evals/ directory and regenerate template files
# requires an existing lai.config.jsonc — run `lai init` first if you don't have one
lai init evals
# all init variants accept -y/--yes for non-interactive/CI use
lai init --yes
lai init config re-detects your Langium project structure and regenerates lai.config.jsonc. This is useful if your project structure has changed (e.g., moved grammar files or added new services) and you want to update the config without touching evals.
lai init evals regenerates the evals/ directory with fresh template files (utils.ts and basic.eval.ts). It prompts before overwriting basic.eval.ts if it already exists. This is useful if templates have been updated in a newer version of LAI or if you want a clean starting point for your evaluations.
The resulting lai.config.jsonc looks like:
{
"version": "1.0",
"langium": {
"configPath": "./langium-config.json",
// one entry per registered language (multi-language projects list several)
"languages": [
{
"id": "my-dsl",
"grammarPath": "./src/grammar/my-dsl.langium",
"caseInsensitive": false
}
]
},
"descriptor": {
"path": "language.descriptor.yml"
},
"sysprompt": {
"path": "language.sysprompt.md"
},
"evaluations": {
"directory": "evals"
},
"project": {
"name": "my-dsl"
}
}
Step 2: Generate a Descriptor
# generate from project analysis (uses LLM to synthesize)
lai gen descriptor
# regenerate from scratch, ignoring the existing descriptor
lai gen descriptor --fresh
# skip prompts / auto-accept defaults (non-interactive/CI)
lai gen descriptor --yes
Produces language.descriptor.yml — a structured YAML file that maps your Langium project. The descriptor is the single source of truth that drives all prompt generation.
Descriptor Structure
A compact overview (see the lai-gen-descriptor skill for deep detail):
version: 1.0 # LAI version that generated this descriptor
# langium project references
langium_config: ./langium-config.json
# registered languages (array; multi-language projects list several)
languages:
- name: my-dsl
description: A domain-specific language for ...
caseInsensitive: false
grammar: ./src/grammar/my-dsl.langium
# built-in grammar/type files always in scope (string array)
builtins:
- ./src/builtins/my-dsl-builtins.langium
# details about how services are instantiated (used for eval generation)
serviceDetails:
createServicesFunc: createMyDslServices
createServicesAttributes: [MyDsl]
# custom langium services — only include what exists (snake_case keys)
services:
# validators are a list; each may name the language it validates
validators:
- language: my-dsl
path: ./src/validation/my-dsl-validator.ts
scope_provider: ./src/scoping/my-dsl-scope-provider.ts
token_builder: ./src/my-dsl-token-builder.ts
# many other optional services: module, scope_computation, linker,
# name_provider, type_provider, value_converter, hover_provider, etc.
# language test directories (string array)
tests:
- ./test/
# examples
examples:
- name: Basic Example
description: A simple program demonstrating core syntax.
file: ./examples/basic.mydsl
tags: [beginner, syntax]
# external documentation
documentation:
- src: https://my-dsl-docs.example.com/guide/
description: Comprehensive language guide.
阅读完整来源 ↗