sysml-v2-lsp 0.1.6 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/CHANGELOG.md +26 -90
  2. package/README.md +63 -264
  3. package/dist/server/mcpServer.mjs +20 -20
  4. package/dist/server/parser/parseWorker.mjs +11 -11
  5. package/dist/server/server.mjs +80 -67
  6. package/package.json +2 -2
  7. package/sysml.library/.project +17 -0
  8. package/sysml.library/.settings/org.eclipse.jdt.core.prefs +11 -0
  9. package/sysml.library/Domain Libraries/Analysis/.meta.json +10 -0
  10. package/sysml.library/Domain Libraries/Analysis/.project.json +27 -0
  11. package/sysml.library/Domain Libraries/Analysis/AnalysisTooling.sysml +34 -0
  12. package/sysml.library/Domain Libraries/Analysis/SampledFunctions.sysml +119 -0
  13. package/sysml.library/Domain Libraries/Analysis/StateSpaceRepresentation.sysml +143 -0
  14. package/sysml.library/Domain Libraries/Analysis/TradeStudies.sysml +171 -0
  15. package/sysml.library/Domain Libraries/Cause and Effect/.meta.json +8 -0
  16. package/sysml.library/Domain Libraries/Cause and Effect/.project.json +23 -0
  17. package/sysml.library/Domain Libraries/Cause and Effect/CausationConnections.sysml +83 -0
  18. package/sysml.library/Domain Libraries/Cause and Effect/CauseAndEffect.sysml +81 -0
  19. package/sysml.library/Domain Libraries/Geometry/.meta.json +8 -0
  20. package/sysml.library/Domain Libraries/Geometry/.project.json +27 -0
  21. package/sysml.library/Domain Libraries/Geometry/ShapeItems.sysml +899 -0
  22. package/sysml.library/Domain Libraries/Geometry/SpatialItems.sysml +168 -0
  23. package/sysml.library/Domain Libraries/Metadata/.meta.json +10 -0
  24. package/sysml.library/Domain Libraries/Metadata/.project.json +19 -0
  25. package/sysml.library/Domain Libraries/Metadata/ImageMetadata.sysml +78 -0
  26. package/sysml.library/Domain Libraries/Metadata/ModelingMetadata.sysml +143 -0
  27. package/sysml.library/Domain Libraries/Metadata/ParametersOfInterestMetadata.sysml +39 -0
  28. package/sysml.library/Domain Libraries/Metadata/RiskMetadata.sysml +100 -0
  29. package/sysml.library/Domain Libraries/Quantities and Units/.meta.json +29 -0
  30. package/sysml.library/Domain Libraries/Quantities and Units/.project.json +23 -0
  31. package/sysml.library/Domain Libraries/Quantities and Units/ISQ.sysml +42 -0
  32. package/sysml.library/Domain Libraries/Quantities and Units/ISQAcoustics.sysml +439 -0
  33. package/sysml.library/Domain Libraries/Quantities and Units/ISQAtomicNuclear.sysml +2726 -0
  34. package/sysml.library/Domain Libraries/Quantities and Units/ISQBase.sysml +206 -0
  35. package/sysml.library/Domain Libraries/Quantities and Units/ISQCharacteristicNumbers.sysml +1991 -0
  36. package/sysml.library/Domain Libraries/Quantities and Units/ISQChemistryMolecular.sysml +1353 -0
  37. package/sysml.library/Domain Libraries/Quantities and Units/ISQCondensedMatter.sysml +1223 -0
  38. package/sysml.library/Domain Libraries/Quantities and Units/ISQElectromagnetism.sysml +2333 -0
  39. package/sysml.library/Domain Libraries/Quantities and Units/ISQInformation.sysml +958 -0
  40. package/sysml.library/Domain Libraries/Quantities and Units/ISQLight.sysml +1537 -0
  41. package/sysml.library/Domain Libraries/Quantities and Units/ISQMechanics.sysml +1564 -0
  42. package/sysml.library/Domain Libraries/Quantities and Units/ISQSpaceTime.sysml +1169 -0
  43. package/sysml.library/Domain Libraries/Quantities and Units/ISQThermodynamics.sysml +1256 -0
  44. package/sysml.library/Domain Libraries/Quantities and Units/MeasurementRefCalculations.sysml +30 -0
  45. package/sysml.library/Domain Libraries/Quantities and Units/MeasurementReferences.sysml +526 -0
  46. package/sysml.library/Domain Libraries/Quantities and Units/Quantities.sysml +107 -0
  47. package/sysml.library/Domain Libraries/Quantities and Units/QuantityCalculations.sysml +70 -0
  48. package/sysml.library/Domain Libraries/Quantities and Units/SI.sysml +378 -0
  49. package/sysml.library/Domain Libraries/Quantities and Units/SIPrefixes.sysml +48 -0
  50. package/sysml.library/Domain Libraries/Quantities and Units/TensorCalculations.sysml +50 -0
  51. package/sysml.library/Domain Libraries/Quantities and Units/Time.sysml +274 -0
  52. package/sysml.library/Domain Libraries/Quantities and Units/USCustomaryUnits.sysml +260 -0
  53. package/sysml.library/Domain Libraries/Quantities and Units/VectorCalculations.sysml +62 -0
  54. package/sysml.library/Domain Libraries/Requirement Derivation/.meta.json +8 -0
  55. package/sysml.library/Domain Libraries/Requirement Derivation/.project.json +19 -0
  56. package/sysml.library/Domain Libraries/Requirement Derivation/DerivationConnections.sysml +63 -0
  57. package/sysml.library/Domain Libraries/Requirement Derivation/RequirementDerivation.sysml +39 -0
  58. package/sysml.library/Kernel Libraries/Kernel Data Type Library/.meta.json +9 -0
  59. package/sysml.library/Kernel Libraries/Kernel Data Type Library/.project.json +11 -0
  60. package/sysml.library/Kernel Libraries/Kernel Data Type Library/Collections.kerml +147 -0
  61. package/sysml.library/Kernel Libraries/Kernel Data Type Library/ScalarValues.kerml +23 -0
  62. package/sysml.library/Kernel Libraries/Kernel Data Type Library/VectorValues.kerml +64 -0
  63. package/sysml.library/Kernel Libraries/Kernel Function Library/.meta.json +23 -0
  64. package/sysml.library/Kernel Libraries/Kernel Function Library/.project.json +15 -0
  65. package/sysml.library/Kernel Libraries/Kernel Function Library/BaseFunctions.kerml +80 -0
  66. package/sysml.library/Kernel Libraries/Kernel Function Library/BooleanFunctions.kerml +22 -0
  67. package/sysml.library/Kernel Libraries/Kernel Function Library/CollectionFunctions.kerml +68 -0
  68. package/sysml.library/Kernel Libraries/Kernel Function Library/ComplexFunctions.kerml +47 -0
  69. package/sysml.library/Kernel Libraries/Kernel Function Library/ControlFunctions.kerml +117 -0
  70. package/sysml.library/Kernel Libraries/Kernel Function Library/DataFunctions.kerml +43 -0
  71. package/sysml.library/Kernel Libraries/Kernel Function Library/IntegerFunctions.kerml +43 -0
  72. package/sysml.library/Kernel Libraries/Kernel Function Library/NaturalFunctions.kerml +27 -0
  73. package/sysml.library/Kernel Libraries/Kernel Function Library/NumericalFunctions.kerml +43 -0
  74. package/sysml.library/Kernel Libraries/Kernel Function Library/OccurrenceFunctions.kerml +154 -0
  75. package/sysml.library/Kernel Libraries/Kernel Function Library/RationalFunctions.kerml +49 -0
  76. package/sysml.library/Kernel Libraries/Kernel Function Library/RealFunctions.kerml +56 -0
  77. package/sysml.library/Kernel Libraries/Kernel Function Library/ScalarFunctions.kerml +33 -0
  78. package/sysml.library/Kernel Libraries/Kernel Function Library/SequenceFunctions.kerml +111 -0
  79. package/sysml.library/Kernel Libraries/Kernel Function Library/StringFunctions.kerml +25 -0
  80. package/sysml.library/Kernel Libraries/Kernel Function Library/TrigFunctions.kerml +35 -0
  81. package/sysml.library/Kernel Libraries/Kernel Function Library/VectorFunctions.kerml +273 -0
  82. package/sysml.library/Kernel Libraries/Kernel Semantic Library/.meta.json +22 -0
  83. package/sysml.library/Kernel Libraries/Kernel Semantic Library/.project.json +15 -0
  84. package/sysml.library/Kernel Libraries/Kernel Semantic Library/Base.kerml +95 -0
  85. package/sysml.library/Kernel Libraries/Kernel Semantic Library/Clocks.kerml +156 -0
  86. package/sysml.library/Kernel Libraries/Kernel Semantic Library/ControlPerformances.kerml +135 -0
  87. package/sysml.library/Kernel Libraries/Kernel Semantic Library/FeatureReferencingPerformances.kerml +190 -0
  88. package/sysml.library/Kernel Libraries/Kernel Semantic Library/KerML.kerml +483 -0
  89. package/sysml.library/Kernel Libraries/Kernel Semantic Library/Links.kerml +67 -0
  90. package/sysml.library/Kernel Libraries/Kernel Semantic Library/Metaobjects.kerml +58 -0
  91. package/sysml.library/Kernel Libraries/Kernel Semantic Library/Objects.kerml +212 -0
  92. package/sysml.library/Kernel Libraries/Kernel Semantic Library/Observation.kerml +161 -0
  93. package/sysml.library/Kernel Libraries/Kernel Semantic Library/Occurrences.kerml +992 -0
  94. package/sysml.library/Kernel Libraries/Kernel Semantic Library/Performances.kerml +293 -0
  95. package/sysml.library/Kernel Libraries/Kernel Semantic Library/SpatialFrames.kerml +197 -0
  96. package/sysml.library/Kernel Libraries/Kernel Semantic Library/StatePerformances.kerml +145 -0
  97. package/sysml.library/Kernel Libraries/Kernel Semantic Library/Transfers.kerml +281 -0
  98. package/sysml.library/Kernel Libraries/Kernel Semantic Library/TransitionPerformances.kerml +66 -0
  99. package/sysml.library/Kernel Libraries/Kernel Semantic Library/Triggers.kerml +188 -0
  100. package/sysml.library/Systems Library/.meta.json +27 -0
  101. package/sysml.library/Systems Library/.project.json +19 -0
  102. package/sysml.library/Systems Library/Actions.sysml +552 -0
  103. package/sysml.library/Systems Library/Allocations.sysml +29 -0
  104. package/sysml.library/Systems Library/AnalysisCases.sysml +38 -0
  105. package/sysml.library/Systems Library/Attributes.sysml +25 -0
  106. package/sysml.library/Systems Library/Calculations.sysml +37 -0
  107. package/sysml.library/Systems Library/Cases.sysml +71 -0
  108. package/sysml.library/Systems Library/Connections.sysml +60 -0
  109. package/sysml.library/Systems Library/Constraints.sysml +44 -0
  110. package/sysml.library/Systems Library/Flows.sysml +126 -0
  111. package/sysml.library/Systems Library/Interfaces.sysml +89 -0
  112. package/sysml.library/Systems Library/Items.sysml +153 -0
  113. package/sysml.library/Systems Library/Metadata.sysml +32 -0
  114. package/sysml.library/Systems Library/Parts.sysml +81 -0
  115. package/sysml.library/Systems Library/Ports.sysml +54 -0
  116. package/sysml.library/Systems Library/Requirements.sysml +194 -0
  117. package/sysml.library/Systems Library/StandardViewDefinitions.sysml +123 -0
  118. package/sysml.library/Systems Library/States.sysml +103 -0
  119. package/sysml.library/Systems Library/SysML.sysml +539 -0
  120. package/sysml.library/Systems Library/UseCases.sysml +57 -0
  121. package/sysml.library/Systems Library/VerificationCases.sysml +103 -0
  122. package/sysml.library/Systems Library/Views.sysml +164 -0
