@mmmnt/feat-grammar 0.1.6

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/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, Moment
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # @mmmnt/feat-grammar
2
+
3
+ The TextMate grammar for `.feat` — the single highlighting artifact behind every
4
+ surface. Editor extensions, websites, and any TextMate-compatible tool consume
5
+ this package; the grammar is tested by tokenizing real corpus exemplars with
6
+ `vscode-textmate` (the engine VS Code itself uses).
7
+
8
+ ## Websites (Shiki)
9
+
10
+ ```js
11
+ import { createHighlighter } from "shiki";
12
+ import featLanguage from "@mmmnt/feat-grammar";
13
+
14
+ const highlighter = await createHighlighter({
15
+ themes: ["github-dark"],
16
+ langs: [featLanguage],
17
+ });
18
+ const html = highlighter.codeToHtml(specText, { lang: "feat", theme: "github-dark" });
19
+ ```
20
+
21
+ ## Editors
22
+
23
+ - **VS Code / Windsurf / Cursor / Devin**: install the `feat-vscode` extension
24
+ (VS Code Marketplace + Open VSX) — it bundles this grammar.
25
+ - **JetBrains IDEs**: Settings → Editor → TextMate Bundles → add a directory
26
+ containing `feat.tmLanguage.json`.
27
+ - **GitHub.com rendering**: requires a `github-linguist` submission (planned
28
+ once the language has public usage).
29
+
30
+ Part of [Feature](https://github.com/mmmnt/feature) — the `.feat` execution
31
+ specification language. Docs: https://github.com/mmmnt/feature/wiki
32
+
33
+ MIT
@@ -0,0 +1,202 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
3
+ "name": "Feat",
4
+ "scopeName": "source.feat",
5
+ "patterns": [
6
+ { "include": "#comment" },
7
+ { "include": "#pragma" },
8
+ { "include": "#identity" },
9
+ { "include": "#sections" },
10
+ { "include": "#scenario" },
11
+ { "include": "#trigger" },
12
+ { "include": "#prediction" },
13
+ { "include": "#matchers" },
14
+ { "include": "#refs" },
15
+ { "include": "#placeholders" },
16
+ { "include": "#strings" },
17
+ { "include": "#numbers" }
18
+ ],
19
+ "repository": {
20
+ "comment": {
21
+ "match": "#.*$",
22
+ "name": "comment.line.number-sign.feat"
23
+ },
24
+ "pragma": {
25
+ "match": "^(feat)\\s+(\\d+\\.\\d+)\\s*$",
26
+ "captures": {
27
+ "1": { "name": "keyword.control.pragma.feat" },
28
+ "2": { "name": "constant.numeric.version.feat" }
29
+ }
30
+ },
31
+ "identity": {
32
+ "patterns": [
33
+ {
34
+ "match": "^(spec)\\s+([A-Z0-9-]+)\\s+(\".*\")",
35
+ "captures": {
36
+ "1": { "name": "keyword.declaration.spec.feat" },
37
+ "2": { "name": "entity.name.type.spec-id.feat" },
38
+ "3": { "name": "string.quoted.double.feat" }
39
+ }
40
+ },
41
+ {
42
+ "match": "^(context|aggregate)\\s+(\\S+)",
43
+ "captures": {
44
+ "1": { "name": "keyword.declaration.feat" },
45
+ "2": { "name": "entity.name.namespace.feat" }
46
+ }
47
+ },
48
+ {
49
+ "match": "^(type)\\s+(command|query|infrastructure|integration|scaffold|projection|policy|saga)\\b",
50
+ "captures": {
51
+ "1": { "name": "keyword.declaration.feat" },
52
+ "2": { "name": "constant.language.spec-type.feat" }
53
+ }
54
+ },
55
+ {
56
+ "match": "^(status)\\s+(draft|agreed|built|verified)\\b",
57
+ "captures": {
58
+ "1": { "name": "keyword.declaration.feat" },
59
+ "2": { "name": "constant.language.status.feat" }
60
+ }
61
+ }
62
+ ]
63
+ },
64
+ "sections": {
65
+ "patterns": [
66
+ {
67
+ "match": "^(construct|enforce|contract|given)\\s*:",
68
+ "captures": { "1": { "name": "keyword.control.section.feat" } }
69
+ },
70
+ {
71
+ "match": "^\\s+(handler at|touches|imports|input|response|record|event|error|rejects|clock at|execute)\\b",
72
+ "captures": { "1": { "name": "keyword.other.directive.feat" } }
73
+ }
74
+ ]
75
+ },
76
+ "scenario": {
77
+ "patterns": [
78
+ {
79
+ "match": "^(scenario)(\\s+outline)?\\s+(\".*\")\\s*:",
80
+ "captures": {
81
+ "1": { "name": "keyword.control.scenario.feat" },
82
+ "2": { "name": "keyword.control.scenario.feat" },
83
+ "3": { "name": "string.quoted.double.scenario-name.feat" }
84
+ }
85
+ },
86
+ {
87
+ "match": "^\\s+(examples)\\s*:",
88
+ "captures": { "1": { "name": "keyword.control.section.feat" } }
89
+ }
90
+ ]
91
+ },
92
+ "trigger": {
93
+ "patterns": [
94
+ {
95
+ "match": "^\\s+(when)\\s*:\\s*([A-Z][A-Za-z0-9]*)",
96
+ "captures": {
97
+ "1": { "name": "keyword.control.trigger.feat" },
98
+ "2": { "name": "entity.name.function.command.feat" }
99
+ }
100
+ },
101
+ {
102
+ "match": "^\\s+(deliver)\\s+([A-Z][A-Za-z0-9]*)\\s.*\\b(to)\\s+(\\w+)",
103
+ "captures": {
104
+ "1": { "name": "keyword.control.trigger.feat" },
105
+ "2": { "name": "entity.name.function.event.feat" },
106
+ "3": { "name": "keyword.control.trigger.feat" },
107
+ "4": { "name": "variable.other.service.feat" }
108
+ }
109
+ },
110
+ {
111
+ "match": "\\b(as)\\s+(\\w+)",
112
+ "captures": {
113
+ "1": { "name": "keyword.other.actor.feat" },
114
+ "2": { "name": "variable.other.actor.feat" }
115
+ }
116
+ }
117
+ ]
118
+ },
119
+ "prediction": {
120
+ "patterns": [
121
+ {
122
+ "match": "^\\s+(predict)\\s+(success|error)\\b(\\s+[A-Z0-9_]+)?",
123
+ "captures": {
124
+ "1": { "name": "keyword.control.predict.feat" },
125
+ "2": { "name": "constant.language.prediction-type.feat" },
126
+ "3": { "name": "constant.other.error-code.feat" }
127
+ }
128
+ },
129
+ {
130
+ "match": "^\\s+(predict)\\s+(rejection)\\s+(<?[A-Za-z0-9_-]+>?)",
131
+ "captures": {
132
+ "1": { "name": "keyword.control.predict.feat" },
133
+ "2": { "name": "constant.language.prediction-type.feat" },
134
+ "3": { "name": "constant.other.rejection-id.feat" }
135
+ }
136
+ },
137
+ {
138
+ "match": "^\\s+(response)\\s+(\\w+)\\s+([A-Z][A-Za-z0-9]*)",
139
+ "captures": {
140
+ "1": { "name": "keyword.other.response.feat" },
141
+ "2": { "name": "constant.numeric.status.feat" },
142
+ "3": { "name": "entity.name.type.schema.feat" }
143
+ }
144
+ },
145
+ {
146
+ "match": "^\\s+(\\w+)\\s+(has|contains)\\s+(ordered|unordered)?",
147
+ "captures": {
148
+ "1": { "name": "variable.other.service.feat" },
149
+ "2": { "name": "keyword.other.assertion.feat" },
150
+ "3": { "name": "keyword.other.ordering.feat" }
151
+ }
152
+ },
153
+ {
154
+ "match": "\\b([A-Z][A-Za-z0-9_]*)\\s+(with)\\s+([A-Z][A-Za-z0-9]*)",
155
+ "captures": {
156
+ "1": { "name": "entity.name.type.record.feat" },
157
+ "2": { "name": "keyword.other.with.feat" },
158
+ "3": { "name": "entity.name.type.schema.feat" }
159
+ }
160
+ }
161
+ ]
162
+ },
163
+ "matchers": {
164
+ "patterns": [
165
+ {
166
+ "match": "\\b(any)\\s+(uuid|timestamp|string|number|boolean)\\b",
167
+ "captures": {
168
+ "1": { "name": "support.function.matcher.feat" },
169
+ "2": { "name": "support.type.matcher.feat" }
170
+ }
171
+ },
172
+ { "match": "\\b(matching|absent)\\b", "name": "support.function.matcher.feat" },
173
+ {
174
+ "match": "\\b(equals fixture)\\b",
175
+ "name": "support.function.matcher.feat"
176
+ }
177
+ ]
178
+ },
179
+ "refs": {
180
+ "patterns": [
181
+ {
182
+ "match": "@(when|deliver)(\\[\\d+\\])?(\\.[A-Za-z0-9_.]+)?",
183
+ "name": "variable.language.stimulus-ref.feat"
184
+ }
185
+ ]
186
+ },
187
+ "placeholders": {
188
+ "patterns": [
189
+ { "match": "\\{\\$[A-Za-z_][A-Za-z0-9_]*\\}", "name": "variable.parameter.placeholder.feat" },
190
+ { "match": "<[A-Za-z_][A-Za-z0-9_-]*>", "name": "variable.parameter.placeholder.feat" }
191
+ ]
192
+ },
193
+ "strings": {
194
+ "match": "\"[^\"]*\"",
195
+ "name": "string.quoted.double.feat"
196
+ },
197
+ "numbers": {
198
+ "match": "\\b\\d+(\\.\\d+)?\\b",
199
+ "name": "constant.numeric.feat"
200
+ }
201
+ }
202
+ }
package/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ /** The raw TextMate grammar object (scopeName: source.feat). */
2
+ export declare const grammar: Record<string, unknown>;
3
+
4
+ /** Shiki-ready LanguageRegistration (name: "feat"). */
5
+ export declare const featLanguage: Record<string, unknown>;
6
+
7
+ export default featLanguage;
package/index.js ADDED
@@ -0,0 +1,23 @@
1
+ // @mmmnt/feat-grammar — the TextMate grammar for .feat, ready for Shiki and any
2
+ // TextMate-compatible highlighter. The JSON file is the artifact; this module
3
+ // wraps it in the shapes the common consumers want.
4
+
5
+ import { readFileSync } from "node:fs";
6
+ import { fileURLToPath } from "node:url";
7
+
8
+ const grammarPath = fileURLToPath(new URL("./feat.tmLanguage.json", import.meta.url));
9
+
10
+ /** The raw TextMate grammar object (scopeName: source.feat). */
11
+ export const grammar = JSON.parse(readFileSync(grammarPath, "utf8"));
12
+
13
+ /**
14
+ * Shiki LanguageRegistration: pass straight to `createHighlighter({ langs: [featLanguage] })`
15
+ * or `highlighter.loadLanguage(featLanguage)`, then highlight with `lang: "feat"`.
16
+ */
17
+ export const featLanguage = {
18
+ ...grammar,
19
+ name: "feat",
20
+ aliases: ["feat"],
21
+ };
22
+
23
+ export default featLanguage;
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@mmmnt/feat-grammar",
3
+ "version": "0.1.6",
4
+ "description": "TextMate grammar for the .feat execution specification language — powers editor extensions, Shiki, and any TextMate-compatible highlighter",
5
+ "type": "module",
6
+ "main": "index.js",
7
+ "types": "index.d.ts",
8
+ "files": [
9
+ "index.js",
10
+ "index.d.ts",
11
+ "feat.tmLanguage.json"
12
+ ],
13
+ "devDependencies": {
14
+ "vitest": "^3.2.0",
15
+ "vscode-oniguruma": "^2.0.1",
16
+ "vscode-textmate": "^9.2.0"
17
+ },
18
+ "engines": {
19
+ "node": ">=20"
20
+ },
21
+ "license": "MIT",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/mmmnt/feature.git",
25
+ "directory": "packages/feat-grammar"
26
+ },
27
+ "homepage": "https://github.com/mmmnt/feature#readme",
28
+ "bugs": {
29
+ "url": "https://github.com/mmmnt/feature/issues"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "scripts": {
35
+ "build": "true",
36
+ "typecheck": "true",
37
+ "test": "vitest run --passWithNoTests"
38
+ }
39
+ }