sysml-v2-lsp 0.1.7 → 0.3.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 (124) hide show
  1. package/CHANGELOG.md +64 -98
  2. package/README.md +73 -263
  3. package/dist/server/mcpServer.js +162 -0
  4. package/dist/server/{server.mjs → server.js} +74 -67
  5. package/index.cjs +3 -3
  6. package/package.json +6 -5
  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
  123. package/dist/server/mcpServer.mjs +0 -110
  124. package/dist/server/parser/parseWorker.mjs +0 -1030
package/CHANGELOG.md CHANGED
@@ -1,118 +1,84 @@
1
1
  # Changelog
2
2
 
3
- ## [0.1.7]
3
+ ## [0.3.0]
4
4
 
5
5
  ### Added
6
6
 
7
- - Comprehensive keyword validator tests — 14 new parser tests covering all expanded `NAME_PRECEDING_KEYWORDS` categories: KerML element keywords, visibility/prefix modifiers, action control nodes, reference-preceding keywords, relationship keywords, directionality, succession/flow, annotation/membership, `message`/`transition`, colon/specialization punctuation, and `:=` assignment skip logic
8
- - `findTextReferences()` unit tests 6 new tests covering whole-word matching, partial-word exclusion, line-comment skipping, block-comment skipping, empty results, and regex special character safety
9
- - Cross-file references test verifies text-based reference scanning finds usages across multiple documents
10
- - `includeDeclaration` filtering test verifies references provider correctly excludes the declaration when `includeDeclaration: false`
11
- - Reference deduplication test verifies no duplicate locations are returned
12
- - Cross-file CodeLens test verifies reference counts include usages from other documents
13
-
14
- ### Fixed
15
-
16
- - Expand `NAME_PRECEDING_KEYWORDS` from ~25 to ~120 tokens identifiers after KerML keywords (`type`, `classifier`, `datatype`, `class`, `struct`, `assoc`, `metaclass`, etc.), action control nodes (`fork`, `join`, `merge`, `decide`), relationship keywords (`redefines`, `subsets`, `specializes`, `conjugates`, `chains`, etc.), KerML relationship elements (`specialization`, `conjugation`, `disjoining`, `inverting`, etc.), requirement/state body keywords (`assume`, `require`, `frame`, `objective`, `entry`, `do`, `exit`), and punctuation tokens (`:`, `:>`, `:>>`, `::`, `::>`, `>`, `=>`, `~`, `,`, `#`) are no longer falsely flagged as keyword typos
17
- - Fix skip-punctuation logic in keyword validator — replace `:`, `::`, `:>`, `:>>` (now in `NAME_PRECEDING_KEYWORDS`) with `DOT`, `=`, `:=` as the only "value/path" skip tokens
18
- - Add `MESSAGE` and `TRANSITION` to SysML definition/usage element keywords in `NAME_PRECEDING_KEYWORDS`
19
-
20
- ## [0.1.6]
21
-
22
- ### Fixed
23
-
24
- - 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
25
- - 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
26
- - 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
27
-
28
- ## [0.1.5]
29
-
30
- ### Added
31
-
32
- - 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
33
- - `sysml.inlayHints.enabled` VS Code setting — allows users to toggle inlay hints on/off (default: true). Server-side gating returns empty results when disabled
34
- - Extension Development Host settings (`examples/.vscode/settings.json`) — disables inlay hints during F5 testing
35
- - Code completion provider tests — ensures keyword completions, snippet insert text, and resolve are covered
36
- - 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
+ - Mermaid diagram preview: SysML Mermaid diagram generation with 6 diagram types (class, activity, state, sequence, interconnection, use-case) and auto-detection
8
+ - Mermaid focus mode: filter diagram to a specific element, its children, parent, and related types
9
+ - Mermaid diff mode: compare original vs. modified SysML and report structural changes
10
+ - Complexity analyzer: structural complexity metrics (nesting depth, coupling, fan-out, documentation coverage) with composite 0–100 index and per-definition hotspots
11
+ - Semantic validator: unresolved type references, invalid multiplicity bounds, empty enumerations, duplicate definitions with standard-library type allow-list
12
+ - MCP tool `preview`: generates Mermaid diagrams from SysML with focus/diff support
13
+ - MCP tool `getDiagnostics`: returns semantic diagnostics for parsed documents
14
+ - MCP tool `getComplexity`: exposes complexity analysis as an MCP tool
15
+ - Code action quick-fixes: naming convention (PascalCase/camelCase), missing documentation stub, empty enumeration placeholder, unused definition suppression
16
+ - Library type-level indexing: Go-to-Definition into standard library types at exact declaration lines
17
+ - Multiplicity extraction from parse tree (`0..*`, `1`, etc.) on symbols
18
+ - Documentation extraction from doc/comment nodes on symbols
19
+ - Symbol table caching per URI keyed by document version
20
+ - Multi-specialization support: comma-separated specialization targets with `:>` and `specializes`
21
+ - LSP `sysml/serverStats` request: uptime, memory, and cache statistics
22
+ - LSP `sysml/clearCache` request: flush all in-memory caches
23
+ - LSP `sysml/status` notifications: begin/end parse progress events
24
+ - Language configuration: folding markers (`#region`/`#endregion`), indentation rules, `wordPattern`
25
+ - Model stats: lex/parse timing breakdown and complexity report in `sysml/model` response
26
+ - New tests: codeActions, complexity, libraryIndex, semantic validation, MCP preview/diagnostics
37
27
 
