Skip to content

fix: stop suggesting and highlighting raw dotprompt markers - #648

Open
pavelgj wants to merge 2 commits into
mainfrom
pj/editor-markers-v3k9p6dz2m
Open

pavelgj wants to merge 2 commits into
mainfrom
pj/editor-markers-v3k9p6dz2m

Conversation

@pavelgj

@pavelgj pavelgj commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

What's new

Editor tooling stops suggesting and highlighting raw <<<dotprompt:...>>> markers and inserts the template helpers instead.

  • Snippets / completions / live templates (vscode, monaco, codemirror, jetbrains): removed the <<< raw-marker snippet; role/section insert the inline helpers ({{role "system"}}, {{section "output"}}), alongside {{history}} and {{media url=...}}.
  • Grammars (vscode tmLanguage, monaco, codemirror, vim, emacs, jetbrains lexer, tree-sitter): <<<dotprompt:...>>> is plain text now. Tree-sitter parser regenerated with the pinned tree-sitter-cli 0.22.6; corpus test updated.
  • Block forms {{#role}}...{{/role}} / {{#section}} removed from suggestions: the helpers never call options.fn, so block content was silently dropped.
  • JetBrains lexer now lexes inside {{ }}: helper names (role, history, section, media, if, each, ...) are highlighted as helpers, other identifiers/paths as variables, }} as a close brace. Previously only the (now removed) marker token was Dotprompt-specific. Lexer unit tests added (bazel test //packages/jetbrains:DotpromptLexerTest).
  • CodeMirror / Monaco helper completions after {{ were inserting literal text ({{ro + role produced {{{{role "${role}"}}). They're now real snippets that don't repeat the typed {{ and absorb an auto-closed }}. CodeMirror has vitest coverage (pnpm exec vitest run in packages/codemirror).
  • Stray {{/section}} removed from monaco/codemirror samples; READMEs and the vscode CHANGELOG (Unreleased) updated; snippet default model is gemini-flash-latest.

Why

With #640-#645, runtimes only honor markers carrying a random per-render nonce, so a literal <<<dotprompt:role:system>>> in a template renders as text in a user message. The tooling was teaching a form that now silently does nothing (raised in review of #640).

Breaking changes (tooling)

  • tree-sitter: node types dotprompt_marker and marker_content are gone; external queries referencing them will fail to compile.
  • jetbrains: DotpromptTokenTypes.MARKER and the DOTPROMPT_MARKER color key are removed.
  • monaco: the keyword.marker token is no longer emitted.

Not in this PR

  • Rebuilding the committed monaco/codemirror dist/ (already stale vs src on main; rebuilt at release).
  • Other places still showing block-form {{#role}}: examples/*.prompt, Dart docs, rs/promptly LSP hover text, the streamlit-monaco demo, docs/design/promptly.md, the tree-sitter "ROLE BLOCK" corpus test, monaco/codemirror fold/indent rules.
  • Old model names in monaco/codemirror samples and model completion lists.
  • Emacs and the JetBrains Gradle build weren't run locally (toolchains unavailable); the JetBrains Bazel build passes.

Runtimes now only honor `<<<dotprompt:{nonce}:...>>>` markers carrying the
per-render nonce, so a literal `<<<dotprompt:role:system>>>` in a template
renders as plain text. Editor tooling still inserted that form (vscode
`<<<` snippet) and highlighted it as live syntax, teaching a form that
silently does nothing.

- Remove the raw-marker snippet and the marker rule/token/node from the
  vscode tmLanguage, monaco, codemirror, vim, emacs, jetbrains and
  tree-sitter grammars (parser regenerated with tree-sitter-cli 0.22.6,
  corpus test now expects plain text).
- Role and section snippets, completions, live templates and hover docs
  now insert the inline helpers (`{{role "system"}}`, `{{section "x"}}`).
  The block forms they used (`{{#role}}...{{/role}}`) discard their
  content, since `role` and `section` never call `options.fn`.
- Drop stray `{{/section}}` lines from the monaco/codemirror samples.
- Update READMEs and the vscode CHANGELOG (Unreleased) accordingly, and
  default snippet models to gemini-flash-latest.
Comment thread packages/jetbrains/README.md Resolved
Comment thread packages/codemirror/src/completions.ts Resolved
The JetBrains lexer never emitted HANDLEBARS_HELPER or HANDLEBARS_VARIABLE,
so once the raw marker token was removed nothing Dotprompt-specific was
highlighted. It now lexes inside `{{ }}` in the template body: helper names
in helper position (built-ins and role/history/section/media/json/
ifEquals/unlessEquals), variables and paths, and `}}`/`~}}`/`}}}` closers.
The expression state is encoded in the lexer state, and getState() now
reports the state at the token start so incremental relexing resumes
correctly. Adds a Bazel kt_jvm_test for the lexer.

CodeMirror helper completions used string `apply` values, which replace the
typed word verbatim, so `{{ro` + `role` produced
`{{{{role "${role}"}}`. They are now snippets that start at the helper
name, use real fields, and replace an auto-closed `}}` instead of doubling
it. Monaco had the same doubling (empty replace range at the cursor); its
insert texts and ranges are fixed the same way. Adds vitest coverage for
the CodeMirror completion source.
@github-actions github-actions Bot added the bazel label Nov 18, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants