@abco20/btxml-checker 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ # MIT License
2
+
3
+ Copyright (c) 2026 btxml contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,159 @@
1
+ # btxml-checker
2
+
3
+ BehaviorTree.CPP XML checker and formatter.
4
+
5
+ ## Installation
6
+
7
+ Install in a project:
8
+
9
+ ```bash
10
+ npm install --save-dev @abco20/btxml-checker
11
+ npx btxmlc check "behavior_trees/**/*.xml"
12
+ ```
13
+
14
+ Use once without installing first:
15
+
16
+ ```bash
17
+ npx @abco20/btxml-checker check "behavior_trees/**/*.xml"
18
+ ```
19
+
20
+ ## CLI Usage
21
+
22
+ Commands:
23
+
24
+ - `btxmlc format` rewrites XML into Groot-compatible layout.
25
+ - `btxmlc format --check` only reports whether formatting differs.
26
+ - `btxmlc lint` checks XML syntax and BT rules.
27
+ - `btxmlc lint --fix` applies safe, deterministic lint fixes.
28
+ - `btxmlc check` runs format check and lint together.
29
+ - `btxmlc repair` interactively resolves conflicting node model definitions.
30
+ - `btxmlc init` creates a starter `btxml.config.json`.
31
+ - `btxmlc explain <code>` shows documentation for a rule code.
32
+ - `btxmlc doctor` diagnoses workspace health.
33
+
34
+ By default, `btxmlc format` formats only BehaviorTree.CPP XML files. Generic XML files such as `package.xml` are skipped unless `--force` is specified.
35
+
36
+ Use `lint --fix` for safe automatic fixes:
37
+
38
+ ```bash
39
+ npx btxmlc lint --fix
40
+ ```
41
+
42
+ Use `repair` for node model conflicts that require a choice:
43
+
44
+ ```bash
45
+ npx btxmlc repair
46
+ npx btxmlc repair --write
47
+ ```
48
+
49
+ `btxmlc check` and `btxmlc lint` support `--output human` and `--output json`.
50
+
51
+ ```bash
52
+ npx btxmlc check --output json
53
+ npx btxmlc lint --output json
54
+ ```
55
+
56
+ ## Configuration
57
+
58
+ Place `btxml.config.json` in the root of your project.
59
+
60
+ Minimal config:
61
+
62
+ ```json
63
+ {
64
+ "$schema": "./node_modules/@abco20/btxml-checker/schemas/btxml.config.schema.json"
65
+ }
66
+ ```
67
+
68
+ Common project config:
69
+
70
+ ```json
71
+ {
72
+ "$schema": "./node_modules/@abco20/btxml-checker/schemas/btxml.config.schema.json",
73
+ "files": {
74
+ "include": ["behavior_trees/**/*.xml"]
75
+ },
76
+ "resolver": {
77
+ "entrypoints": ["behavior_trees/main.xml"]
78
+ },
79
+ "models": {
80
+ "files": ["behavior_trees/models/**/*.xml"],
81
+ "definitions": ["behavior_trees/nodes.json"]
82
+ },
83
+ "linter": {
84
+ "rules": {
85
+ "model/no-unknown-port": "error"
86
+ }
87
+ },
88
+ "formatter": {
89
+ "indentWidth": 2,
90
+ "xmlDeclaration": "always",
91
+ "blankLineBetweenBehaviorTrees": true,
92
+ "lineEnding": "lf"
93
+ }
94
+ }
95
+ ```
96
+
97
+ Disable bundled BT.CPP built-in node models if your project provides its own definitions:
98
+
99
+ ```json
100
+ {
101
+ "models": {
102
+ "builtins": []
103
+ }
104
+ }
105
+ ```
106
+
107
+ ## TypeScript API
108
+
109
+ Use the public package exports only:
110
+
111
+ ```ts
112
+ import { checkBtWorkspace, formatBtXml, normalizeBtxmlConfig } from "@abco20/btxml-checker";
113
+ import { createBtEditorService, type BtEditorService } from "@abco20/btxml-checker/editor";
114
+ import { getNodeTypeFromElement, isGenericNodeTag } from "@abco20/btxml-checker/semantic";
115
+
116
+ const { config, ok, diagnostics } = normalizeBtxmlConfig({
117
+ strict: true,
118
+ });
119
+
120
+ if (!ok) {
121
+ throw new Error(diagnostics.map((diag) => diag.message).join("\n"));
122
+ }
123
+
124
+ const result = await checkBtWorkspace(
125
+ {
126
+ inputs: [
127
+ {
128
+ uri: "file:///workspace/behavior_trees/main.xml",
129
+ path: "behavior_trees/main.xml",
130
+ kind: "bt-xml",
131
+ text: `<?xml version="1.0"?>\n<root BTCPP_format="4"><BehaviorTree ID="Main"/></root>`,
132
+ },
133
+ ],
134
+ config,
135
+ },
136
+ );
137
+
138
+ console.log(result.ok, result.summary.errors);
139
+
140
+ const service: BtEditorService = createBtEditorService();
141
+ service.openDocument("memory:///tree.xml", `<root BTCPP_format="4"><BehaviorTree ID="Main"/></root>`);
142
+
143
+ const semantic = service.getSemanticDocumentView("memory:///tree.xml");
144
+ const firstNode = semantic.view?.nodes[0];
145
+ if (firstNode) {
146
+ console.log(getNodeTypeFromElement(firstNode.usage.element));
147
+ console.log(isGenericNodeTag(firstNode.tagName));
148
+ }
149
+
150
+ console.log(formatBtXml(`<root BTCPP_format="4"><BehaviorTree ID="Main"/></root>`));
151
+ ```
152
+
153
+ Avoid importing internal modules or internal-only types such as parser internals, semantic indexes, or project index structures.
154
+
155
+ ## Limitations
156
+
157
+ CDATA, DOCTYPE, non-declaration processing instructions, and unknown XML entities are unsupported in v0.1.
158
+
159
+ See the repository README and docs for the full configuration and rule reference.
@@ -0,0 +1,33 @@
1
+ # Third Party Notices
2
+
3
+ This package includes data derived from BehaviorTree.CPP built-in node model definitions through `@btxml/model`.
4
+
5
+ ## BehaviorTree.CPP
6
+
7
+ Repository: https://github.com/BehaviorTree/BehaviorTree.CPP
8
+
9
+ License: MIT
10
+
11
+ ```text
12
+ MIT License
13
+
14
+ Copyright (c) 2018-2024 Davide Faconti and BehaviorTree.CPP contributors
15
+
16
+ Permission is hereby granted, free of charge, to any person obtaining a copy
17
+ of this software and associated documentation files (the "Software"), to deal
18
+ in the Software without restriction, including without limitation the rights
19
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
+ copies of the Software, and to permit persons to whom the Software is
21
+ furnished to do so, subject to the following conditions:
22
+
23
+ The above copyright notice and this permission notice shall be included in all
24
+ copies or substantial portions of the Software.
25
+
26
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
+ SOFTWARE.
33
+ ```
@@ -0,0 +1,62 @@
1
+ import { S as SourceRange, D as Diagnostic } from './diagnostic-B5htzyJ9.js';
2
+
3
+ type XmlDeclaration = {
4
+ version?: string;
5
+ encoding?: string;
6
+ standalone?: string;
7
+ range: SourceRange;
8
+ attributes?: BtXmlAttribute[];
9
+ };
10
+ type BtXmlText = {
11
+ kind: "text";
12
+ text: string;
13
+ range: SourceRange;
14
+ fullRange?: SourceRange;
15
+ };
16
+ type BtXmlComment = {
17
+ kind: "comment";
18
+ text: string;
19
+ range: SourceRange;
20
+ fullRange?: SourceRange;
21
+ contentRange?: SourceRange;
22
+ };
23
+ type BtXmlAttribute = {
24
+ name: string;
25
+ value: string;
26
+ valueOffsets?: readonly number[];
27
+ range: SourceRange;
28
+ fullRange?: SourceRange;
29
+ nameRange: SourceRange;
30
+ equalsRange?: SourceRange;
31
+ valueRange: SourceRange;
32
+ valueContentRange?: SourceRange;
33
+ };
34
+ type BtXmlElement = {
35
+ kind: "element";
36
+ name: string;
37
+ attributes: BtXmlAttribute[];
38
+ children: BtXmlNode[];
39
+ range: SourceRange;
40
+ fullRange?: SourceRange;
41
+ openTagRange: SourceRange;
42
+ startTagRange?: SourceRange;
43
+ closeTagRange?: SourceRange;
44
+ endTagRange?: SourceRange;
45
+ nameRange?: SourceRange;
46
+ selfClosing: boolean;
47
+ };
48
+ type BtXmlNode = BtXmlElement | BtXmlText | BtXmlComment;
49
+ type BtDocumentKind = "bt-document" | "model-document" | "generic-xml" | "invalid-xml";
50
+ type BtDocument = {
51
+ uri: string;
52
+ path?: string;
53
+ kind: BtDocumentKind;
54
+ isBtXml: boolean;
55
+ xmlDeclaration?: XmlDeclaration;
56
+ root?: BtXmlElement;
57
+ nodes: BtXmlNode[];
58
+ diagnostics: Diagnostic[];
59
+ originalText: string;
60
+ };
61
+
62
+ export type { BtDocument as B, XmlDeclaration as X, BtXmlElement as a, BtXmlAttribute as b, BtXmlNode as c, BtDocumentKind as d, BtXmlComment as e, BtXmlText as f };
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node