38
28
  ### Changed
39
29
 
40
- - Reorganise folder structure: `client/` `clients/vscode/`, Python client at `clients/python/`
41
- - Call hierarchy provider no longer depends on `TextDocuments` uses `DocumentManager` for all text access, simplifying the architecture
42
- - `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)
43
- - Suppress esbuild size warnings custom build summary replaces default output to avoid misleading ⚠️ indicators on the expected 1.4 MB ANTLR parser bundle
30
+ - MCP `validate` response shape: now returns `syntaxErrors`, `semanticIssues`, and `totalIssues` (was `errors` + `errorCount`)
31
+ - Symbol `typeName` `typeNames` (array) across MCP core and model provider
32
+ - Definition provider simplified: word-at-position logic moved inline
33
+ - References provider: uses symbol-table–based `findReferences()` instead of cross-file text scanning
34
+ - Diagnostics computed synchronously on document change (removed background parse worker thread)
35
+ - Symbol table kind inference: direct string comparison replaces regex-based rule matching for minification safety
36
+ - Document manager simplified: removed `TextDocuments` integration; parse timing now derived from `ParseResult.timing`
37
+ - esbuild: output format changed from ESM (`.mjs`) to CJS (`.js`); simplified to server + MCP + client bundles
38
+ - Parser simplified: removed SLL/LL two-stage fallback with `BailErrorStrategy`; single-pass parse
39
+ - MCP server: added `instructions` field for tool-call guidance
40
+ - Library index: `resolveLibraryPackage()` replaced by `resolveLibraryType()` for type-level lookups
44
41
 
45
- ### Fixed
42
+ ### Removed
46
43
 
47
- - 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
48
- - 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
49
- - 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`)
50
- - Fix CodeLens reference counts only counting declarations now uses text-based scanning consistent with Find References
51
- - Remove redundant `activationEvents` from `package.json` VS Code auto-generates from `contributes.languages`
52
- - Remove unnecessary `sysml.inlayHints.enabled` from dev workspace settings (only needed in Extension Development Host)
44
+ - Background parse worker thread (`parseWorker.mjs`) and DFA warm-up
45
+ - `resolveAt()` and `getWordAtPosition()` from symbol table (moved to providers)
46
+ - `findTextReferences()` text-scanning reference finder
47
+ - Keyword typo validation from diagnostics provider (replaced by semantic validator)
48
+ - Several parser and symbol table tests (connection-end parsing, keyword typo, `findTextReferences`)
53
49
 
54
- ## [0.1.4]
50
+ ## [0.2.0]
55
51
 
56
52
  ### Added
57
53
 
