vscode-behavior3 2.1.1
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 +21 -0
- package/README.md +237 -0
- package/build.d.ts +24 -0
- package/dist/build-cli.js +220367 -0
- package/dist/extension.js +225724 -0
- package/dist/webview/assets/editor-Ko79XsIi.css +1 -0
- package/dist/webview/assets/editor-RJ_NkY97.js +534 -0
- package/dist/webview/assets/worker-B9qc9nkC.js +13 -0
- package/dist/webview/codicons/LICENSE +399 -0
- package/dist/webview/codicons/LICENSE-CODE +21 -0
- package/dist/webview/codicons/codicon.css +712 -0
- package/dist/webview/codicons/codicon.ttf +0 -0
- package/dist/webview/icons/Action.svg +1 -0
- package/dist/webview/icons/Composite.svg +1 -0
- package/dist/webview/icons/Condition.svg +1 -0
- package/dist/webview/icons/Debug.svg +1 -0
- package/dist/webview/icons/Decorator.svg +1 -0
- package/dist/webview/icons/Disabled.svg +1 -0
- package/dist/webview/icons/Error.svg +1 -0
- package/dist/webview/icons/Other.svg +1 -0
- package/dist/webview/icons/icon.svg +1 -0
- package/dist/webview/icons/status000.svg +40 -0
- package/dist/webview/icons/status001.svg +50 -0
- package/dist/webview/icons/status010.svg +50 -0
- package/dist/webview/icons/status011.svg +60 -0
- package/dist/webview/icons/status100.svg +50 -0
- package/dist/webview/icons/status101.svg +60 -0
- package/dist/webview/icons/status110.svg +60 -0
- package/dist/webview/icons/status111.svg +70 -0
- package/dist/webview/images/pic.png +0 -0
- package/dist/webview/index.html +14 -0
- package/dist/webview/locales/en.json +212 -0
- package/dist/webview/locales/zh.json +211 -0
- package/icon.png +0 -0
- package/media/icons/icon.svg +1 -0
- package/package.json +313 -0
- package/package.nls.json +28 -0
- package/package.nls.zh-cn.json +28 -0
- package/webview/shared/b3build-model.d.ts +98 -0
- package/webview/shared/b3type.ts +112 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 codetypess
|
|
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,237 @@
|
|
|
1
|
+
# Behavior3 Editor
|
|
2
|
+
|
|
3
|
+
VS Code behavior tree visual editor for game AI workflows.
|
|
4
|
+
|
|
5
|
+
## Related Projects
|
|
6
|
+
|
|
7
|
+
- **[behavior3-ts](https://github.com/codetypess/behavior3-ts)** - TypeScript Runtime Library
|
|
8
|
+
- **[behavior3lua](https://github.com/zhandouxiaojiji/behavior3lua)** - Lua Runtime
|
|
9
|
+
|
|
10
|
+
## Editor Preview
|
|
11
|
+
|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
The editor provides an intuitive visual interface for designing and managing behavior trees. See the screenshot above for the full editing experience with node canvas, inspector panel, and tree organization.
|
|
15
|
+
|
|
16
|
+
## Features
|
|
17
|
+
|
|
18
|
+
- Visual canvas editor (drag, connect, organize nodes)
|
|
19
|
+
- Built-in inspector panel for node/tree properties
|
|
20
|
+
- Custom node definitions via `.b3-setting`
|
|
21
|
+
- One-click build command in editor title bar
|
|
22
|
+
- Optional expression validation for node args
|
|
23
|
+
- Auto theme adaptation (dark/light)
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
### Open a tree file
|
|
28
|
+
|
|
29
|
+
- Right-click a tree `.json` file in Explorer
|
|
30
|
+
- Select **Open With** → **Behavior3 Editor**
|
|
31
|
+
|
|
32
|
+
### Create a new project
|
|
33
|
+
|
|
34
|
+
- Right-click a folder in Explorer
|
|
35
|
+
- Run **Behavior Tree: Create Project**
|
|
36
|
+
|
|
37
|
+
### Configure nodes
|
|
38
|
+
|
|
39
|
+
Create a `.b3-setting` file in workspace:
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
[
|
|
43
|
+
{
|
|
44
|
+
"name": "MyAction",
|
|
45
|
+
"type": "Action",
|
|
46
|
+
"desc": "Does something useful",
|
|
47
|
+
"args": [{ "name": "duration", "type": "float", "desc": "Duration in seconds" }]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": "CheckScore",
|
|
51
|
+
"type": "Condition",
|
|
52
|
+
"desc": "Checks whether the score matches the rule",
|
|
53
|
+
"args": [{ "name": "value", "type": "expr", "desc": "Expression" }]
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Build
|
|
59
|
+
|
|
60
|
+
Click **Build** in the editor title bar.
|
|
61
|
+
|
|
62
|
+
### Command Line Build
|
|
63
|
+
|
|
64
|
+
The npm package exposes a `behavior3-build` command for CI and project scripts:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npm install -D vscode-behavior3
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"scripts": {
|
|
73
|
+
"build:behavior": "behavior3-build --project ./workdir/hero.json --output ./dist/behavior3"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
You can also run it without adding a script:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npm exec -- behavior3-build --project ./workdir/hero.json --output ./dist/behavior3
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Or run it without installing first:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npx --package vscode-behavior3 behavior3-build --project ./workdir/hero.json --output ./dist/behavior3
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Publishing flow:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
npm login
|
|
94
|
+
npm whoami
|
|
95
|
+
npm version patch
|
|
96
|
+
npm run pack:npm
|
|
97
|
+
npm run publish:npm
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
`npm run pack:npm` performs the same prepack checks as publishing and prints the
|
|
101
|
+
tarball contents without publishing.
|
|
102
|
+
|
|
103
|
+
### Build Script (`.b3-workspace`)
|
|
104
|
+
|
|
105
|
+
`settings.buildScript` supports ESM scripts:
|
|
106
|
+
|
|
107
|
+
- JavaScript: `.js`, `.mjs`
|
|
108
|
+
- TypeScript: `.ts`, `.mts` (runtime transpile, no type-check)
|
|
109
|
+
|
|
110
|
+
TypeScript build scripts can import other local TypeScript files with explicit
|
|
111
|
+
extensions:
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
import { helper } from "./helper.ts";
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
To debug TypeScript build scripts, launch the CLI with Node inspector and enable
|
|
118
|
+
build-script debug mode:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
BEHAVIOR3_BUILD_DEBUG=1 node --inspect-brk dist/build-cli.js --output /tmp/b3build --project sample/workdir/hero.json
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
This emits inline source maps and creates temporary `.runtime.*.mjs` files next
|
|
125
|
+
to the build script while the build runs so breakpoints in `build.ts` and
|
|
126
|
+
imported helper files can bind. The runtime files are removed after the build
|
|
127
|
+
completes; if the build script fails to load, they are left in place for
|
|
128
|
+
inspection. Editor debug builds also clean runtime files when the debug session
|
|
129
|
+
terminates.
|
|
130
|
+
Inside the editor, `Ctrl+B`/`Cmd+B` builds normally, while
|
|
131
|
+
`Ctrl+Shift+B`/`Cmd+Shift+B` starts a VS Code Node debug session for the build.
|
|
132
|
+
|
|
133
|
+
Example:
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"settings": {
|
|
138
|
+
"checkExpr": true,
|
|
139
|
+
"buildScript": "scripts/build.ts",
|
|
140
|
+
"checkScripts": ["scripts/checkers/**/*.ts"]
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`settings.checkScripts` is optional and loads additional checker-only scripts
|
|
146
|
+
relative to the `.b3-workspace` directory. Matching scripts are scanned for
|
|
147
|
+
exported `@behavior3.check("name")` classes and are used by both the editor
|
|
148
|
+
Inspector validation and project builds. Generated `.runtime.*.mjs`, `.d.ts`,
|
|
149
|
+
`node_modules`, `dist`, and `build` paths are ignored.
|
|
150
|
+
|
|
151
|
+
All build hooks receive `env`:
|
|
152
|
+
|
|
153
|
+
- `env.fs`: Node `fs`
|
|
154
|
+
- `env.path`: full path helper object (all methods exposed)
|
|
155
|
+
- `env.workdir`: resolved workspace directory
|
|
156
|
+
- `env.nodeDefs`: loaded node definitions map
|
|
157
|
+
- `env.logger`: `log/debug/info/warn/error`
|
|
158
|
+
|
|
159
|
+
Use an exported `@behavior3.build` class. The decorator is provided by the build
|
|
160
|
+
runtime, so no value import is required. The extension constructs the class once
|
|
161
|
+
with `env`, then calls methods:
|
|
162
|
+
|
|
163
|
+
- `constructor(env)`
|
|
164
|
+
- `onProcessTree(tree, path, errors)`
|
|
165
|
+
- `onProcessNode(node, errors)`
|
|
166
|
+
- `onWriteFile(path, tree)`
|
|
167
|
+
- `onComplete(status)`
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
import type { BuildEnv, TreeData } from "vscode-behavior3/build";
|
|
171
|
+
|
|
172
|
+
@behavior3.build
|
|
173
|
+
export class ProjectBuild {
|
|
174
|
+
constructor(private readonly env: BuildEnv) {}
|
|
175
|
+
|
|
176
|
+
onProcessTree(tree: TreeData) {
|
|
177
|
+
this.env.logger.info("building", tree.name);
|
|
178
|
+
return tree;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
For compatibility, supported script files may still export a class via named
|
|
184
|
+
`Hook` or `default`.
|
|
185
|
+
|
|
186
|
+
For TypeScript authoring hints, import build script types from
|
|
187
|
+
`vscode-behavior3/build`. See `sample/scripts/build.ts` for a complete example.
|
|
188
|
+
|
|
189
|
+
### Project Batch Processing
|
|
190
|
+
|
|
191
|
+
Use `Batch Process Behavior Trees` to pick a script on demand and apply it to
|
|
192
|
+
every behavior tree source file in the current project. The script can be
|
|
193
|
+
TypeScript with local `import` statements, just like build scripts.
|
|
194
|
+
|
|
195
|
+
## Extension Settings
|
|
196
|
+
|
|
197
|
+
| Setting | Type | Default | Description |
|
|
198
|
+
| --------------------- | ------- | -------- | ---------------------------------------------------------------- |
|
|
199
|
+
| `behavior3.checkExpr` | boolean | `true` | Enable expression syntax validation for expression-type args. |
|
|
200
|
+
| `behavior3.language` | string | `"auto"` | Editor UI language. Options:`auto` (follow VS Code), `zh`, `en`. |
|
|
201
|
+
|
|
202
|
+
## Inspector
|
|
203
|
+
|
|
204
|
+
Inspector is available in the dedicated `behavior3` sidebar and supports direct editing.
|
|
205
|
+
|
|
206
|
+
- Select a node to edit node fields (`args`, `input`, `output`, `desc`, `debug`, `disabled`)
|
|
207
|
+
- Click empty canvas to edit tree fields (`name`, `desc`, `vars`, `import`, `group`)
|
|
208
|
+
- Opening a Behavior3 tree or changing the graph selection will automatically reveal the matching Inspector context
|
|
209
|
+
|
|
210
|
+
## Keyboard Shortcuts
|
|
211
|
+
|
|
212
|
+
| Key | Action |
|
|
213
|
+
| ------------------------ | ------------------------------ |
|
|
214
|
+
| `Ctrl/Cmd+Z` | Undo |
|
|
215
|
+
| `Ctrl+Y` / `Cmd+Shift+Z` | Redo |
|
|
216
|
+
| `Ctrl/Cmd+C` | Copy node |
|
|
217
|
+
| `Ctrl/Cmd+V` | Paste node |
|
|
218
|
+
| `Ctrl/Cmd+Shift+V` | Replace node |
|
|
219
|
+
| `Enter` / `Insert` | Insert node |
|
|
220
|
+
| `Delete` / `Backspace` | Delete selected node |
|
|
221
|
+
| `Ctrl/Cmd+F` | Search node content |
|
|
222
|
+
| `Ctrl/Cmd+G` | Jump to node by id |
|
|
223
|
+
| `Ctrl/Cmd+B` | Build |
|
|
224
|
+
| `F4` | Toggle Text / Behavior3 editor |
|
|
225
|
+
|
|
226
|
+
## Development
|
|
227
|
+
|
|
228
|
+
- Output logs: **View → Output** → channel **Behavior3**
|
|
229
|
+
- Webview logs are also available in DevTools
|
|
230
|
+
|
|
231
|
+
## Requirements
|
|
232
|
+
|
|
233
|
+
- VS Code 1.85.0+
|
|
234
|
+
|
|
235
|
+
## License
|
|
236
|
+
|
|
237
|
+
MIT
|
package/build.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { BuildRuntime } from "./webview/shared/b3build-model";
|
|
2
|
+
export type { NodeDef } from "behavior3";
|
|
3
|
+
export type { NodeData, TreeData } from "./webview/shared/b3type";
|
|
4
|
+
export type {
|
|
5
|
+
BuildEnv,
|
|
6
|
+
CheckDecorator,
|
|
7
|
+
BuildDecorator,
|
|
8
|
+
BuildHookClass,
|
|
9
|
+
BuildLogger,
|
|
10
|
+
BuildRuntime,
|
|
11
|
+
BuildScript,
|
|
12
|
+
FsLike,
|
|
13
|
+
Hook,
|
|
14
|
+
NodeArg,
|
|
15
|
+
NodeArgCheckContext,
|
|
16
|
+
NodeArgChecker,
|
|
17
|
+
NodeArgCheckerClass,
|
|
18
|
+
NodeArgCheckResult,
|
|
19
|
+
PathLike,
|
|
20
|
+
} from "./webview/shared/b3build-model";
|
|
21
|
+
|
|
22
|
+
declare global {
|
|
23
|
+
const behavior3: BuildRuntime;
|
|
24
|
+
}
|