feat: VRL Monaco editor intelligence — autocomplete, hover docs, signature help#99
feat: VRL Monaco editor intelligence — autocomplete, hover docs, signature help#99TerrifiedBug merged 11 commits intomainfrom
Conversation
…ImplicitAny errors
The afterMatch regex required [a-zA-Z_] as first char, breaking hover on digits within names like encode_base16, sha1, uuid_v4. Changed to [a-zA-Z0-9_]* (continuation chars) with a separate identifier-start validation on the combined word.
Greptile SummaryThis PR introduces a unified VRL function registry as the single source of truth for both Monaco editor intelligence and AI prompt context, replacing a hand-maintained static string. It adds a Monarch tokenizer, function autocomplete with snippet insertion, hover documentation, and signature help to the VRL Monaco editor. Key changes:
Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
Registry["src/lib/vrl/function-registry.ts\n(141 VrlFunction entries)"]
Registry -->|"getVrlFunction(name)"| Hover["Hover Provider\nprovideHover()"]
Registry -->|"searchVrlFunctions(prefix)"| Complete["Function Completion Provider\nprovideCompletionItems()"]
Registry -->|"getVrlFunction(name)"| SigHelp["Signature Help Provider\nprovideSignatureHelp()"]
Registry -->|"buildVrlReferenceFromRegistry()"| AI["AI Prompts\nbuildVrlSystemPrompt()\nbuildVrlChatSystemPrompt()"]
LangDef["src/lib/vrl/vrl-language.ts\n(Monarch tokenizer)"] -->|"beforeMount"| Monaco["Monaco Editor\n(language: 'vrl')"]
Complete --> Monaco
Hover --> Monaco
SigHelp --> Monaco
Fields["VrlFieldsPanel\n(source schema fields)"] -->|"registerCompletionItemProvider('.') "| Monaco
Snippets["VRL_SNIPPETS"] -->|"registerCompletionItemProvider"| Monaco
|
| // Define theme here too (before mount ensures it's available) | ||
| monaco.editor.defineTheme("vrl-theme", vrlTheme); | ||
| }, []); |
There was a problem hiding this comment.
Signature help limited to single-line function calls
provideSignatureHelp only inspects the content of the cursor's current line:
const line = model.getLineContent(position.lineNumber);
const textBefore = line.substring(0, position.column - 1);When a VRL function call spans multiple lines — e.g. the opening ( is on a previous line — textBefore on the argument line will never contain an unclosed (, so funcEnd stays -1 and the provider returns null. Signature hints won't appear for arguments typed on any line after the one containing the opening parenthesis.
For a v1 this is acceptable, but worth noting for a follow-up. A fix would walk backwards through previous lines when no unclosed ( is found on the current line.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/components/vrl-editor/vrl-editor.tsx
Line: 218-220
Comment:
**Signature help limited to single-line function calls**
`provideSignatureHelp` only inspects the content of the cursor's current line:
```typescript
const line = model.getLineContent(position.lineNumber);
const textBefore = line.substring(0, position.column - 1);
```
When a VRL function call spans multiple lines — e.g. the opening `(` is on a previous line — `textBefore` on the argument line will never contain an unclosed `(`, so `funcEnd` stays `-1` and the provider returns `null`. Signature hints won't appear for arguments typed on any line after the one containing the opening parenthesis.
For a v1 this is acceptable, but worth noting for a follow-up. A fix would walk backwards through previous lines when no unclosed `(` is found on the current line.
How can I resolve this? If you propose a fix, please make it concise.
Summary
src/lib/vrl/function-registry.ts) with 141 functions as the single source of truth for editor intelligence and AI prompt context(and,, supporting nested function calls via parenthesis depth trackingvrl-reference.tswithbuildVrlReferenceFromRegistry()— AI and editor now share the same function dataTest plan
parse— verify autocomplete shows all parse functions with descriptions and category badges.— verify field completion still works from source schemasparse_json— verify signature, description, and example popupparse_key_value— verify all 3 parameters shown with defaultsparse_key_value(— verify signature help shows parameter hintsto_string(parse_json(— verify showsparse_jsonsignature (innermost)