@corenel/ui-kit 0.1.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.
- package/dist/host.d.ts +26 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +27 -0
- package/dist/host.js.map +1 -0
- package/dist/icons.d.ts +75 -0
- package/dist/icons.d.ts.map +1 -0
- package/dist/icons.js +109 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/languages.d.ts +28 -0
- package/dist/languages.d.ts.map +1 -0
- package/dist/languages.js +29 -0
- package/dist/languages.js.map +1 -0
- package/dist/monacoColorize.d.ts +7 -0
- package/dist/monacoColorize.d.ts.map +1 -0
- package/dist/monacoColorize.js +143 -0
- package/dist/monacoColorize.js.map +1 -0
- package/dist/prmdLanguage.d.ts +12 -0
- package/dist/prmdLanguage.d.ts.map +1 -0
- package/dist/prmdLanguage.js +218 -0
- package/dist/prmdLanguage.js.map +1 -0
- package/dist/templateRefs.d.ts +69 -0
- package/dist/templateRefs.d.ts.map +1 -0
- package/dist/templateRefs.js +238 -0
- package/dist/templateRefs.js.map +1 -0
- package/dist/theme.d.ts +15 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +81 -0
- package/dist/theme.js.map +1 -0
- package/dist/ui-helpers.d.ts +4 -0
- package/dist/ui-helpers.d.ts.map +1 -0
- package/dist/ui-helpers.js +168 -0
- package/dist/ui-helpers.js.map +1 -0
- package/dist/usage.d.ts +43 -0
- package/dist/usage.d.ts.map +1 -0
- package/dist/usage.js +114 -0
- package/dist/usage.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/* Monaco language support for .prmd — tokenizer (YAML frontmatter + markdown
|
|
2
|
+
* body + jinja tokens), editor themes matching the app palette, a completion
|
|
3
|
+
* provider fed per-model with TemplateVars, and marker-based diagnostics from
|
|
4
|
+
* lib/templateRefs. Registered once against the app's bundled Monaco instance
|
|
5
|
+
* (lib/monaco.ts). */
|
|
6
|
+
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
|
7
|
+
import { completionContext, lintTemplateRefs } from './templateRefs';
|
|
8
|
+
import { registerLanguageExtension } from './languages';
|
|
9
|
+
export const PRMD_LANG = 'prmd';
|
|
10
|
+
export const PRMD_THEME_LIGHT = 'prompd-light';
|
|
11
|
+
export const PRMD_THEME_DARK = 'prompd-dark';
|
|
12
|
+
/** Completable vars per model — the provider is global, the vars are not. */
|
|
13
|
+
const modelVars = new WeakMap();
|
|
14
|
+
export function setPrmdTemplateVars(model, vars) {
|
|
15
|
+
modelVars.set(model, vars);
|
|
16
|
+
}
|
|
17
|
+
/** Lint unknown `{{ refs }}` against `known` and surface them as error markers
|
|
18
|
+
* (squiggly + hover message + problems affordances, all native Monaco). */
|
|
19
|
+
export function applyPrmdMarkers(model, known) {
|
|
20
|
+
const diags = lintTemplateRefs(model.getValue(), known.map((v) => v.name));
|
|
21
|
+
monaco.editor.setModelMarkers(model, PRMD_LANG, diags.map((d) => {
|
|
22
|
+
const s = model.getPositionAt(d.start);
|
|
23
|
+
const e = model.getPositionAt(d.end);
|
|
24
|
+
return {
|
|
25
|
+
severity: monaco.MarkerSeverity.Error,
|
|
26
|
+
message: d.message,
|
|
27
|
+
startLineNumber: s.lineNumber,
|
|
28
|
+
startColumn: s.column,
|
|
29
|
+
endLineNumber: e.lineNumber,
|
|
30
|
+
endColumn: e.column,
|
|
31
|
+
};
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
export function clearPrmdMarkers(model) {
|
|
35
|
+
monaco.editor.setModelMarkers(model, PRMD_LANG, []);
|
|
36
|
+
}
|
|
37
|
+
let registered = false;
|
|
38
|
+
export function ensurePrmdLanguage() {
|
|
39
|
+
if (registered)
|
|
40
|
+
return;
|
|
41
|
+
registered = true;
|
|
42
|
+
monaco.languages.register({ id: PRMD_LANG, extensions: ['.prmd'] });
|
|
43
|
+
monaco.languages.setLanguageConfiguration(PRMD_LANG, {
|
|
44
|
+
comments: { blockComment: ['{#', '#}'] },
|
|
45
|
+
brackets: [['{', '}'], ['[', ']'], ['(', ')']],
|
|
46
|
+
autoClosingPairs: [
|
|
47
|
+
{ open: '{', close: '}' },
|
|
48
|
+
{ open: '[', close: ']' },
|
|
49
|
+
{ open: '(', close: ')' },
|
|
50
|
+
{ open: '"', close: '"', notIn: ['string'] },
|
|
51
|
+
{ open: "'", close: "'", notIn: ['string'] },
|
|
52
|
+
],
|
|
53
|
+
surroundingPairs: [
|
|
54
|
+
{ open: '{', close: '}' },
|
|
55
|
+
{ open: '[', close: ']' },
|
|
56
|
+
{ open: '(', close: ')' },
|
|
57
|
+
{ open: '"', close: '"' },
|
|
58
|
+
{ open: "'", close: "'" },
|
|
59
|
+
{ open: '*', close: '*' },
|
|
60
|
+
{ open: '`', close: '`' },
|
|
61
|
+
],
|
|
62
|
+
});
|
|
63
|
+
// Frontmatter only at the top of the document (leading blank lines allowed),
|
|
64
|
+
// mirroring the runtime parser: root waits for the first fence or any other
|
|
65
|
+
// content, then commits to @frontmatter or @body for the rest of the file.
|
|
66
|
+
monaco.languages.setMonarchTokensProvider(PRMD_LANG, {
|
|
67
|
+
defaultToken: '',
|
|
68
|
+
tokenizer: {
|
|
69
|
+
root: [
|
|
70
|
+
[/^---\s*$/, { token: 'meta.fence', next: '@frontmatter' }],
|
|
71
|
+
[/^\s+$/, ''],
|
|
72
|
+
[/./, { token: '@rematch', next: '@body' }],
|
|
73
|
+
],
|
|
74
|
+
frontmatter: [
|
|
75
|
+
[/^---\s*$/, { token: 'meta.fence', next: '@body' }],
|
|
76
|
+
{ include: '@jinja' },
|
|
77
|
+
[/(^|\s)#.*$/, 'comment'],
|
|
78
|
+
[/^[ \t]*(?:-[ \t]+)?[\w.-]+(?=\s*:)/, 'type'],
|
|
79
|
+
[/"[^"]*"|'[^']*'/, 'string'],
|
|
80
|
+
[/\b\d+(\.\d+)?\b/, 'number'],
|
|
81
|
+
[/\b(true|false|null)\b/, 'keyword'],
|
|
82
|
+
],
|
|
83
|
+
body: [
|
|
84
|
+
{ include: '@jinja' },
|
|
85
|
+
[/^#{1,6}\s.*$/, 'md.header'],
|
|
86
|
+
[/\*\*[^*]+\*\*/, 'md.bold'],
|
|
87
|
+
[/`[^`]+`/, 'md.code'],
|
|
88
|
+
[/^\s*(?:[-*]|\d+\.)(?=\s)/, 'md.list'],
|
|
89
|
+
],
|
|
90
|
+
jinja: [
|
|
91
|
+
[/\{#.*?#\}/, 'jinja.comment'],
|
|
92
|
+
[/\{\{.*?\}\}/, 'jinja.var'],
|
|
93
|
+
[/\{%.*?%\}/, 'jinja.tag'],
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
// Palettes mirror the app's highlighter colors (styles/app.css .jv/.jt/.h/...).
|
|
98
|
+
monaco.editor.defineTheme(PRMD_THEME_LIGHT, {
|
|
99
|
+
base: 'vs',
|
|
100
|
+
inherit: true,
|
|
101
|
+
rules: [
|
|
102
|
+
{ token: 'meta.fence', foreground: '9aa3af' },
|
|
103
|
+
{ token: 'jinja.var', foreground: 'b45309', fontStyle: 'bold' },
|
|
104
|
+
{ token: 'jinja.tag', foreground: '6d28d9' },
|
|
105
|
+
{ token: 'jinja.comment', foreground: '9aa3af', fontStyle: 'italic' },
|
|
106
|
+
{ token: 'md.header', foreground: '2563eb', fontStyle: 'bold' },
|
|
107
|
+
{ token: 'md.bold', fontStyle: 'bold' },
|
|
108
|
+
{ token: 'md.code', foreground: 'b45309' },
|
|
109
|
+
{ token: 'md.list', foreground: '7c3aed' },
|
|
110
|
+
],
|
|
111
|
+
colors: { 'editor.background': '#f7f8fb' },
|
|
112
|
+
});
|
|
113
|
+
monaco.editor.defineTheme(PRMD_THEME_DARK, {
|
|
114
|
+
base: 'vs-dark',
|
|
115
|
+
inherit: true,
|
|
116
|
+
rules: [
|
|
117
|
+
{ token: 'meta.fence', foreground: '6b7280' },
|
|
118
|
+
{ token: 'jinja.var', foreground: 'fbbf24', fontStyle: 'bold' },
|
|
119
|
+
{ token: 'jinja.tag', foreground: 'c4b5fd' },
|
|
120
|
+
{ token: 'jinja.comment', foreground: '6b7280', fontStyle: 'italic' },
|
|
121
|
+
{ token: 'md.header', foreground: '93c5fd', fontStyle: 'bold' },
|
|
122
|
+
{ token: 'md.bold', fontStyle: 'bold' },
|
|
123
|
+
{ token: 'md.code', foreground: 'fbbf24' },
|
|
124
|
+
{ token: 'md.list', foreground: 'c4b5fd' },
|
|
125
|
+
],
|
|
126
|
+
colors: { 'editor.background': '#0a0f1a' },
|
|
127
|
+
});
|
|
128
|
+
monaco.languages.registerCompletionItemProvider(PRMD_LANG, {
|
|
129
|
+
triggerCharacters: ['{', ' '],
|
|
130
|
+
provideCompletionItems(model, position) {
|
|
131
|
+
const vars = modelVars.get(model);
|
|
132
|
+
if (!vars?.length)
|
|
133
|
+
return { suggestions: [] };
|
|
134
|
+
// ' ' is a trigger char, so this runs on every space typed in prose —
|
|
135
|
+
// bail on the current line alone before materializing the whole doc.
|
|
136
|
+
const line = model.getLineContent(position.lineNumber);
|
|
137
|
+
if (!line.includes('{{') && !line.includes('{%'))
|
|
138
|
+
return { suggestions: [] };
|
|
139
|
+
const ctx = completionContext(model.getValue(), model.getOffsetAt(position));
|
|
140
|
+
if (!ctx)
|
|
141
|
+
return { suggestions: [] };
|
|
142
|
+
const start = model.getPositionAt(ctx.start);
|
|
143
|
+
const range = new monaco.Range(start.lineNumber, start.column, position.lineNumber, position.column);
|
|
144
|
+
const closer = ctx.opener === '{{' && !ctx.closed ? ' }}' : '';
|
|
145
|
+
return {
|
|
146
|
+
suggestions: vars.map((v, i) => ({
|
|
147
|
+
label: v.name,
|
|
148
|
+
kind: monaco.languages.CompletionItemKind.Variable,
|
|
149
|
+
detail: v.detail,
|
|
150
|
+
documentation: v.doc,
|
|
151
|
+
insertText: v.name + closer,
|
|
152
|
+
range,
|
|
153
|
+
sortText: String(i).padStart(3, '0'),
|
|
154
|
+
})),
|
|
155
|
+
};
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
// Hover over a `{{ param }}` (or `{% … param … %}`) token shows the parameter's
|
|
159
|
+
// type + description — the same per-model vars the completion provider uses, so
|
|
160
|
+
// it covers every declared parameter, not just a fixed set.
|
|
161
|
+
monaco.languages.registerHoverProvider(PRMD_LANG, {
|
|
162
|
+
provideHover(model, position) {
|
|
163
|
+
const vars = modelVars.get(model);
|
|
164
|
+
if (!vars?.length)
|
|
165
|
+
return null;
|
|
166
|
+
const word = model.getWordAtPosition(position);
|
|
167
|
+
if (!word)
|
|
168
|
+
return null;
|
|
169
|
+
const v = vars.find((x) => x.name === word.word);
|
|
170
|
+
if (!v)
|
|
171
|
+
return null;
|
|
172
|
+
// Only when the word actually sits inside a jinja expression on this line —
|
|
173
|
+
// not a prose word that happens to share a parameter's name.
|
|
174
|
+
const line = model.getLineContent(position.lineNumber);
|
|
175
|
+
const start = word.startColumn - 1;
|
|
176
|
+
const end = word.endColumn - 1;
|
|
177
|
+
let inExpr = false;
|
|
178
|
+
for (const m of line.matchAll(/\{\{[\s\S]*?\}\}|\{%[\s\S]*?%\}/g)) {
|
|
179
|
+
const s = m.index ?? 0;
|
|
180
|
+
if (start >= s && end <= s + m[0].length) {
|
|
181
|
+
inExpr = true;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (!inExpr)
|
|
186
|
+
return null;
|
|
187
|
+
const contents = [
|
|
188
|
+
{ value: `**${v.name}**${v.detail ? ` — _${v.detail}_` : ''}` },
|
|
189
|
+
];
|
|
190
|
+
if (v.doc)
|
|
191
|
+
contents.push({ value: v.doc });
|
|
192
|
+
return {
|
|
193
|
+
range: new monaco.Range(position.lineNumber, word.startColumn, position.lineNumber, word.endColumn),
|
|
194
|
+
contents,
|
|
195
|
+
};
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
// .prmd is one of corenel's native formats — register it as a default language
|
|
200
|
+
// extension so the language-agnostic editor installs it via the registry, and
|
|
201
|
+
// expose its per-model assist (param completions + unknown-ref markers) so the
|
|
202
|
+
// editor delegates by language id rather than hardcoding prmd.
|
|
203
|
+
registerLanguageExtension({
|
|
204
|
+
id: PRMD_LANG,
|
|
205
|
+
extensions: ['.prmd'],
|
|
206
|
+
register: () => ensurePrmdLanguage(),
|
|
207
|
+
assist: {
|
|
208
|
+
sync(model, assist) {
|
|
209
|
+
const a = (assist ?? null);
|
|
210
|
+
setPrmdTemplateVars(model, a?.vars ?? []);
|
|
211
|
+
if (a?.lint)
|
|
212
|
+
applyPrmdMarkers(model, a.vars);
|
|
213
|
+
else
|
|
214
|
+
clearPrmdMarkers(model);
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
});
|
|
218
|
+
//# sourceMappingURL=prmdLanguage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prmdLanguage.js","sourceRoot":"","sources":["../prmdLanguage.ts"],"names":[],"mappings":"AAAA;;;;sBAIsB;AACtB,OAAO,KAAK,MAAM,MAAM,wCAAwC,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAoB,MAAM,gBAAgB,CAAC;AACvF,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAExD,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC;AAChC,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAC/C,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC;AAE7C,6EAA6E;AAC7E,MAAM,SAAS,GAAG,IAAI,OAAO,EAA2C,CAAC;AAEzE,MAAM,UAAU,mBAAmB,CAAC,KAA+B,EAAE,IAAmB;IACtF,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED;2EAC2E;AAC3E,MAAM,UAAU,g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AAE,CAAC,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;YAC1C,IAAI,CAAC,EAAE,IAAI;gBAAE,gBAAgB,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;;gBACxC,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;KACF;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** One identifier reference found in a template expression (global offsets). */
|
|
2
|
+
export interface TemplateRef {
|
|
3
|
+
name: string;
|
|
4
|
+
start: number;
|
|
5
|
+
end: number;
|
|
6
|
+
}
|
|
7
|
+
/** A completable name: a .prmd parameter or a workflow state field. Shared by
|
|
8
|
+
* the Monaco completion provider and the lightweight textarea popup. */
|
|
9
|
+
export interface TemplateVar {
|
|
10
|
+
name: string;
|
|
11
|
+
/** Short kind/type tag ("string", "param", "node output"). */
|
|
12
|
+
detail?: string;
|
|
13
|
+
/** One-line description (param description / node label). */
|
|
14
|
+
doc?: string;
|
|
15
|
+
}
|
|
16
|
+
/** A reference whose root is not declared anywhere the linter knows about. */
|
|
17
|
+
export interface TemplateDiagnostic {
|
|
18
|
+
name: string;
|
|
19
|
+
start: number;
|
|
20
|
+
end: number;
|
|
21
|
+
message: string;
|
|
22
|
+
}
|
|
23
|
+
/** Offset where the body starts (after the closing frontmatter fence), or 0
|
|
24
|
+
* when there is no frontmatter. Mirrors highlightPrmd's fence detection. */
|
|
25
|
+
export declare function bodyStart(source: string): number;
|
|
26
|
+
/** All identifier references + locally declared names ({% for %}, {% set %})
|
|
27
|
+
* in the template body of `source`. */
|
|
28
|
+
export declare function extractTemplateRefs(source: string): {
|
|
29
|
+
refs: TemplateRef[];
|
|
30
|
+
declared: Set<string>;
|
|
31
|
+
};
|
|
32
|
+
/** References whose root is not in `known`, not locally declared, and not a
|
|
33
|
+
* builtin — the squiggly set. */
|
|
34
|
+
export declare function lintTemplateRefs(source: string, known: Iterable<string>, message?: (name: string) => string): TemplateDiagnostic[];
|
|
35
|
+
/** Where completion applies at `caret`: inside an unclosed-or-closed `{{ }}` /
|
|
36
|
+
* `{% %}` expression on the current line, with the identifier prefix typed so
|
|
37
|
+
* far. Null = no completion here (outside a token, in a filter, after a dot,
|
|
38
|
+
* still inside the tag word, or in the frontmatter). */
|
|
39
|
+
export interface CompletionContext {
|
|
40
|
+
/** Global offset where the prefix starts (replace [start, caret)). */
|
|
41
|
+
start: number;
|
|
42
|
+
prefix: string;
|
|
43
|
+
opener: '{{' | '{%';
|
|
44
|
+
/** Whether the token is already closed later on this line. */
|
|
45
|
+
closed: boolean;
|
|
46
|
+
/** True when the expression before the prefix is empty (just opened a token). */
|
|
47
|
+
atExprStart: boolean;
|
|
48
|
+
}
|
|
49
|
+
export declare function completionContext(source: string, caret: number): CompletionContext | null;
|
|
50
|
+
/** What an editor surface needs for a templated doc: `vars` feeds the `{{ }}`
|
|
51
|
+
* completion provider; `lint` adds error squigglies on unknown references. */
|
|
52
|
+
export interface EditorAssist {
|
|
53
|
+
vars: TemplateVar[];
|
|
54
|
+
lint?: boolean;
|
|
55
|
+
}
|
|
56
|
+
/** Build the editor assistance for a parsed .prmd doc (null for other files).
|
|
57
|
+
* Single source for every editor surface so they can't drift. When the doc
|
|
58
|
+
* declares `inherits:` or `using:`, parameters may come from files the client
|
|
59
|
+
* hasn't resolved (that resolution is backend-side), so the local declared-set
|
|
60
|
+
* is incomplete — completions stay, lint stands down to avoid false errors. */
|
|
61
|
+
export declare function buildPrmdAssist(fileName: string, parsed: {
|
|
62
|
+
params: Array<{
|
|
63
|
+
name: string;
|
|
64
|
+
type?: string;
|
|
65
|
+
description?: string;
|
|
66
|
+
}>;
|
|
67
|
+
meta: Record<string, unknown>;
|
|
68
|
+
}): EditorAssist | null;
|
|
69
|
+
//# sourceMappingURL=templateRefs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateRefs.d.ts","sourceRoot":"","sources":["../templateRefs.ts"],"names":[],"mappings":"A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GAAG,iBAAiB,GAAG,IAAI,CA2CzF;AAID;8EAC8E;AAC9E,MAAM,WAAW,YAAY;IAAG,IAAI,EAAE,WAAW,EAAE,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE;AAYrE;;;;+EAI+E;AAC/E,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE;IAAE,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAC9G,YAAY,GAAG,IAAI,CASrB"}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/* Static analysis of the Jinja/Nunjucks template syntax in .prmd bodies and
|
|
2
|
+
* .pdflow node templates — pure string work, no compiler involved. Powers the
|
|
3
|
+
* editor's parameter completions and unknown-reference squigglies. It is a
|
|
4
|
+
* deliberately small approximation of the real engine: identifier ROOTS only
|
|
5
|
+
* (`user.name` references `user`), filters and their arguments are ignored,
|
|
6
|
+
* and `{% for %}` / `{% set %}` declarations count as known everywhere (no
|
|
7
|
+
* block scoping). False negatives are fine; false positives erode trust.
|
|
8
|
+
*/
|
|
9
|
+
/** Expression-language words that are never variable references. */
|
|
10
|
+
const KEYWORDS = new Set([
|
|
11
|
+
'if', 'elif', 'else', 'endif', 'for', 'endfor', 'in', 'and', 'or', 'not', 'is',
|
|
12
|
+
'set', 'endset', 'true', 'false', 'none', 'null', 'True', 'False', 'None',
|
|
13
|
+
]);
|
|
14
|
+
/** Names that are always available: Nunjucks globals + the loop variable + the
|
|
15
|
+
* workflow-context names a .prmd legitimately uses when run inside a .pdflow. */
|
|
16
|
+
const BUILTINS = new Set(['loop', 'range', 'cycler', 'joiner', 'input', 'previous_output']);
|
|
17
|
+
const TOKEN_RE = /\{\{[\s\S]*?\}\}|\{%[\s\S]*?%\}|\{#[\s\S]*?#\}/g;
|
|
18
|
+
const IDENT_RE = /[A-Za-z_][A-Za-z0-9_]*/g;
|
|
19
|
+
/** Offset where the body starts (after the closing frontmatter fence), or 0
|
|
20
|
+
* when there is no frontmatter. Mirrors highlightPrmd's fence detection. */
|
|
21
|
+
export function bodyStart(source) {
|
|
22
|
+
const lines = source.split('\n');
|
|
23
|
+
let s1 = -1;
|
|
24
|
+
let offset = 0;
|
|
25
|
+
for (let i = 0; i < lines.length; i++) {
|
|
26
|
+
const isFence = lines[i].trim() === '---';
|
|
27
|
+
offset += lines[i].length + 1;
|
|
28
|
+
if (s1 === -1) {
|
|
29
|
+
if (isFence)
|
|
30
|
+
s1 = i;
|
|
31
|
+
else if (lines[i].trim() !== '')
|
|
32
|
+
return 0; // content before any fence — no frontmatter
|
|
33
|
+
}
|
|
34
|
+
else if (isFence) {
|
|
35
|
+
return Math.min(offset, source.length); // line after the closing fence
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// Unterminated frontmatter is highlighted as YAML to the end — lint nothing.
|
|
39
|
+
return s1 === -1 ? 0 : source.length;
|
|
40
|
+
}
|
|
41
|
+
/** Neutralize whitespace-control dashes (`{%- ... -%}` / `{{- ... -}}`) in a
|
|
42
|
+
* token's inner text, preserving length so offsets stay valid. */
|
|
43
|
+
function stripWsControl(inner) {
|
|
44
|
+
let s = inner;
|
|
45
|
+
if (s.startsWith('-'))
|
|
46
|
+
s = ' ' + s.slice(1);
|
|
47
|
+
if (s.endsWith('-'))
|
|
48
|
+
s = s.slice(0, -1) + ' ';
|
|
49
|
+
return s;
|
|
50
|
+
}
|
|
51
|
+
/** Blank out string literals (preserving length) so identifier scans skip them. */
|
|
52
|
+
function stripStrings(expr) {
|
|
53
|
+
return expr.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g, (m) => ' '.repeat(m.length));
|
|
54
|
+
}
|
|
55
|
+
/** Scan one expression for identifier roots. `base` is the expression's global
|
|
56
|
+
* offset. Attribute accesses (`x.attr`), keywords, and Jinja test names
|
|
57
|
+
* (`x is defined`, `y is not none`) are skipped. */
|
|
58
|
+
function scanExpr(expr, base, out) {
|
|
59
|
+
let clean = stripStrings(expr);
|
|
60
|
+
// `is [not] <test>` — the test word is a test name, not a variable.
|
|
61
|
+
clean = clean.replace(/\bis(\s+not)?\s+[A-Za-z_][A-Za-z0-9_]*/g, (m) => ' '.repeat(m.length));
|
|
62
|
+
IDENT_RE.lastIndex = 0;
|
|
63
|
+
let m;
|
|
64
|
+
while ((m = IDENT_RE.exec(clean))) {
|
|
65
|
+
const name = m[0];
|
|
66
|
+
if (KEYWORDS.has(name))
|
|
67
|
+
continue;
|
|
68
|
+
// Skip attribute access: the previous non-space char is a dot.
|
|
69
|
+
let p = m.index - 1;
|
|
70
|
+
while (p >= 0 && (clean[p] === ' ' || clean[p] === '\t'))
|
|
71
|
+
p--;
|
|
72
|
+
if (p >= 0 && clean[p] === '.')
|
|
73
|
+
continue;
|
|
74
|
+
out.push({ name, start: base + m.index, end: base + m.index + name.length });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/** All identifier references + locally declared names ({% for %}, {% set %})
|
|
78
|
+
* in the template body of `source`. */
|
|
79
|
+
export function extractTemplateRefs(source) {
|
|
80
|
+
const from = bodyStart(source);
|
|
81
|
+
const refs = [];
|
|
82
|
+
const declared = new Set();
|
|
83
|
+
TOKEN_RE.lastIndex = 0;
|
|
84
|
+
let m;
|
|
85
|
+
while ((m = TOKEN_RE.exec(source))) {
|
|
86
|
+
if (m.index < from)
|
|
87
|
+
continue;
|
|
88
|
+
const raw = m[0];
|
|
89
|
+
if (raw.startsWith('{#'))
|
|
90
|
+
continue;
|
|
91
|
+
if (raw.startsWith('{{')) {
|
|
92
|
+
let expr = stripWsControl(raw.slice(2, -2));
|
|
93
|
+
// Everything from the first filter pipe on is filter territory — skip it
|
|
94
|
+
// (filter args can be refs; missing those is an accepted false negative).
|
|
95
|
+
const pipe = stripStrings(expr).indexOf('|');
|
|
96
|
+
if (pipe >= 0)
|
|
97
|
+
expr = expr.slice(0, pipe);
|
|
98
|
+
scanExpr(expr, m.index + 2, refs);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
// {% tag ... %} (whitespace-control dashes neutralized, length preserved)
|
|
102
|
+
const inner = stripWsControl(raw.slice(2, -2));
|
|
103
|
+
const tagMatch = /^\s*([A-Za-z_][A-Za-z0-9_]*)/.exec(inner);
|
|
104
|
+
if (!tagMatch)
|
|
105
|
+
continue;
|
|
106
|
+
const tag = tagMatch[1];
|
|
107
|
+
const afterTag = tagMatch.index + tagMatch[0].length;
|
|
108
|
+
if (tag === 'if' || tag === 'elif') {
|
|
109
|
+
scanExpr(inner.slice(afterTag), m.index + 2 + afterTag, refs);
|
|
110
|
+
}
|
|
111
|
+
else if (tag === 'for') {
|
|
112
|
+
const inAt = stripStrings(inner).search(/\bin\b/);
|
|
113
|
+
if (inAt > afterTag) {
|
|
114
|
+
// loop variables declare names; the iterable is a reference
|
|
115
|
+
for (const v of inner.slice(afterTag, inAt).split(',')) {
|
|
116
|
+
const name = v.trim();
|
|
117
|
+
if (/^[A-Za-z_][A-Za-z0-9_]*$/.test(name))
|
|
118
|
+
declared.add(name);
|
|
119
|
+
}
|
|
120
|
+
scanExpr(inner.slice(inAt + 2), m.index + 2 + inAt + 2, refs);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
else if (tag === 'set') {
|
|
124
|
+
const rest = inner.slice(afterTag);
|
|
125
|
+
const setMatch = /^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=([\s\S]*)$/.exec(rest);
|
|
126
|
+
if (setMatch) {
|
|
127
|
+
declared.add(setMatch[1]);
|
|
128
|
+
const rhsOffset = afterTag + setMatch[0].length - setMatch[2].length;
|
|
129
|
+
scanExpr(setMatch[2], m.index + 2 + rhsOffset, refs);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
// block form: {% set name %}...{% endset %}
|
|
133
|
+
const blockMatch = /^\s*([A-Za-z_][A-Za-z0-9_]*)\s*$/.exec(rest);
|
|
134
|
+
if (blockMatch)
|
|
135
|
+
declared.add(blockMatch[1]);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// other tags (else/endif/endfor/endset/...) declare and reference nothing
|
|
139
|
+
}
|
|
140
|
+
return { refs, declared };
|
|
141
|
+
}
|
|
142
|
+
/** References whose root is not in `known`, not locally declared, and not a
|
|
143
|
+
* builtin — the squiggly set. */
|
|
144
|
+
export function lintTemplateRefs(source, known, message = (n) => `"${n}" isn't a declared parameter.`) {
|
|
145
|
+
const knownSet = new Set(known);
|
|
146
|
+
const { refs, declared } = extractTemplateRefs(source);
|
|
147
|
+
const out = [];
|
|
148
|
+
for (const r of refs) {
|
|
149
|
+
if (knownSet.has(r.name) || declared.has(r.name) || BUILTINS.has(r.name))
|
|
150
|
+
continue;
|
|
151
|
+
out.push({ ...r, message: message(r.name) });
|
|
152
|
+
}
|
|
153
|
+
return out;
|
|
154
|
+
}
|
|
155
|
+
export function completionContext(source, caret) {
|
|
156
|
+
if (caret < bodyStart(source))
|
|
157
|
+
return null;
|
|
158
|
+
const lineStart = source.lastIndexOf('\n', caret - 1) + 1;
|
|
159
|
+
const lineEndIdx = source.indexOf('\n', caret);
|
|
160
|
+
const lineEnd = lineEndIdx === -1 ? source.length : lineEndIdx;
|
|
161
|
+
const before = source.slice(lineStart, caret);
|
|
162
|
+
// An unclosed {# before the caret means we're inside a comment — no
|
|
163
|
+
// completion, even when the comment text contains a {{ or {%.
|
|
164
|
+
const ovc = before.lastIndexOf('{#');
|
|
165
|
+
if (ovc !== -1 && !before.slice(ovc + 2).includes('#}'))
|
|
166
|
+
return null;
|
|
167
|
+
const ovv = before.lastIndexOf('{{');
|
|
168
|
+
const ovt = before.lastIndexOf('{%');
|
|
169
|
+
const openerIdx = Math.max(ovv, ovt);
|
|
170
|
+
if (openerIdx === -1)
|
|
171
|
+
return null;
|
|
172
|
+
const opener = openerIdx === ovv ? '{{' : '{%';
|
|
173
|
+
const between = before.slice(openerIdx + 2);
|
|
174
|
+
if (between.includes('}}') || between.includes('%}') || between.includes('#}'))
|
|
175
|
+
return null; // caret is past the token
|
|
176
|
+
let exprStart = openerIdx + 2;
|
|
177
|
+
if (opener === '{%') {
|
|
178
|
+
const tagMatch = /^-?\s*[A-Za-z_][A-Za-z0-9_]*\s/.exec(between);
|
|
179
|
+
if (!tagMatch)
|
|
180
|
+
return null; // still typing the tag word
|
|
181
|
+
exprStart = openerIdx + 2 + tagMatch[0].length;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
if (between.startsWith('-'))
|
|
185
|
+
exprStart += 1; // {{- whitespace control
|
|
186
|
+
if (stripStrings(between).includes('|'))
|
|
187
|
+
return null; // filter zone
|
|
188
|
+
}
|
|
189
|
+
// identifier prefix immediately before the caret
|
|
190
|
+
let ps = caret;
|
|
191
|
+
while (ps > lineStart + exprStart && /[A-Za-z0-9_]/.test(source[ps - 1]))
|
|
192
|
+
ps--;
|
|
193
|
+
if (/[0-9]/.test(source[ps] ?? ''))
|
|
194
|
+
return null; // prefix can't start with a digit
|
|
195
|
+
let q = ps - 1;
|
|
196
|
+
while (q >= lineStart && (source[q] === ' ' || source[q] === '\t'))
|
|
197
|
+
q--;
|
|
198
|
+
if (q >= lineStart && source[q] === '.')
|
|
199
|
+
return null; // attribute access
|
|
200
|
+
const rest = source.slice(caret, lineEnd);
|
|
201
|
+
const closed = opener === '{{' ? rest.includes('}}') : rest.includes('%}');
|
|
202
|
+
const exprBefore = source.slice(lineStart + exprStart, ps);
|
|
203
|
+
return {
|
|
204
|
+
start: ps,
|
|
205
|
+
prefix: source.slice(ps, caret),
|
|
206
|
+
opener,
|
|
207
|
+
closed,
|
|
208
|
+
atExprStart: exprBefore.trim() === '',
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
/** Context names the prompd test runner injects into a `.test.prmd` judge body
|
|
212
|
+
* (see testing/prompd/adapter.ts) — always available regardless of the
|
|
213
|
+
* `parameters:` block, so the editor must not flag them. Mirrors how `input` /
|
|
214
|
+
* `previous_output` are builtins for a .prmd run inside a workflow. */
|
|
215
|
+
const TEST_CONTEXT = [
|
|
216
|
+
{ name: 'prompt', detail: 'test context', doc: 'The compiled prompt sent to the model under test.' },
|
|
217
|
+
{ name: 'response', detail: 'test context', doc: 'The model response being evaluated.' },
|
|
218
|
+
{ name: 'params', detail: 'test context', doc: 'The test case params as a JSON string.' },
|
|
219
|
+
];
|
|
220
|
+
/** Build the editor assistance for a parsed .prmd doc (null for other files).
|
|
221
|
+
* Single source for every editor surface so they can't drift. When the doc
|
|
222
|
+
* declares `inherits:` or `using:`, parameters may come from files the client
|
|
223
|
+
* hasn't resolved (that resolution is backend-side), so the local declared-set
|
|
224
|
+
* is incomplete — completions stay, lint stands down to avoid false errors. */
|
|
225
|
+
export function buildPrmdAssist(fileName, parsed) {
|
|
226
|
+
if (!/\.prmd$/i.test(fileName))
|
|
227
|
+
return null;
|
|
228
|
+
const external = parsed.meta.inherits != null || parsed.meta.using != null;
|
|
229
|
+
const vars = parsed.params.map((p) => ({ name: p.name, detail: p.type || 'param', doc: p.description }));
|
|
230
|
+
// .test.prmd judge bodies reference the runner-injected prompt/response/params.
|
|
231
|
+
if (/\.test\.prmd$/i.test(fileName)) {
|
|
232
|
+
for (const v of TEST_CONTEXT)
|
|
233
|
+
if (!vars.some((x) => x.name === v.name))
|
|
234
|
+
vars.push(v);
|
|
235
|
+
}
|
|
236
|
+
return { vars, lint: !external };
|
|
237
|
+
}
|
|
238
|
+
//# sourceMappingURL=templateRefs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateRefs.js","sourceRoot":"","sources":["../templateRefs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAkBH,oEAAoE;AACpE,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC;IACvB,IAAI,EAAE,MA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,EAAE,CAAC,QAAQ,EAAE,CAAC;AACnC,CAAC"}
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type Theme = 'dark' | 'light';
|
|
2
|
+
export declare function getTheme(): Theme;
|
|
3
|
+
export declare function applyTheme(t: Theme): void;
|
|
4
|
+
export declare function setTheme(t: Theme): void;
|
|
5
|
+
export declare function initTheme(): void;
|
|
6
|
+
export type EditorControls = 'auto' | 'labels' | 'icons';
|
|
7
|
+
export declare function getEditorControls(): EditorControls;
|
|
8
|
+
export declare function applyEditorControls(v: EditorControls): void;
|
|
9
|
+
export declare function setEditorControls(v: EditorControls): void;
|
|
10
|
+
import type { CompressionMode } from '@corenel/protocol';
|
|
11
|
+
export declare function getCompression(): CompressionMode;
|
|
12
|
+
export declare function setCompression(v: CompressionMode): void;
|
|
13
|
+
export declare function getShowHelp(): boolean;
|
|
14
|
+
export declare function setShowHelp(v: boolean): void;
|
|
15
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../theme.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;AAGrC,wBAAgB,QAAQ,IAAI,KAAK,CAEhC;AACD,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAEzC;AACD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAKvC;AACD,wBAAgB,SAAS,IAAI,IAAI,CAGhC;AAKD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAGzD,wBAAgB,iBAAiB,IAAI,cAAc,CAKlD;AACD,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,cAAc,GAAG,IAAI,CAE3D;AACD,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,cAAc,GAAG,IAAI,CAGzD;AAID,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,wBAAgB,cAAc,IAAI,eAAe,CAKhD;AACD,wBAAgB,cAAc,CAAC,CAAC,EAAE,eAAe,GAAG,IAAI,CAEvD;AAID,wBAAgB,WAAW,IAAI,OAAO,CAErC;AACD,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,IAAI,CAE5C"}
|