diff --git a/package-lock.json b/package-lock.json index c9d93e9..b86cb29 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@sema-lang/ui", - "version": "0.1.4", + "version": "0.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@sema-lang/ui", - "version": "0.1.4", + "version": "0.2.0", "license": "MIT", "dependencies": { "@lit/task": "^1.0.3", diff --git a/src/grammars/sema.tmLanguage.json b/src/grammars/sema.tmLanguage.json index 3de9967..8f03646 100644 --- a/src/grammars/sema.tmLanguage.json +++ b/src/grammars/sema.tmLanguage.json @@ -140,7 +140,7 @@ }, { "comment": "defun/defmacro/defmulti/defmethod/defagent/deftool name", - "match": "(\\()\\s*(defun|defmacro|defmulti|defmethod|defagent|deftool|defn|defworkflow|define-record-type)\\s+([\\w!$%&*+\\-./:<=>?@^~][\\w!$%&*+\\-./:<=>?@^~0-9]*)", + "match": "(\\()\\s*(defun|defmacro|defmulti|defmethod|defagent|deftool|defn|defworkflow|defpolicy|define-record-type)\\s+([\\w!$%&*+\\-./:<=>?@^~][\\w!$%&*+\\-./:<=>?@^~0-9]*)", "captures": { "1": { "name": "punctuation.paren.open.sema" @@ -171,7 +171,7 @@ ] }, "special-form": { - "match": "(?<=[\\s(\\[{])(?:define|async|await|defn|def|progn|dotimes|for-range|with-retry|with-session|with-span|with-stream|defworkflow|defun|lambda|fn|if|if-let|cond|case|when|when-let|unless|let\\*?|letrec|begin|do|while|and|or|set!|quote|quasiquote|unquote-splicing|unquote|define-record-type|defmacro|defmethod|defmulti|defagent|deftool|try|catch|throw|import|module|export|load|delay|force|eval|macroexpand|else|prompt|message|match\\*|match)(?=[\\s)\\]}]|$)", + "match": "(?<=[\\s(\\[{])(?:define|async|await|defn|def|progn|dotimes|for-range|with-retry|with-session|with-span|with-stream|defworkflow|defpolicy|defun|lambda|fn|if|if-let|cond|case|when|when-let|unless|let\\*?|letrec|begin|do|while|and|or|set!|quote|quasiquote|unquote-splicing|unquote|define-record-type|defmacro|defmethod|defmulti|defagent|deftool|try|catch|throw|import|module|export|load|delay|force|eval|macroexpand|else|prompt|message|match\\*|match)(?=[\\s)\\]}]|$)", "name": "keyword.control.sema" }, "operator": { @@ -386,7 +386,7 @@ }, { "comment": "Tool query functions", - "match": "(?<=[\\s(\\[{])(?:tool/name|tool/description|tool/parameters)(?=[\\s)\\]}]|$)", + "match": "(?<=[\\s(\\[{])(?:tool/name|tool/description|tool/parameters|tool/policy-subjects)(?=[\\s)\\]}]|$)", "name": "support.function.sema" }, { @@ -486,7 +486,7 @@ }, { "comment": "issue #12 grammar sweep: workflow builtins", - "match": "(?<=[\\s(\\[{])(?:settled/err\\?|settled/ok\\?|checkpoint|parallel|parallel-settled|phase|pipeline|pipeline-settled|settled-partition|step|workflow/check|workflow/checkpoint|workflow/phase|workflow/run|workflow/run-form|workflow/step|workflow/tool-call)(?=[\\s)\\]}]|$)", + "match": "(?<=[\\s(\\[{])(?:approval|settled/err\\?|settled/ok\\?|checkpoint|parallel|parallel-settled|phase|pipeline|pipeline-settled|policy/without|settled-partition|step|workflow/approval|workflow/check|workflow/checkpoint|workflow/phase|workflow/policy-without|workflow/run|workflow/run-form|workflow/step|workflow/tool-call|workflow/tool-result)(?=[\\s)\\]}]|$)", "name": "support.function.sema" }, { diff --git a/tests/syntax-highlight-sync.test.ts b/tests/syntax-highlight-sync.test.ts index 577c271..f911dd2 100644 --- a/tests/syntax-highlight-sync.test.ts +++ b/tests/syntax-highlight-sync.test.ts @@ -17,6 +17,19 @@ describe('highlightToHtmlSync', () => { expect(out).toMatch(/define<\/span>/) }) + it('classifies workflow approval and policy forms', async () => { + await preloadLanguage('sema') + const out = highlightToHtmlSync( + '(defpolicy safe {})\n(approval :ship {})\n(policy/without "test" #t)\n(workflow/approval :ship {})\n(tool/policy-subjects publish)', + 'sema', + ) + expect(out).toContain('defpolicy') + expect(out).toContain('approval') + expect(out).toContain('policy/without') + expect(out).toContain('workflow/approval') + expect(out).toContain('tool/policy-subjects') + }) + it('supports non-sema languages too (json), unlike the old sema-only tokenizer', async () => { await preloadLanguage('json') const out = highlightToHtmlSync('{"a": 1}', 'json')