mps-aspect-textgen
Skill1.7k starsChanged 2 months agoApache-2.0View on GitHub
Use when authoring or debugging MPS TextGen — concept-to-plain-text serialisation for languages whose final output is text (source files, config, scripts, DDL, XML, markdown). Covers `ConceptTextGenDeclaration` roots, `append` / `indent buffer` / `with indent` statements, text layout areas, context objects (e.g. imports sets), attributes, the base text gen component (`LanguageTextGenDeclaration`), binary `write`, `found error`, and the indentation-buffer model. Reach for this skill whenever the task involves editing `<lang>/languageModels/textGen.mps`.
Trending
Quiet since October.thin dataabout the whole repository
Who's talking about JetBrains/MPS
- mbeddr/mps-gradle-plugin“Null pointer exception on generate”GitHub · May 18, 2020 · 1 reactions
- nebojsa-vuksic/skill-atlas“Scan every repository of an organization or user”GitHub · Oct 1, 2026
- modelix/modelix.editor“Implement MPS shortcuts”GitHub · Feb 21, 2023
The biggest 3 of 3 mentions linking to the repository that our crawl found. Each line is their own headline.
In this repository83 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- actionsSkill
- bugfix-workflowSkill
- code-styleSkill
- commitsSkill
- debuggingSkill
- mps-aspect-accessoriesSkill
- mps-aspect-actionsSkill
- mps-aspect-behaviorSkill
- mps-aspect-constraintsSkill
- mps-aspect-dataflowSkill
- mps-aspect-editor-menus-and-keymapsSkill
- mps-aspect-editorSkill
- mps-aspect-generation-planSkill
- mps-aspect-generatorSkill
- mps-aspect-intentionsSkill
- mps-aspect-migrationsSkill
- mps-aspect-structure-conceptsSkill
- mps-aspect-typesystemSkill
- mps-baselanguageSkill
- mps-build-languageSkill
- mps-consoleSkill
- mps-distribution-buildSkill
- mps-dsl-memorySkill
- mps-ide-pluginSkill
- mps-lang-core-xmlSkill
- mps-language-analysisSkill
- mps-language-aspects-overviewSkill
- mps-language-inheritanceSkill
- mps-language-modularitySkill
- mps-mcp-workflowSkill
- mps-model-manipulationSkill
- mps-node-editingSkill
- mps-project-managementSkill
- mps-quotationsSkill
- mps-run-configurationsSkill
- mps-testsSkill
- registrySkill
- skill-optimization-studySkill
- ssrSkill
- teamcity-cliSkill
- actionsSkill
- bugfix-workflowSkill
- code-styleSkill
- commitsSkill
- debuggingSkill
- mps-aspect-accessoriesSkill
- mps-aspect-actionsSkill
- mps-aspect-behaviorSkill
- mps-aspect-constraintsSkill
- mps-aspect-dataflowSkill
- mps-aspect-editor-menus-and-keymapsSkill
- mps-aspect-editorSkill
- mps-aspect-generation-planSkill
- mps-aspect-generatorSkill
- mps-aspect-intentionsSkill
- mps-aspect-migrationsSkill
- mps-aspect-structure-conceptsSkill
- mps-aspect-textgenSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 23
Prefer with indent { ... } over paired increase depth .
- Distinctive: line 24
Use TextGen only when the final artifact is text.
- Very specific: line 28
After edits run mps_mcp_check_root_node_problems and rebuild the language.
≈ “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.
Files
MPS TextGen 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.
TextGen turns a model (usually the output of generation) into plain text files. It is how BaseLanguage becomes .java on disk, and how any text-targeting language serialises its models. Lives in <lang>/languageModels/textGen.mps, language jetbrains.mps.lang.textGen. Rule bodies are BaseLanguage + smodel + textgen-specific statements (append, indent buffer, with indent).
Prerequisite for any insert: the textGen model must exist (mps_mcp_create_model with moduleName: "<lang>" and modelName: "<lang>.textGen" — aspect ID textGen, case-sensitive, no @ suffix; see aspect-model-stereotypes.md) and must import jetbrains.mps.lang.textGen, jetbrains.mps.baseLanguage, and jetbrains.mps.lang.smodel as used languages before the first mps_mcp_insert_root_node_from_json. Missing any of these three causes node inserts to fail with unresolved-concept errors. See step 1 of the Common-Path Workflow.
Critical Directives
- One
ConceptTextGenDeclarationroot per concept you want to serialise. Only the file-generating root concept needsextension/filename/encoding; structural concepts inside the file need onlytextGenBlock. extensionis a function body returning a string, not a literal property. It mustreturna string.- TextGen dispatch is concept-exact, not polymorphic. An extending concept that wants the parent's serialisation must declare its own
ConceptTextGenDeclaration(even an empty one) — or its output will be silently missing. Seereferences/dispatch-and-base-component.md. - The indentation buffer is a per-output-file depth counter.
with indent/increase depth/decrease depthand thewithIndentflag onNodeAppendPartonly mutate the counter — whitespace is emitted only whenindent bufferis called. Always pairappend \n ;withindent buffer ;on the next line that should be indented. Seereferences/indentation-model.md. - Prefer
with indent { ... }over pairedincrease depth ; … ; decrease depth ;— the block form cannot leak depth on an earlyreturnor exception. Use the paired form only when the scope is not a block. - Use TextGen only when the final artifact is text. If your pipeline ends in a model-to-model transformation targeting another MPS language (e.g. BaseLanguage), you don't need TextGen — that language's own TextGen handles the final step.
BinaryWriteOperation(write) cannot be mixed with textappends in the sameConceptTextGenDeclaration. A rule emits either text or bytes, not both.- The older
$ref{node.reference<target>}syntax is deprecated. Use aNodeAppendPartover a resolved node (or over.name). - Edit textGen models through MPS MCP tools (
mps_mcp_insert_root_node_from_json,mps_mcp_update_node). Do not hand-edit.mpsfiles. - After edits run
mps_mcp_check_root_node_problemsand rebuild the language; regenerate consumers.
Common-Path Workflow
- Create a
textGenmodel (mps_mcp_create_modelwithmoduleName: "<lang>"andmodelName: "<lang>.textGen"; aspect ID istextGen— case-sensitive, no@suffix) if absent, then before any insert add the three required used languages:jetbrains.mps.lang.textGen(forConceptTextGenDeclaration,AppendOperation, parts,NodeParameter, etc.),jetbrains.mps.baseLanguage(forStatementList,DotExpression, control flow, returns), andjetbrains.mps.lang.smodel(forSPropertyAccess,SLinkAccess,SLinkListAccessused to read node data). Also add the structure language whose concepts you serialise (referenced byconceptDeclarationand inside smodel accesses), andjetbrains.mps.baseLanguage.collectionsif you use maps/lists. Skipping any of the three core languages causesmps_mcp_insert_root_node_from_jsonto fail with unresolved-concept errors — don't add them piecemeal after a failure. - For each concept to serialise, insert a
ConceptTextGenDeclarationroot viamps_mcp_insert_root_node_from_json. The file-generating concept also needsextension, optionallyencoding/filename/filePath/layout/contextObjects. - Fill the
textGenBlockbody — aStatementListofappends,indent buffer,with indent { ... }, and standard BaseLanguage control flow. Seereferences/statements-and-appends.mdfor the part vocabulary andreferences/json-blueprints.mdfor AST shapes. - Push formatting heuristics ("should this go on a new line?") into the behavior aspect and call them back from textgen (
node.hasNewLineAfter()pattern). Seereferences/delegating-to-behavior.md. - For large-file languages (imports area, headers, shared state), declare a
TextUnitLayout, aUnitContextDeclarationin the baseLanguageTextGenDeclaration, and per-conceptUnitContextObjects. Seereferences/layout-and-context-objects.md. - Validate with
mps_mcp_check_root_node_problems, rebuild the language module, regenerate any consumer, and inspect the produced text.
TextGen vs. Generator
| Aspect | Role |
| Generator | Model → Model (typed AST transformation) |
| TextGen | Model → Text (final serialisation) |
A custom language usually has both: a generator rewrites into BaseLanguage + runtime API, and BaseLanguage's TextGen emits .java. Write your own TextGen only if you target text directly (as jetbrains.mps.core.xml does).
Related Skills
mps-aspect-generator— model-to-model step that usually precedes TextGen; emits the AST you serialise.mps-aspect-behavior— host for layout-heuristic helper methods called from textgen bodies.mps-model-manipulation— BaseLanguage + smodel + collections used inside textgen bodies (StatementList,DotExpression,SLinkAccess,SLinkListAccess,StaticMethodCall); for atextGenBlockbody open onlyreferences/dot-expression-basics.mdin themps-model-manipulationskill root after loading that companion skill from the same origin.mps-quotations— anti-quotations may appear insideQuotations used as${...}expression values.mps-aspect-structure-concepts— when introducing the concepts a textgen will serialise.
Reference Index
Start here — most common case: one ConceptTextGenDeclaration emitting text for one concept → read only references/concept-textgen-root.md and, for the body vocabulary, references/statements-and-appends.md; wrong indentation → only references/indentation-model.md; no output at all → only references/common-failures.md.
- Open
references/concept-textgen-root.mdwhen adding or editing aConceptTextGenDeclaration— slot purposes (extension,encoding,filename,filePath,layout,contextObjects,textGenBlock), the editor shorthand, and what each child holds. - Open
references/statements-and-appends.mdwhen writing the body —AppendOperationand its part vocabulary (ConstantStringAppendPart,NodeAppendPart,CollectionAppendPart,NewLineAppendPart), the$list{... with sep}form,BinaryWriteOperation(write),FoundErrorOperation(found error), control flow, and the smodel/behavior accessors usable inside a body. - Open
references/indentation-model.mdwhen indentation is wrong — the depth-counter mental model, rules of thumb (always pair\nwithindent buffer, preferwith indent { ... }, usewithIndentflag for one-shot dispatch), and worked examples fromIfStatement_TextGen,BlockStatement_TextGen, andClassConcept_TextGen. - Open
references/layout-and-context-objects.mdwhen emitting multi-region files (headers, imports, body) or threading per-generation state —TextUnitLayoutwithappend to AREA { ... },LanguageTextGenDeclaration,UnitContextDeclarationtypes, and per-conceptUnitContextObjectbindings (the imports-set pattern). Also covers attribute dispatch order (reverse containment) and${attributed node}. - Open
references/dispatch-and-base-component.mdfor concept-exact dispatch — why an extending concept needs its own (possibly empty)ConceptTextGenDeclaration, and how the baseLanguageTextGenDeclarationexposes reusableOperationDeclarations /UtilityMethodDeclarations /UnitContextDeclarations; inheriting between language base components viaextends. - Open
references/delegating-to-behavior.mdwhen textgen bodies grow tangled with formatting heuristics — the xml pattern of movinghasNewLineAfter/isMultiline/onNewLineinto behavior and calling them from textgen, plus utility classes (XmlCharEscape) for escaping/formatting. - Open
references/json-blueprints.mdwhen inserting nodes via MCP — full validated AST shapes for each statement/part (AppendOperationwith literal/expression/list parts,WithIndentOperation,IncreaseDepthOperation/DecreaseDepthOperation,NodeAppendPartwithwithIndent), the minimal file-generating-concept skeleton, layout/context skeletons, and the full validated concept reference (FQNs, concept refs, child roles). - Open
references/common-failures.mdwhen output is missing, indentation is broken, file extension is wrong, special characters appear unescaped, subclasses emit nothing, imports leak inline, attributes are ignored, orwriteandappendcollide.
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
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.