package/CHANGELOG.md CHANGED
@@ -1,101 +1,37 @@
1
1
  # Changelog
2
2
 
3
- ## [0.1.6]
4
-
5
- ### Fixed
6
-
7
- - Fix keyword validator silently ignoring extreme typos (e.g., `pasddsafart def Vehicle`) — identifiers in keyword positions are now flagged even when no close keyword match exists (Levenshtein distance > 2), with a generic "Unexpected identifier" message instead of requiring a "Did you mean?" suggestion
8
- - Fix `flagUnknownIdentifiers` incorrectly skipping identifiers followed by `def` — valid keywords before `def` (`part`, `action`, etc.) have their own token types, so an IDENTIFIER before `def` is always invalid
9
- - Fix Python LSP client missing diagnostics on first run — `drain_notifications` used a fixed 2-second timeout, but DFA warm-up on first server start takes ~15-20s. Added `drain_until_diagnostics()` which waits up to 30s and stops as soon as diagnostics arrive
10
-
11
- ## [0.1.5]
3
+ ## [0.2.0]
12
4
 
13
5
  ### Added
14
6
 
15
- - Python LSP client example in `clients/python/` zero-dependency script demonstrating how to drive the SysML v2 language server from Python over JSON-RPC/stdio, using the same server as VS Code
16
- - `sysml.inlayHints.enabled` VS Code setting allows users to toggle inlay hints on/off (default: true). Server-side gating returns empty results when disabled
17
- - Extension Development Host settings (`examples/.vscode/settings.json`) disables inlay hints during F5 testing
18
- - Code completion provider tests ensures keyword completions, snippet insert text, and resolve are covered
19
- - Call hierarchy typed-usage detection — `action x : TypeDef`, `state x : TypeDef`, and `calc x : TypeDef` composition patterns are now recognised as outgoing/incoming calls, not just explicit `perform`/`include`/`accept` keywords
7
+ - Custom LSP request (`sysml/model`): full semantic model with scoped queries
8
+ - MCP server (`sysml-mcp` CLI): 7 tools, 3 resources, 3 prompts for AI-assisted modelling
9
+ - Standard library: 94 bundled SysML v2 / KerML files from OMG release repo
10
+ - Inlay hints: ghost text for inferred types and supertypes
11
+ - Call hierarchy: action call graph navigation
12
+ - Type hierarchy: specialization chain navigation
13
+ - Signature help: parameter tooltips for action/calc invocations
14
+ - Code lens: reference counts above definitions
15
+ - Document links: clickable `import` statements
16
+ - Workspace symbols: cross-document symbol search
17
+ - Linked editing ranges: simultaneous rename of all occurrences
18
+ - Selection ranges: smart expand/shrink selection
19
+ - Code actions: quick-fix actions for diagnostics
20
+ - Formatting: document and range formatting
21
+ - Keyword validation: typo detection with "did you mean?" suggestions
22
+ - npm package: `sysml-v2-lsp` distributable for third-party extensions
23
+ - Python LSP client: reference JSON-RPC/stdio client
24
+ - Parse worker: background ANTLR parsing with DFA warm-up
25
+ - `make update-library`: fetch latest standard library from upstream
26
+ - `make package-server` / `make test-package`: npm tarball build and validation
20
27
 