58
- - 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)
59
- - `constraint` grammar rules: `ConstraintDefinition`, `ConstraintUsage`, `RequirementConstraintMember`, `assert constraint`
60
- - 9 new unit tests for MCP resources and prompts (101 total tests, up from 92)
61
- - Constraint-related unit tests
62
-
63
- ### Fixed
64
-
65
- - Fix false positive diagnostics on qualified names with `::` (e.g., `toaster::maxTemp`) — add `COLON_COLON` to next-token skip list in `parseWorker.ts`
66
- - Fix identifiers after `actor`, `stakeholder`, `subject`, `variant`, `ref`, `snapshot`, `timeslice` incorrectly flagged as keyword typos — add to `NAME_PRECEDING_KEYWORDS` in both validators
67
- - Fix false positive keyword typo diagnostics on dot-chain and expression-position identifiers (e.g., `transportPassenger.driver`) — skip identifiers preceded by `.`, `=`, `:`, `::`, `:>`, `:>>`
68
- - Remove unused `parseAndBuild` import in `mcpServer.ts` after refactoring
54
+ - Custom LSP request (`sysml/model`): full semantic model with scoped queries
55
+ - MCP server (`sysml-mcp` CLI): 7 tools, 3 resources, 3 prompts for AI-assisted modelling
56
+ - Standard library: 94 bundled SysML v2 / KerML files from OMG release repo
57
+ - Inlay hints: ghost text for inferred types and supertypes
58
+ - Call hierarchy: action call graph navigation
59
+ - Type hierarchy: specialization chain navigation
60
+ - Signature help: parameter tooltips for action/calc invocations
61
+ - Code lens: reference counts above definitions
62
+ - Document links: clickable `import` statements
63
+ - Workspace symbols: cross-document symbol search
64
+ - Linked editing ranges: simultaneous rename of all occurrences
65
+ - Selection ranges: smart expand/shrink selection
66
+ - Code actions: quick-fix actions for diagnostics
67
+ - Formatting: document and range formatting
68
+ - Keyword validation: typo detection with "did you mean?" suggestions
69
+ - npm package: `sysml-v2-lsp` distributable for third-party extensions
70
+ - Python LSP client: reference JSON-RPC/stdio client
71
+ - Parse worker: background ANTLR parsing with DFA warm-up
72
+ - `make update-library`: fetch latest standard library from upstream
73
+ - `make package-server` / `make test-package`: npm tarball build and validation
69
74
 
70
75
  ### Changed
71
76
 
72
- - Slim VS Code dev extension to lightweight harness move TextMate grammar and snippets to separate `VSCode_SysML_Extension` repo
73
- - Simplify `language-configuration.json` to minimal comments and brackets for dev use
74
-
75
- ## [0.1.3]
76
-
77
- ### Added
78
-
79
- - `make test-package` target to test npm package in a simulated consumer project
80
- - README badges: npm version, license, Socket.dev supply chain security
81
-
82
- ### Fixed
83
-
84
- - 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
85
- - Rename ESM bundles from `.js` to `.mjs` for Node 20 compatibility — `child_process.fork()` now correctly treats server and worker as ESM
86
- - Move `@modelcontextprotocol/sdk` and `zod` from `dependencies` to `devDependencies` — they are fully bundled by esbuild and not needed at runtime
87
- - Guard `postinstall` script with `[ -f tsconfig.json ]` so it only runs in dev checkout, not in consumer installs
88
-
89
- ## [0.1.2]
90
-
91
- ### Added
92
-
93
- - Release checklist (`.github/RELEASE_CHECKLIST.md`)
94
-
95
- ### Fixed
96
-
97
- - Remove unused `antlr4-c3` dependency from server package
98
- - Fix client extension server path to use bundled `dist/` output (VSIX was broken)
99
- - Fix `postinstall` script silently swallowing server install failures
100
- - Sync versions across `server/package.json`, `client/package.json`, and MCP server to `0.1.1`
101
- - Align Node engine requirement to `>=20` in `server/package.json` (was `>=18`)
102
- - Update esbuild target from `node18` to `node20`
103
- - Add `*.tgz` to `.gitignore` to prevent accidental commits
104
- - Add explicit `require`/`default` conditions to `exports` field
105
- - Remove redundant `activationEvents` (auto-generated from `contributes.languages`)
106
-
107
- ## [0.1.1]
108
-
109
- ### Fixed
110
-
111
- - Update postinstall script to handle missing `client` directory gracefully
112
- - Add npm trusted publishing (OIDC) support and normalize repository URL
113
- - Remove accidentally committed `.tgz` archive
114
- - Skip `npm version` in release workflow when git tag already matches `package.json`
115
- - Drop Node 18 from CI matrix (Vite 7 requires Node 20+)
77
+ - Go-to-definition falls back to standard library for unresolved symbols
78
+ - Recursive type name extraction in symbol table
79
+ - Synthetic `start`/`done` nodes in activity diagram flows
80
+ - Element kind enum expanded to 55 kinds
81
+ - esbuild bundles four targets: server, worker, MCP server, VS Code client
116
82
 
