agentleFS
JetBrainsKnown publisherJetBrains/MPS/.agents/skills/mps-aspect-typesystem/SKILL.md

mps-aspect-typesystem

Skill1.7k starsChanged 2 months agoApache-2.0View on GitHub

Use when authoring or debugging MPS typesystem — inference rules (`typeof :==: / :<=: / :>=:`), `SubtypingRule`, `ComparisonRule`, `InequationReplacementRule`, `SubstituteTypeRule`, `WhenConcreteStatement` blocks, `NonTypesystemRule` checking rules, `TypesystemQuickFix`, error/warning/info reports with `messageTarget` highlighting and quick-fix wiring (`helginsIntention`), and shared BaseLanguage helpers in the typesystem model. Reach for this skill whenever the task involves editing `<lang>/languageModels/typesystem.mps`.

Trending

Quiet since October.thin dataabout the whole repository

Jan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 1 mentionNov 2026: 0 mentionsDec 2026: 0 mentions
Jan 2026Jul 2026Dec 2026
Mentions a month of the JetBrains/MPS repository that our weekly crawl found: only 3 in all, so this is a hint, not a trend. There is no adoption data for this file yet.

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 0 are distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    After edits run mps_mcp_check_root_node_problems, compile the language, and test on sample models.

    line 33
  2. Very specific:

    Create a typesystem model (mps_mcp_create_model with moduleName: "<lang>" and modelName: "<lang>.typesystem" — aspect ID typesystem, …

    line 37
  3. Very specific:

    Add used languages: jetbrains.mps.lang.typesystem, and any languages used in bodies (smodel, collections, closures, baseLanguage).

    line 38
  4. Very specific:

    Add InferenceRule roots for concepts whose types you compute (see references/inference-rules.md).

    line 39
  5. Very specific:

    Add SubtypingRule / ComparisonRule / InequationReplacementRule / SubstituteTypeRule roots for the type lattice (see …

    line 40
  6. Very specific:

    Add NonTypesystemRule roots for checks that are not about types (see references/non-typesystem-checking.md).

    line 41
  7. Very specific:

    Add TypesystemQuickFix roots for any fix you want to attach to reports.

    line 42
  8. Very specific:

    Write bodies with BaseLanguage + smodel.

    line 43

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

MPS Typesystem and Checking Aspect

Loading companion skills

Companion names in this skill are lazy dependencies: load only those relevant to the current task. If this skill came from an MCP server, use the host's skill loader to resolve the companion's unique discovered entry URI on the same host-assigned originating server. If the host has no server-backed skill loader, stop and report that limitation; do not silently fall back to a filesystem copy. If this skill came from a filesystem catalog, load the named sibling from that same catalog at <skills-root>/<skill-name>/SKILL.md, even if remote skill loaders are also available. Do not invent a tool name or server endpoint.

The typesystem aspect gives nodes types and reports semantic errors. It combines two related sub-aspects:

  • Typesystem rules — compute types and constraints on them (InferenceRule, SubtypingRule, InequationReplacementRule, ComparisonRule, SubstituteTypeRule).
  • Non-typesystem checking rules — produce errors/warnings/messages without contributing to type inference (NonTypesystemRule, a.k.a. "checking rule").

Lives in <lang>/languageModels/typesystem.mps, language jetbrains.mps.lang.typesystem. Rule bodies are BaseLanguage + smodel + collections + closures.

Critical Directives

  • One InferenceRule (or other root rule) per concept whose type/check you compute. Multiple rules collectively constrain a node — keep each rule focused.
  • The infer prefix makes an inequation soft (the solver tries to satisfy it, will not immediately error). Without infer, violating the inequation reports an error. Choose deliberately.
  • In equation/inequation JSON, both leftExpression and rightExpression are TypeClause slots — always wrap the real Expression in a NormalTypeClause (normalType child holds the actual Expression). Do not put the Expression directly under leftExpression/rightExpression.
  • TextGen-style dispatch caveat does not apply here; typesystem rules are inherited via concept hierarchy, but the overrides property on a rule suppresses inherited rules from superconcepts.
  • TextGen / typesystem error messages: wrap smodel expressions that render types with <...> presentation: error "Expected " + <expectedType> + " but got " + <actualType> -> node;. Avoid raw toString.
  • when concrete (typeof(expr) as v) { ... } defers a block until the type is fully resolved — use it before deciding whether to report an error or assign a result type.
  • Quick fixes (TypesystemQuickFix) are roots, not executed automatically — the user triggers them via the UI. Wire them into a report through the helginsIntention slot (TypesystemIntention wrapper with quickFix ref + actualArguments). See references/quick-fixes.md.
  • Reusable helper code (utility classes, shared algorithms) can live as a plain BaseLanguage ClassConcept root directly in the typesystem model. No separate utility module is required.
  • For MPS-typed return types (sequence<node<X>>, list<node<X>>) the Java parser gives back List<SNode> — fix per references/variable-declarations.md in the mps-model-manipulation skill root after loading that companion skill from the same origin.
  • Edit typesystem models through MPS MCP tools (mps_mcp_insert_root_node_from_json, mps_mcp_update_node, mps_mcp_parse_java_and_insert). Do not hand-edit .mps files.
  • After edits run mps_mcp_check_root_node_problems, compile the language, and test on sample models.

Common-Path Workflow

  1. Create a typesystem model (mps_mcp_create_model with moduleName: "<lang>" and modelName: "<lang>.typesystem" — aspect ID typesystem, case-sensitive, no @ suffix; see aspect-model-stereotypes.md) if absent.
  2. Add used languages: jetbrains.mps.lang.typesystem, and any languages used in bodies (smodel, collections, closures, baseLanguage).
  3. Add InferenceRule roots for concepts whose types you compute (see references/inference-rules.md).
  4. Add SubtypingRule / ComparisonRule / InequationReplacementRule / SubstituteTypeRule roots for the type lattice (see references/lattice-rules.md).
  5. Add NonTypesystemRule roots for checks that are not about types (see references/non-typesystem-checking.md).
  6. Add TypesystemQuickFix roots for any fix you want to attach to reports; wire them via a helginsIntention/TypesystemIntention child of the warning/error/info statement (see references/quick-fixes.md).
  7. Write bodies with BaseLanguage + smodel. Use when concrete (references/when-concrete.md) when you need resolved types before checking. For helper code, place a ClassConcept root directly in the typesystem model and call it from rules.
  8. Validate: mps_mcp_check_root_node_problems plus compile the language and test on sample models. A helginsIntention-wired quick fix now surfaces in the check report's quickFixes array and can be applied with mps_mcp_apply_intention(nodeReference = <problem node>, intentionId = <fix id>); an auto-applicable fix runs under autoApplyQuickFixes=true.

Related Skills

  • mps-aspect-behavior — behavior methods called from rule bodies via node.method(); common host for getType / isAssignableFrom-style helpers callable from typesystem.
  • mps-aspect-constraints — non-type validation often lives in constraints; consider whether a check belongs there before adding a NonTypesystemRule.
  • mps-aspect-intentions — distinct from TypesystemQuickFix (intentions are user-invoked from caret; quick fixes attach to a report).
  • mps-model-manipulation — full BaseLanguage / smodel / collections reference used inside rule bodies (StatementList, DotExpression, smodel operations, the List<SNode> → sequence<node<X>> return-type fix); for an inference or checking rule body open only references/dot-expression-basics.md in the mps-model-manipulation skill root after loading that companion skill from the same origin.
  • mps-quotations — <type> literals in rule bodies are heavy quotations; %(expr)% splices use the Antiquotation family. The typesystem model usually uses jetbrains.mps.lang.quotation as a used language.
  • mps-aspect-structure-concepts — when introducing the type concept(s) the rules target.

Reference Index

Start here — most common case: one InferenceRule that types a concept → read only references/inference-rules.md, plus references/json-blueprints.md when inserting it through MCP; a checking rule that reports an error → only references/non-typesystem-checking.md; a type that stays undefined → only references/common-failures.md.

  • Open references/inference-rules.md when writing or debugging an InferenceRule — the operator vocabulary (:==:, :<=:, :>=:, soft infer, strong :<<=: / :>>=:), free type variables (var elementType;), join(A | B), %(...)% anti-quotations in <...> literals, and the four worked examples (StringLiteral, ParenthesizedExpression, TernaryOperator, ForEachStatement).
  • Open references/when-concrete.md when a rule must wait for a resolved concrete type before deciding — WhenConcreteStatement shape, nested when concrete blocks, operation type(op, leftType, rightType), and the bound-variable plumbing (WhenConcreteVariableDeclaration / WhenConcreteVariableReference).
  • Open references/lattice-rules.md for the type-lattice rules — SubtypingRule (single supertype or nlist<> of supertypes), InequationReplacementRule (a.k.a. "replacement rule", structural subtyping with isApplicableClause, isWeak, equationInfo.getNodeWithError()), ComparisonRule (boolean body, weak), and SubstituteTypeRule (attributedNode, return-or-null pattern).
  • Open references/non-typesystem-checking.md when adding a NonTypesystemRule ("checking rule") — error / warning / info "msg" -> node;, isStrongSubtype(typeof(x) :<< t) for strict-subtype tests, and the CheckExcessTypeCasts example.
  • Open references/quick-fixes.md when authoring a TypesystemQuickFix and wiring it into a report — QuickFixArgument declarations, executeBlock / descriptionBlock, the three sample fixes (RemoveExcessTypeCast, RemoveMisplacedDash, HideCardinalityOne), and the full JSON for the helginsIntention / TypesystemIntention / TypesystemIntentionArgument plumbing.
  • Open references/messages-and-helpers.md when crafting messages — the <...> type-rendering convention, messageTarget to highlight just a property/reference/child cell, PropertyMessageTarget shape, and shared BaseLanguage helper roots (ElementSummary pattern).
  • Open references/json-blueprints.md when inserting nodes via MCP — body-level skeletons for each equation/inequation kind, ReportErrorStatement / WarningStatement / InfoStatement with optional helginsIntention / messageTarget, anti-quotation handling inside quotations, minimal rule-root skeletons, and the full validated concept reference with FQNs and concept refs.
  • Open references/common-failures.md when a type is undefined, subtyping isn't applied, error messages render badly, return types fight the Java parser, rules cycle, quick fixes aren't offered, when concrete bodies never run, or SubstituteTypeRule seems ignored.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.