21
28
  ### Changed
22
29
 
23
- - Reorganise folder structure: `client/` `clients/vscode/`, Python client at `clients/python/`
24
- - Call hierarchy provider no longer depends on `TextDocuments` — uses `DocumentManager` for all text access, simplifying the architecture
25
- - `DocumentManager.getUris()` now returns all open documents (from `TextDocuments.all()`), not just cached ones — fixes providers that scan across documents (call hierarchy, references, code lens)
26
- - Suppress esbuild size warnings — custom build summary replaces default output to avoid misleading ⚠️ indicators on the expected 1.4 MB ANTLR parser bundle
27
-
28
- ### Fixed
29
-
30
- - Fix `end` keyword in connection/interface definitions causing false positive diagnostics — identifiers after `end` (e.g., `end source : PowerPort;`) were incorrectly flagged as keyword typos
31
- - Fix `in`/`out`/`inout` direction keywords causing false positive diagnostics — identifiers after `in`, `out`, `inout` (e.g., `out arrived : Boolean`) were incorrectly flagged as keyword typos
32
- - Fix Find References only returning declarations — added text-based reference scanning (`findTextReferences`) across all open documents to find usage-site references (e.g., `action adjustWheels : AdjustWheelAngle`)
33
- - Fix CodeLens reference counts only counting declarations — now uses text-based scanning consistent with Find References
34
- - Remove redundant `activationEvents` from `package.json` — VS Code auto-generates from `contributes.languages`
35
- - Remove unnecessary `sysml.inlayHints.enabled` from dev workspace settings (only needed in Extension Development Host)
36
-
37
- ## [0.1.4]
38
-
39
- ### Added
40
-
41
- - Extract MCP resource and prompt handler logic into testable `mcpCore.ts` module — 3 resource handlers (element kinds, keywords, grammar overview) and 3 prompt handlers (review SysML, explain element, generate SysML)
42
- - `constraint` grammar rules: `ConstraintDefinition`, `ConstraintUsage`, `RequirementConstraintMember`, `assert constraint`
43
- - 9 new unit tests for MCP resources and prompts (101 total tests, up from 92)
44
- - Constraint-related unit tests
45
-
46
- ### Fixed
47
-
48
- - Fix false positive diagnostics on qualified names with `::` (e.g., `toaster::maxTemp`) — add `COLON_COLON` to next-token skip list in `parseWorker.ts`
49
- - Fix identifiers after `actor`, `stakeholder`, `subject`, `variant`, `ref`, `snapshot`, `timeslice` incorrectly flagged as keyword typos — add to `NAME_PRECEDING_KEYWORDS` in both validators
50
- - Fix false positive keyword typo diagnostics on dot-chain and expression-position identifiers (e.g., `transportPassenger.driver`) — skip identifiers preceded by `.`, `=`, `:`, `::`, `:>`, `:>>`
51
- - Remove unused `parseAndBuild` import in `mcpServer.ts` after refactoring
52
-
53
- ### Changed
54
-
55
- - Slim VS Code dev extension to lightweight harness — move TextMate grammar and snippets to separate `VSCode_SysML_Extension` repo
56
- - Simplify `language-configuration.json` to minimal comments and brackets for dev use
57
-
58
- ## [0.1.3]
59
-
60
- ### Added
61
-
62
- - `make test-package` target to test npm package in a simulated consumer project
63
- - README badges: npm version, license, Socket.dev supply chain security
64
-
65
- ### Fixed
66
-
67
- - Fix `constructor.name` minification breaking code lens and symbol resolution — `getRuleName()` now uses ANTLR4 `ruleIndex` + `ruleNames[]` instead of `constructor.name` which is mangled by esbuild
68
- - Rename ESM bundles from `.js` to `.mjs` for Node 20 compatibility — `child_process.fork()` now correctly treats server and worker as ESM
69
- - Move `@modelcontextprotocol/sdk` and `zod` from `dependencies` to `devDependencies` — they are fully bundled by esbuild and not needed at runtime
70
- - Guard `postinstall` script with `[ -f tsconfig.json ]` so it only runs in dev checkout, not in consumer installs
71
-
72
- ## [0.1.2]
73
-
74
- ### Added
75
-
76
- - Release checklist (`.github/RELEASE_CHECKLIST.md`)
77
-
78
- ### Fixed
79
-
80
- - Remove unused `antlr4-c3` dependency from server package
81
- - Fix client extension server path to use bundled `dist/` output (VSIX was broken)
82
- - Fix `postinstall` script silently swallowing server install failures
83
- - Sync versions across `server/package.json`, `client/package.json`, and MCP server to `0.1.1`
84
- - Align Node engine requirement to `>=20` in `server/package.json` (was `>=18`)
85
- - Update esbuild target from `node18` to `node20`
86
- - Add `*.tgz` to `.gitignore` to prevent accidental commits
87
- - Add explicit `require`/`default` conditions to `exports` field
88
- - Remove redundant `activationEvents` (auto-generated from `contributes.languages`)
89
-
90
- ## [0.1.1]
91
-
92
- ### Fixed
93
-
94
- - Update postinstall script to handle missing `client` directory gracefully
95
- - Add npm trusted publishing (OIDC) support and normalize repository URL
96
- - Remove accidentally committed `.tgz` archive
97
- - Skip `npm version` in release workflow when git tag already matches `package.json`
98
- - Drop Node 18 from CI matrix (Vite 7 requires Node 20+)
30
+ - Go-to-definition falls back to standard library for unresolved symbols
31
+ - Recursive type name extraction in symbol table
32
+ - Synthetic `start`/`done` nodes in activity diagram flows
33
+ - Element kind enum expanded to 55 kinds
34
+ - esbuild bundles four targets: server, worker, MCP server, VS Code client
99
35
 