117
83
  ## [0.1.0]
118
84
 
package/README.md CHANGED
@@ -1,288 +1,110 @@
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
+ [![npm](https://img.shields.io/npm/v/sysml-v2-lsp?logo=npm)](https://www.npmjs.com/package/sysml-v2-lsp)
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
+ [![SysML v2.0 Language Support VS Code Marketplace](https://img.shields.io/visual-studio-marketplace/v/JamieD.sysml-v2-support?label=VS%20Code%20Marketplace&logo=visual-studio-code)](https://marketplace.visualstudio.com/items?itemName=JamieD.sysml-v2-support)
8
6
 
9
- Powered by the ANTLR4 grammar from [daltskin/sysml-v2-grammar](https://github.com/daltskin/sysml-v2-grammar).
7
+ A [Language Server Protocol (LSP)](https://microsoft.github.io/language-server-protocol/) implementation for [SysML v2](https://www.omgsysml.org/SysML-2.htm).
10
8
 
11
- > **Works with:** VS Code, Neovim, Emacs, Sublime Text, Helix, and any editor that supports the Language Server Protocol.
9
+ ## Features
12
10
 
13
- ---
11
+ | Feature | Status | Description |
12
+ | ----------------------- | ------ | -------------------------------------------------------- |
13
+ | **Diagnostics** | ✅ | Syntax error reporting with red squiggles |
14
+ | **Document Symbols** | ✅ | Outline panel with SysML model structure |
15
+ | **Hover** | ✅ | Element kind, type, and documentation on hover |
16
+ | **Go to Definition** | ✅ | Ctrl+Click navigation to declarations |
17
+ | **Find References** | ✅ | Find all usages of a symbol |
18
+ | **Code Completion** | ✅ | Keywords, snippets, and symbol suggestions |
19
+ | **Semantic Tokens** | ✅ | Rich, context-aware syntax highlighting |
20
+ | **Folding Ranges** | ✅ | Collapsible `{ }` blocks and comments |
21
+ | **Rename** | ✅ | Rename symbol and all references |
22
+ | **Semantic Validation** | ✅ | Unresolved types, invalid multiplicity, duplicates |
23
+ | **Code Actions** | ✅ | Quick-fixes: naming, doc stubs, empty enums, unused defs |
24
+ | **Complexity Analysis** | ✅ | Structural metrics, composite index, hotspot detection |
25
+ | **Mermaid Preview** | ✅ | 6 diagram types with auto-detect, focus, and diff modes |
26
+ | **MCP Server** | ✅ | AI-assisted modelling via `sysml-mcp` CLI |
14
27
 
15
- ## Language Server Features
28
+ ## Quick Start
16
29
 
17
- The language server runs as a separate process and communicates over LSP — these features are available in **any** compatible editor.
30
+ ### Install from Marketplace
18
31
 
19
- ### Editing & Navigation
32
+ Install via the VS Code extension from the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=JamieD.sysml-v2-support).
20
33
 
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 |
34
+ ### Dev Container (recommended)
32
35
 
33
- ### Code Intelligence
36
+ Open in GitHub Codespaces or VS Code Dev Containers — everything is pre-installed.
34
37
 
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:
38
+ ### Manual Setup
159
39
 
160
40
  ```bash
41
+ # Install dependencies
161
42
  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
-
168
- Build the server, then point your editor's LSP client at it:
169
-
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
43
 
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)):
44
+ # Build
45
+ npm run build
187
46
 
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))
47
+ # Run tests
48
+ npm test
195
49
  ```
196
50
 
197
- **Python** — A zero-dependency Python LSP client is included in [`clients/python/`](clients/python/):
51
+ ### Development
198
52
 
199
53
  ```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
54
+ # Watch mode — recompiles on file changes
55
+ npm run watch
209
56
 
210
- ```bash
211
- npm install && npm run build
212
- node dist/server/mcpServer.mjs # stdio transport
57
+ # Then press F5 in VS Code to launch the extension + server
213
58
  ```
214
59
 
215
- ---
60
+ Use the **"Client + Server"** compound debug configuration to debug both sides simultaneously.
216
61
 
217
62
  ## Architecture
218
63
 
219
64
  ```
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
- └─────────────────────────────────────────────────────────────────┘
65
+ ┌──────────────────────┐ IPC ┌──────────────────────────┐
66
+ VS Code Extension │ ◄─────────► │ Language Server
67
+ (Language Client) │ (Separate Process) │
68
+ ├──────────────────────┤ ├──────────────────────────┤
69
+ Starts server • Parser
70
+ Registers language │ │ Diagnostics
71
+ Completion (keywords)
72
+ Symbols / hover
73
+ Go-to-def / references
74
+ │ • Semantic tokens │
75
+ │ │ │ • Rename / folding │
76
+ └──────────────────────┘ └──────────────────────────┘
246
77
  ```
247
78
 
248
79
  ### Project Structure
249
80
 
250
81
  ```
251
82
  sysml-v2-lsp/
252
- ├── server/ # Language Server + MCP Server
83
+ ├── client/ # VS Code Language Client extension
84
+ │ └── src/extension.ts # Starts LanguageClient, connects to server
85
+ ├── server/ # Language Server (runs in separate process)
253
86
  │ └── src/
254
- │ ├── server.ts # LSP connection, capability registration
255
- │ ├── mcpServer.ts # MCP server entry point (stdio)
256
- │ ├── mcpCore.ts # MCP handler logic (testable)
87
+ │ ├── server.ts # LSP connection, capability registration
257
88
  │ ├── 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
266
- ├── grammar/ # ANTLR4 grammar files (.g4)
267
- ├── examples/ # Sample SysML models
268
- ├── test/ # Unit tests (vitest)
89
+ │ ├── parser/ # Parse pipeline
90
+ │ ├── symbols/ # Symbol table, scopes, element types
91
+ ├── providers/ # LSP feature implementations
92
+ ├── analysis/ # Complexity analyzer
93
+ └── mcp/ # Mermaid diagram generator
94
+ ├── grammar/ # Grammar files (.g4)
95
+ ├── test/ # Unit tests (vitest) + E2E tests
269
96
  └── package.json # Extension manifest + monorepo scripts
270
97
  ```
271
98
 
272
- ---
99
+ ## Grammar Updates
273
100
 
274
- ## Development
101
+ 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
102
 
276
103
  ```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
104
+ npm run update-grammar
283
105
  ```
284
106
 
285
- Or use the Makefile:
107
+ ## Available Commands
286
108
 
287
109
  ```bash
288
110
  make install # Install all dependencies
@@ -292,37 +114,25 @@ make watch # Watch mode
292
114
  make test # Run unit tests
293
115
  make lint # ESLint
294
116
  make package # Build .vsix
295
- make package-server # Build npm tarball
296
117
  make update-grammar # Pull latest grammar from upstream
297
118
  make ci # Full CI pipeline
298
119
  ```
299
120
 
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
121
  ## Technology Stack
311
122
 
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 |
123
+ | Component | Technology |
124
+ | --------- | -------------------------------------------------------------------------------- |
125
+ | Language | TypeScript (strict mode) |
126
+ | Runtime | Node.js ≥ 18 |
127
+ | Parser | [antlr4ng](https://github.com/mike-lischke/antlr4ng) |
128
+ | Generator | [antlr-ng](https://github.com/nicklockwood/antlr-ng) |
129
+ | LSP | [vscode-languageserver](https://github.com/microsoft/vscode-languageserver-node) |
130
+ | Bundler | esbuild |
131
+ | Tests | vitest |
322
132
 
323
133
  ## Related Projects
324
134
 
325
- - [daltskin/sysml-v2-grammar](https://github.com/daltskin/sysml-v2-grammar) — ANTLR4 grammar for SysML v2
135
+ - [daltskin/sysml-v2-grammar](https://github.com/daltskin/sysml-v2-grammar) — Grammar for SysML v2
326
136
  - [daltskin/VSCode_SysML_Extension](https://github.com/daltskin/VSCode_SysML_Extension) — VS Code extension with visualization
327
137
  - [OMG SysML v2 Specification](https://github.com/Systems-Modeling/SysML-v2-Release)
328
138