100
36
  ## [0.1.0]
101
37
 
package/README.md CHANGED
@@ -1,288 +1,99 @@
1
1
  # SysML v2 Language Server
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/sysml-v2-lsp)](https://www.npmjs.com/package/sysml-v2-lsp)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
- [![Socket Badge](https://socket.dev/api/badge/npm/package/sysml-v2-lsp)](https://socket.dev/npm/package/sysml-v2-lsp)
3
+ A [Language Server Protocol (LSP)](https://microsoft.github.io/language-server-protocol/) implementation for [SysML v2](https://www.omgsysml.org/SysML-2.htm), powered by the ANTLR4 grammar from [daltskin/sysml-v2-grammar](https://github.com/daltskin/sysml-v2-grammar).
6
4
 
7
- A [Language Server Protocol (LSP)](https://microsoft.github.io/language-server-protocol/) with [Model Context Protocol](https://modelcontextprotocol.io/) implementation for [SysML v2](https://www.omgsysml.org/SysML-2.htm), providing rich editing, navigation, and code intelligence for LSP-compatible editors.
5
+ ## Features
8
6
 
9
- Powered by the ANTLR4 grammar from [daltskin/sysml-v2-grammar](https://github.com/daltskin/sysml-v2-grammar).
7
+ | Feature | Status | Description |
8
+ |---------|--------|-------------|
9
+ | **Diagnostics** | ✅ | Syntax error reporting with red squiggles |
10
+ | **Document Symbols** | ✅ | Outline panel with SysML model structure |
11
+ | **Hover** | ✅ | Element kind, type, and documentation on hover |
12
+ | **Go to Definition** | ✅ | Ctrl+Click navigation to declarations |
13
+ | **Find References** | ✅ | Find all usages of a symbol |
14
+ | **Code Completion** | ✅ | Keywords, snippets, and symbol suggestions |
15
+ | **Semantic Tokens** | ✅ | Rich, context-aware syntax highlighting |
16
+ | **Folding Ranges** | ✅ | Collapsible `{ }` blocks and comments |
17
+ | **Rename** | ✅ | Rename symbol and all references |
10
18
 
11
- > **Works with:** VS Code, Neovim, Emacs, Sublime Text, Helix, and any editor that supports the Language Server Protocol.
19
+ ## Quick Start
12
20
 
13
- ---
21
+ ### Dev Container (recommended)
14
22
 
15
- ## Language Server Features
23
+ Open in GitHub Codespaces or VS Code Dev Containers — everything is pre-installed.
16
24
 
17
- The language server runs as a separate process and communicates over LSP — these features are available in **any** compatible editor.
18
-
19
- ### Editing & Navigation
20
-
21
- | Feature | Description |
22
- | -------------------- | ---------------------------------------------------------------------- |
23
- | **Diagnostics** | Syntax errors, unknown identifiers, keyword typos with severity levels |
24
- | **Code Completion** | Keywords, snippets, and symbol suggestions with documentation |
25
- | **Signature Help** | Parameter tooltips when invoking `action def` / `calc def` |
26
- | **Hover** | Element kind, type, qualified name, and documentation |
27
- | **Go to Definition** | Jump to a symbol's declaration |
28
- | **Find References** | Find all usages of a symbol across open files |
29
- | **Rename Symbol** | Rename a symbol and update all references |
30
- | **Linked Editing** | Edit a name and all same-scope occurrences update simultaneously |
31
- | **Document Links** | Clickable `import` paths — jump to the imported namespace |
32
-
33
- ### Code Intelligence
34
-
35
- | Feature | Description |
36
- | --------------------- | ------------------------------------------------------------------------ |
37
- | **CodeLens** | Reference counts shown above each definition |
38
- | **Inlay Hints** | Ghost text showing inferred types (`: Type`) and supertypes (`:> Super`) |
39
- | **Type Hierarchy** | Navigate specialization chains — supertypes and subtypes |
40
- | **Call Hierarchy** | Navigate `perform`/`include` chains between actions |
41
- | **Workspace Symbols** | Fuzzy search for any definition across all open files |
42
-
43
- ### Presentation & Formatting
44
-
45
- | Feature | Description |
46
- | -------------------- | ------------------------------------------------------------------------------ |
47
- | **Semantic Tokens** | Rich, context-aware syntax highlighting (definitions, usages, keywords, types) |
48
- | **Document Symbols** | Outline / breadcrumbs showing SysML model structure |
49
- | **Folding Ranges** | Collapsible `{ }` blocks and comment regions |
50
- | **Selection Ranges** | Smart expand/shrink selection (word → line → block → enclosing block) |
51
- | **Quick Fix** | Fix keyword typos (e.g., `paart` → `part`) |
52
- | **Formatting** | Auto-indent, normalize braces, trim trailing whitespace |
53
-
54
- ### Parser
55
-
56
- - ANTLR4-based parser via [antlr4ng](https://github.com/mike-lischke/antlr4ng)
57
- - SLL/LL dual-mode strategy — fast path with automatic fallback
58
- - DFA warm-up for near-instant first-parse performance
59
- - Worker thread architecture for non-blocking document processing
60
- - Symbol table with qualified name resolution and cross-file references
61
-
62
- ---
63
-
64
- ## MCP Server (AI Integration)
65
-
66
- A standalone [Model Context Protocol](https://modelcontextprotocol.io/) server that lets AI assistants parse, validate, and query SysML v2 models. Runs independently of any editor.
67
-
68
- ### Tools
69
-
70
- | Tool | Description |
71
- | ----------------- | ------------------------------------------------------ |
72
- | `parse` | Parse SysML source, build symbol table, return summary |
73
- | `validate` | Check syntax and return errors |
74
- | `getSymbols` | List symbols (filter by kind, URI, definitions/usages) |
75
- | `getDefinition` | Look up a symbol by name or qualified name |
76
- | `getReferences` | Find all references to a symbol |
77
- | `getHierarchy` | Get parent–child containment structure |
78
- | `getModelSummary` | Counts, kinds, and loaded documents |
79
-
80
- ### Resources
81
-
82
- | URI | Description |
83
- | -------------------------- | ---------------------------- |
84
- | `sysml://element-kinds` | All recognised element kinds |
85
- | `sysml://keywords` | Complete keyword list |
86
- | `sysml://grammar-overview` | Language structure reference |
87
-
88
- ### Prompts
89
-
90
- | Prompt | Description |
91
- | ----------------- | ------------------------------------ |
92
- | `review-sysml` | Review a SysML model for correctness |
93
- | `explain-element` | Explain a SysML element kind |
94
- | `generate-sysml` | Generate SysML from a description |
95
-
96
- ### MCP Setup
97
-
98
- **VS Code / GitHub Copilot** — The workspace includes `.vscode/mcp.json`, so the MCP server is automatically available after building.
99
-
100
- **Claude Desktop** — Add to `claude_desktop_config.json`:
101
-
102
- ```json
103
- {
104
- "mcpServers": {
105
- "sysml-v2": {
106
- "command": "node",
107
- "args": ["/path/to/sysml-v2-lsp/dist/server/mcpServer.mjs"]
108
- }
109
- }
110
- }
111
- ```
112
-
113
- **Any MCP client** — Run the server directly via stdio:
114
-
115
- ```bash
116
- npx sysml-v2-lsp # after npm install -g sysml-v2-lsp
117
- # or
118
- node dist/server/mcpServer.mjs
119
- ```
120
-
121
- ### Quick Test Examples
122
-
123
- Once the MCP server is connected, try these prompts:
124
-
125
- > Parse this: `package Demo { part def Vehicle { attribute speed : Real; } part car : Vehicle; }`
126
-
127
- > Validate this: `part def Broken { attribute x :`
128
-
129
- > What symbols are in the model?
130
-
131
- > Find the definition of Vehicle
132
-
133
- > Show the hierarchy of car
134
-
135
- ---
136
-
137
- ## VS Code Dev Extension
138
-
139
- A lightweight VS Code extension is included for **development and debugging** of the language server. It registers the `sysml` language ID, starts the LSP client, and provides a restart command — nothing more.
140
-
141
- For the full VS Code experience (TextMate grammar, snippets, language configuration, visualization), see [daltskin/VSCode_SysML_Extension](https://github.com/daltskin/VSCode_SysML_Extension).
142
-
143
- | Feature | Description |
144
- | ------------------------ | ------------------------------------------------------------------------------ |
145
- | **Language Registration**| Registers `.sysml` / `.kerml` file types |
146
- | **LSP Client** | Starts and manages the language server process |
147
- | **Restart Command** | `SysML: Restart Language Server` command |
148
- | **Dev Container** | Open in GitHub Codespaces or VS Code Dev Containers — everything pre-installed |
149
- | **Debug Configurations** | "Client + Server" compound launch for simultaneous debugging |
150
- | **Example Files** | `examples/` folder with camera, toaster, and vehicle models |
151
-
152
- ---
153
-
154
- ## Getting Started
155
-
156
- ### Using the VS Code Extension
157
-
158
- Open in GitHub Codespaces or Dev Containers (recommended), or manually:
25
+ ### Manual Setup
159
26
 
160
27
  ```bash
28
+ # Install dependencies
161
29
  npm install
162
- npm run build
163
- # Press F5 to launch the Extension Development Host
164
- ```
165
-
166
- ### Using the LSP with Other Editors
167
30
 
168
- Build the server, then point your editor's LSP client at it:
31
+ # Generate TypeScript parser from ANTLR4 grammar
32
+ npm run generate
169
33
 
170
- ```bash
171
- npm install && npm run build
172
- # Server binary: dist/server/server.mjs
173
- # Start with: node dist/server/server.mjs --stdio
174
- ```
175
-
176
- **Neovim** (via [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig)):
177
-
178
- ```lua
179
- vim.lsp.start({
180
- name = 'sysml',
181
- cmd = { 'node', '/path/to/sysml-v2-lsp/dist/server/server.mjs', '--stdio' },
182
- filetypes = { 'sysml' },
183
- })
184
- ```
185
-
186
- **Emacs** (via [lsp-mode](https://github.com/emacs-lsp/lsp-mode)):
34
+ # Build
35
+ npm run build
187
36
 
188
- ```elisp
189
- (lsp-register-client
190
- (make-lsp-client
191
- :new-connection (lsp-stdio-connection
192
- '("node" "/path/to/sysml-v2-lsp/dist/server/server.mjs" "--stdio"))
193
- :activation-fn (lsp-activate-on "sysml")
194
- :server-id 'sysml-lsp))
37
+ # Run tests
38
+ npm test
195
39
  ```
196
40
 
197
- **Python** — A zero-dependency Python LSP client is included in [`clients/python/`](clients/python/):
41
+ ### Development
198
42
 
199
43
  ```bash
200
- cd clients/python
201
- python3 sysml_lsp_client.py # analyse all example files
202
- python3 sysml_lsp_client.py ../../examples/vehicle-model.sysml # specific file
203
- ```
204
-
205
- This demonstrates that the same LSP server used by VS Code can be driven from
206
- any language — see the [Python client README](clients/python/README.md) for details.
207
-
208
- ### Using the MCP Server
44
+ # Watch mode — recompiles on file changes
45
+ npm run watch
209
46
 
210
- ```bash
211
- npm install && npm run build
212
- node dist/server/mcpServer.mjs # stdio transport
47
+ # Then press F5 in VS Code to launch the extension + server
213
48
  ```
214
49
 
215
- ---
50
+ Use the **"Client + Server"** compound debug configuration to debug both sides simultaneously.
216
51
 
217
52
  ## Architecture
218
53
 
219
54
  ```
220
- ┌──────────────────────────────────────────────────────────────────┐
221
- Language Server (Node.js)
222
-
223
- │ ┌──────────────┐ ┌──────────────────┐ ┌───────────────────┐ │
224
- ANTLR4 Parser│ │ Symbol Table 21 Providers
225
- (worker thr.)│──│ scopes, q-names │──│ completion, hover
226
- SLL/LL dual cross-file refs │ │ def, refs, rename │
227
- └──────────────┘ └──────────────────┘ hierarchy, format
228
- tokens, lens, ...
229
- └───────────────────┘
230
- └──────────────────────┬───────────────────────────┬───────────────┘
231
- │ LSP (stdio/IPC) │
232
- ┌────────────┴────────────┐ │
233
- │ Any Editor │ │
234
- │ VS Code, Neovim, │ │
235
- │ Emacs, Sublime, ... │ │
236
- └─────────────────────────┘ │
237
-
238
- ┌──────────────────────────────────────────────────┴──────────────┐
239
- │ MCP Server (standalone) │
240
- │ 7 tools · 3 resources · 3 prompts · stdio transport │
241
- │ │
242
- │ ┌─────────────────┐ ┌──────────────────┐ ┌──────────────────┐ │
243
- │ │ Claude, Copilot│ │ Cursor, Windsurf│ │ Any MCP Client │ │
244
- │ └─────────────────┘ └──────────────────┘ └──────────────────┘ │
245
- └─────────────────────────────────────────────────────────────────┘
55
+ ┌──────────────────────┐ IPC ┌──────────────────────────┐
56
+ VS Code Extension │ ◄─────────► │ Language Server
57
+ (Language Client) │ (Separate Process) │
58
+ ├──────────────────────┤ ├──────────────────────────┤
59
+ Starts server • ANTLR4 parser
60
+ Registers language │ │ Diagnostics
61
+ Completion (keywords)
62
+ Symbols / hover
63
+ Go-to-def / references
64
+ │ • Semantic tokens │
65
+ │ │ │ • Rename / folding │
66
+ └──────────────────────┘ └──────────────────────────┘
246
67
  ```
247
68
 
248
69
  ### Project Structure
249
70
 
250
71
  ```
251
72
  sysml-v2-lsp/
252
- ├── server/ # Language Server + MCP Server
73
+ ├── client/ # VS Code Language Client extension
74
+ │ └── src/extension.ts # Starts LanguageClient, connects to server
75
+ ├── server/ # Language Server (runs in separate process)
253
76
  │ └── src/
254
- │ ├── server.ts # LSP connection, capability registration
255
- │ ├── mcpServer.ts # MCP server entry point (stdio)
256
- │ ├── mcpCore.ts # MCP handler logic (testable)
77
+ │ ├── server.ts # LSP connection, capability registration
257
78
  │ ├── documentManager.ts # Parse cache, document lifecycle
258
- │ ├── parser/ # ANTLR4 parse pipeline + worker thread
259
- │ ├── symbols/ # Symbol table, scopes, element types
260
- │ └── providers/ # 21 LSP feature implementations
261
- ├── clients/ # LSP client implementations
262
- │ ├── vscode/ # VS Code Language Client extension
263
- │ │ └── src/extension.ts # Starts LanguageClient, registers language
264
- │ └── python/ # Python LSP client demo (zero dependencies)
265
- │ └── sysml_lsp_client.py
79
+ │ ├── parser/ # ANTLR4 parse pipeline
80
+ │ ├── symbols/ # Symbol table, scopes, element types
81
+ │ └── providers/ # LSP feature implementations
266
82
  ├── grammar/ # ANTLR4 grammar files (.g4)
267
- ├── examples/ # Sample SysML models
268
- ├── test/ # Unit tests (vitest)
83
+ ├── test/ # Unit tests (vitest) + E2E tests
269
84
  └── package.json # Extension manifest + monorepo scripts
270
85
  ```
271
86
 
272
- ---
87
+ ## Grammar Updates
273
88
 
274
- ## Development
89
+ The grammar files in `grammar/` are sourced from [daltskin/sysml-v2-grammar](https://github.com/daltskin/sysml-v2-grammar). To pull the latest version:
275
90
 
276
91
  ```bash
277
- npm install # Install all dependencies
278
- npm run generate # Generate TypeScript parser from ANTLR4 grammar
279
- npm run build # Compile + bundle (esbuild)
280
- npm run watch # Watch mode — recompiles on changes
281
- npm test # Run 88 unit tests (vitest)
282
- npm run lint # ESLint
92
+ npm run update-grammar
93
+ npm run generate
283
94
  ```
284
95
 
285
- Or use the Makefile:
96
+ ## Available Commands
286
97
 
287
98
  ```bash
288
99
  make install # Install all dependencies
@@ -292,33 +103,21 @@ make watch # Watch mode
292
103
  make test # Run unit tests
293
104
  make lint # ESLint
294
105
  make package # Build .vsix
295
- make package-server # Build npm tarball
296
106
  make update-grammar # Pull latest grammar from upstream
297
107
  make ci # Full CI pipeline
298
108
  ```
299
109
 
300
- ### Grammar Updates
301
-
302
- The grammar files in `grammar/` are sourced from [daltskin/sysml-v2-grammar](https://github.com/daltskin/sysml-v2-grammar). To pull the latest:
303
-
304
- ```bash
305
- npm run update-grammar && npm run generate
306
- ```
307
-
308
- ---
309
-
310
110
  ## Technology Stack
311
111
 
312
- | Component | Technology |
313
- | --------- | ----------------------------------------------------------------------------------- |
314
- | Language | TypeScript (strict mode) |
315
- | Runtime | Node.js ≥ 20 |
316
- | Parser | ANTLR4 via [antlr4ng](https://github.com/mike-lischke/antlr4ng) |
317
- | Generator | [antlr-ng](https://github.com/nicklockwood/antlr-ng) |
318
- | LSP | [vscode-languageserver](https://github.com/microsoft/vscode-languageserver-node) |
319
- | MCP | [@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/typescript-sdk) |
320
- | Bundler | esbuild |
321
- | Tests | vitest |
112
+ | Component | Technology |
113
+ |-----------|-----------|
114
+ | Language | TypeScript (strict mode) |
115
+ | Runtime | Node.js ≥ 18 |
116
+ | Parser | ANTLR4 via [antlr4ng](https://github.com/mike-lischke/antlr4ng) |
117
+ | Generator | [antlr-ng](https://github.com/nicklockwood/antlr-ng) |
118
+ | LSP | [vscode-languageserver](https://github.com/microsoft/vscode-languageserver-node) |
119
+ | Bundler | esbuild |
120
+ | Tests | vitest |
322
121
 
323
122
  ## Related Projects
324
123