vscode-behavior3 2.2.0 → 2.3.3
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/README.md +119 -138
- package/build.d.ts +5 -0
- package/dist/build-cli.js +128 -33
- package/dist/extension.js +410 -66
- package/dist/webview/assets/editor-CTBBjkkm.css +1 -0
- package/dist/webview/assets/editor-DuZsOgps.js +8 -0
- package/dist/webview/assets/{vendor-BuywoAnb.js → vendor-Ctok02TG.js} +23 -23
- package/dist/webview/index.html +3 -3
- package/dist/webview/locales/en.json +5 -0
- package/dist/webview/locales/zh.json +5 -0
- package/package.json +30 -10
- package/package.nls.json +4 -2
- package/package.nls.zh-cn.json +4 -2
- package/webview/shared/b3build-model.d.ts +22 -2
- package/dist/webview/assets/editor-BxvY-Wyu.css +0 -1
- package/dist/webview/assets/editor-DaW6jFnb.js +0 -7
package/README.md
CHANGED
|
@@ -1,212 +1,185 @@
|
|
|
1
1
|
# Behavior3 Editor
|
|
2
2
|
|
|
3
|
-
VS Code behavior
|
|
3
|
+
VS Code custom editor for Behavior3 JSON behavior trees. It combines a visual graph canvas, an Inspector, project scaffolding, and build/check/batch scripting for game AI workflows.
|
|
4
4
|
|
|
5
5
|
## Related Projects
|
|
6
6
|
|
|
7
|
-
- **[behavior3-ts](https://github.com/codetypess/behavior3-ts)** - TypeScript
|
|
8
|
-
- **[behavior3lua](https://github.com/zhandouxiaojiji/behavior3lua)** - Lua
|
|
7
|
+
- **[behavior3-ts](https://github.com/codetypess/behavior3-ts)** - TypeScript runtime library
|
|
8
|
+
- **[behavior3lua](https://github.com/zhandouxiaojiji/behavior3lua)** - Lua runtime
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Preview
|
|
11
11
|
|
|
12
12
|

|
|
13
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
14
|
## Features
|
|
17
15
|
|
|
18
|
-
- Visual
|
|
19
|
-
-
|
|
16
|
+
- Visual graph editor for Behavior3 trees and reachable subtrees
|
|
17
|
+
- Inspector in `sidebar` or `embedded` mode
|
|
18
|
+
- Explorer `Behavior3` submenu for project, tree, and script scaffolding
|
|
19
|
+
- Build, debug build, checker scripts, and project batch processing
|
|
20
20
|
- Custom node definitions via `.b3-setting`
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
- Auto theme adaptation (dark/light)
|
|
21
|
+
- Expression and node-argument validation
|
|
22
|
+
- Theme-aware UI for dark and light VS Code themes
|
|
24
23
|
|
|
25
24
|
## Quick Start
|
|
26
25
|
|
|
27
|
-
### Open a tree
|
|
26
|
+
### Open a tree
|
|
27
|
+
|
|
28
|
+
- Right-click a Behavior3 `.json` file in Explorer
|
|
29
|
+
- Select **Open With** -> **Behavior3 Editor**
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
- Select **Open With** → **Behavior3 Editor**
|
|
31
|
+
### Create project files
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
From a folder's Explorer `Behavior3` submenu you can run:
|
|
33
34
|
|
|
34
|
-
-
|
|
35
|
-
-
|
|
35
|
+
- **Create Project**
|
|
36
|
+
- **Create Behavior Tree File**
|
|
37
|
+
- **Create Build Script**
|
|
38
|
+
- **Create Batch Script**
|
|
39
|
+
- **Create Checker Script**
|
|
40
|
+
- **Run Script as Batch Process**
|
|
36
41
|
|
|
37
|
-
|
|
42
|
+
`Run Script as Batch Process` is also available on `.ts`, `.mts`, `.js`, and `.mjs` files. Running it from a folder lets you choose a script first; running it from a script file runs that script directly.
|
|
38
43
|
|
|
39
|
-
|
|
44
|
+
### Configure node definitions
|
|
45
|
+
|
|
46
|
+
Create a `.b3-setting` file in the workspace:
|
|
40
47
|
|
|
41
48
|
```json
|
|
42
49
|
[
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
{
|
|
51
|
+
"name": "MyAction",
|
|
52
|
+
"type": "Action",
|
|
53
|
+
"desc": "Does something useful",
|
|
54
|
+
"args": [{ "name": "duration", "type": "float", "desc": "Duration in seconds" }]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"name": "CheckScore",
|
|
58
|
+
"type": "Condition",
|
|
59
|
+
"desc": "Checks whether the score matches the rule",
|
|
60
|
+
"args": [{ "name": "value", "type": "expr", "desc": "Expression" }]
|
|
61
|
+
}
|
|
55
62
|
]
|
|
56
63
|
```
|
|
57
64
|
|
|
58
|
-
###
|
|
59
|
-
|
|
60
|
-
Click **Build** in the editor title bar.
|
|
65
|
+
### Configure workspace behavior
|
|
61
66
|
|
|
62
|
-
|
|
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
|
-
```
|
|
67
|
+
Use a `.b3-workspace` file to register build and checker scripts:
|
|
69
68
|
|
|
70
69
|
```json
|
|
71
70
|
{
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
"settings": {
|
|
72
|
+
"checkExpr": true,
|
|
73
|
+
"buildScript": "scripts/build.ts",
|
|
74
|
+
"checkScripts": ["scripts/checkers/**/*.ts"]
|
|
75
|
+
}
|
|
75
76
|
}
|
|
76
77
|
```
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
npm exec -- behavior3-build --project ./workdir/hero.json --output ./dist/behavior3
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
Or run it without installing first:
|
|
79
|
+
`buildScript` and `checkScripts` are resolved relative to the `.b3-workspace` file. See [sample/workspace.b3-workspace](sample/workspace.b3-workspace) for a complete sample.
|
|
85
80
|
|
|
86
|
-
|
|
87
|
-
npx --package vscode-behavior3 behavior3-build --project ./workdir/hero.json --output ./dist/behavior3
|
|
88
|
-
```
|
|
81
|
+
## Inspector Modes
|
|
89
82
|
|
|
90
|
-
|
|
83
|
+
Set `behavior3.inspectorMode` to choose the active Inspector presentation:
|
|
91
84
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
npm whoami
|
|
95
|
-
npm version patch
|
|
96
|
-
npm run pack:npm
|
|
97
|
-
npm run publish:npm
|
|
98
|
-
```
|
|
85
|
+
- `sidebar`: show the Inspector in the dedicated Behavior3 side view
|
|
86
|
+
- `embedded`: show the Inspector inside the main editor webview
|
|
99
87
|
|
|
100
|
-
|
|
101
|
-
tarball contents without publishing.
|
|
88
|
+
Both modes share the same document semantics and commands. Only the presentation changes.
|
|
102
89
|
|
|
103
|
-
|
|
90
|
+
## Build, Batch, and Check Scripts
|
|
104
91
|
|
|
105
|
-
|
|
92
|
+
Behavior3 supports ESM JavaScript and TypeScript scripts:
|
|
106
93
|
|
|
107
94
|
- JavaScript: `.js`, `.mjs`
|
|
108
95
|
- TypeScript: `.ts`, `.mts` (runtime transpile, no type-check)
|
|
109
96
|
|
|
110
|
-
|
|
111
|
-
|
|
97
|
+
When importing local TypeScript helpers, use explicit extensions such as `./helper.ts`.
|
|
98
|
+
The `behavior3` decorator namespace is provided by the runtime, so script files only need type imports from `vscode-behavior3/build`.
|
|
112
99
|
|
|
113
|
-
|
|
114
|
-
import { helper } from "./helper.ts";
|
|
115
|
-
```
|
|
100
|
+
All script types can import authoring types from `vscode-behavior3/build`. Example scripts are available in:
|
|
116
101
|
|
|
117
|
-
|
|
118
|
-
|
|
102
|
+
- [sample/scripts/build.ts](sample/scripts/build.ts)
|
|
103
|
+
- [sample/scripts/batch.ts](sample/scripts/batch.ts)
|
|
104
|
+
- [sample/scripts/checkers/positive.ts](sample/scripts/checkers/positive.ts)
|
|
119
105
|
|
|
120
|
-
|
|
121
|
-
BEHAVIOR3_BUILD_DEBUG=1 node --inspect-brk dist/build-cli.js --output /tmp/b3build --project sample/workdir/hero.json
|
|
122
|
-
```
|
|
106
|
+
### Build Scripts
|
|
123
107
|
|
|
124
|
-
|
|
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.
|
|
108
|
+
Build scripts are declared with `@behavior3.build` and can transform build output without rewriting source trees.
|
|
132
109
|
|
|
133
|
-
|
|
110
|
+
```ts
|
|
111
|
+
import type { BuildEnv, BuildScript } from "vscode-behavior3/build";
|
|
134
112
|
|
|
135
|
-
|
|
136
|
-
{
|
|
137
|
-
|
|
138
|
-
"checkExpr": true,
|
|
139
|
-
"buildScript": "scripts/build.ts",
|
|
140
|
-
"checkScripts": ["scripts/checkers/**/*.ts"]
|
|
141
|
-
}
|
|
113
|
+
@behavior3.build
|
|
114
|
+
export class ProjectBuild implements BuildScript {
|
|
115
|
+
constructor(private readonly env: BuildEnv) {}
|
|
142
116
|
}
|
|
143
117
|
```
|
|
144
118
|
|
|
145
|
-
|
|
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.
|
|
119
|
+
Supported hooks:
|
|
150
120
|
|
|
151
|
-
|
|
121
|
+
- `onProcessTree(tree, path, errors)`
|
|
122
|
+
- `onProcessNode(node, errors)`
|
|
123
|
+
- `onWriteFile(path, tree)`
|
|
124
|
+
- `onComplete(status)`
|
|
125
|
+
|
|
126
|
+
### Batch Scripts
|
|
152
127
|
|
|
153
|
-
|
|
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`
|
|
128
|
+
Batch scripts are declared with `@behavior3.batch` and are used by **Run Script as Batch Process** to rewrite source trees in place across the current project.
|
|
158
129
|
|
|
159
|
-
|
|
160
|
-
runtime, so no value import is required. The extension constructs the class once
|
|
161
|
-
with `env`, then calls methods:
|
|
130
|
+
Supported hooks:
|
|
162
131
|
|
|
163
|
-
- `constructor(env)`
|
|
164
132
|
- `shouldUpgradeTree(path, tree)`
|
|
165
133
|
- `onProcessTree(tree, path, errors)`
|
|
166
134
|
- `onProcessNode(node, errors)`
|
|
167
135
|
- `onWriteFile(path, tree)`
|
|
168
136
|
- `onComplete(status)`
|
|
169
137
|
|
|
170
|
-
|
|
171
|
-
import type { BuildEnv, TreeData } from "vscode-behavior3/build";
|
|
138
|
+
### Checker Scripts
|
|
172
139
|
|
|
173
|
-
|
|
174
|
-
export class ProjectBuild {
|
|
175
|
-
constructor(private readonly env: BuildEnv) {}
|
|
140
|
+
Checker scripts register custom argument validators with `@behavior3.check("name")`. They are used by both Inspector validation and project builds.
|
|
176
141
|
|
|
177
|
-
|
|
178
|
-
this.env.logger.info("building", tree.name);
|
|
179
|
-
return tree;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
```
|
|
142
|
+
For compatibility, supported script files may still export classes through named `Hook`, `BuildHook`, `BatchHook`, or `default`, but the decorator-based forms above are the canonical APIs.
|
|
183
143
|
|
|
184
|
-
|
|
185
|
-
`Hook` or `default`.
|
|
144
|
+
## Build and Debug
|
|
186
145
|
|
|
187
|
-
|
|
188
|
-
|
|
146
|
+
- Click **Build** in the editor title bar, or press `Ctrl/Cmd+B`
|
|
147
|
+
- Press `Ctrl/Cmd+Shift+B` to start a debug build session
|
|
189
148
|
|
|
190
|
-
|
|
149
|
+
The npm package also exposes a `behavior3-build` command for CI and project scripts:
|
|
191
150
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
151
|
+
```bash
|
|
152
|
+
npm install -D vscode-behavior3
|
|
153
|
+
```
|
|
195
154
|
|
|
196
|
-
|
|
155
|
+
```json
|
|
156
|
+
{
|
|
157
|
+
"scripts": {
|
|
158
|
+
"build:behavior": "behavior3-build --project ./workdir/hero.json --output ./dist/behavior3"
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
```
|
|
197
162
|
|
|
198
|
-
|
|
199
|
-
| --------------------- | ------- | -------- | ---------------------------------------------------------------- |
|
|
200
|
-
| `behavior3.checkExpr` | boolean | `true` | Enable expression syntax validation for expression-type args. |
|
|
201
|
-
| `behavior3.language` | string | `"auto"` | Editor UI language. Options:`auto` (follow VS Code), `zh`, `en`. |
|
|
163
|
+
You can also run it directly:
|
|
202
164
|
|
|
203
|
-
|
|
165
|
+
```bash
|
|
166
|
+
npm exec -- behavior3-build --project ./workdir/hero.json --output ./dist/behavior3
|
|
167
|
+
```
|
|
204
168
|
|
|
205
|
-
|
|
169
|
+
Or without installing first:
|
|
206
170
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
171
|
+
```bash
|
|
172
|
+
npx --package vscode-behavior3 behavior3-build --project ./workdir/hero.json --output ./dist/behavior3
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Extension Settings
|
|
176
|
+
|
|
177
|
+
| Setting | Type | Default | Description |
|
|
178
|
+
| --------------------------- | --------- | ----------- | ------------------------------------------------------------------------ |
|
|
179
|
+
| `behavior3.checkExpr` | `boolean` | `true` | Enable expression validation for expression-type args. |
|
|
180
|
+
| `behavior3.language` | `string` | `"auto"` | UI language: `auto`, `zh`, or `en`. |
|
|
181
|
+
| `behavior3.subtreeEditable` | `boolean` | `true` | Allow editing supported subtree content from the current editor context. |
|
|
182
|
+
| `behavior3.inspectorMode` | `string` | `"sidebar"` | Choose whether the Inspector is shown in `sidebar` or `embedded` mode. |
|
|
210
183
|
|
|
211
184
|
## Keyboard Shortcuts
|
|
212
185
|
|
|
@@ -224,14 +197,22 @@ Inspector is available in the dedicated `behavior3` sidebar and supports direct
|
|
|
224
197
|
| `Ctrl/Cmd+B` | Build |
|
|
225
198
|
| `F4` | Toggle Text / Behavior3 editor |
|
|
226
199
|
|
|
200
|
+
## Docs
|
|
201
|
+
|
|
202
|
+
- [docs/README.md](docs/README.md) - documentation entry point
|
|
203
|
+
- [docs/spec-driven-development.md](docs/spec-driven-development.md) - SDD workflow
|
|
204
|
+
- [docs/spec/README.md](docs/spec/README.md) - baseline spec map and work-item index
|
|
205
|
+
- [sample/](sample) - sample workspace, trees, and scripts
|
|
206
|
+
|
|
227
207
|
## Development
|
|
228
208
|
|
|
229
|
-
- Output logs: **View
|
|
209
|
+
- Output logs: **View -> Output** -> **Behavior3**
|
|
230
210
|
- Webview logs are also available in DevTools
|
|
231
211
|
|
|
232
212
|
## Requirements
|
|
233
213
|
|
|
234
|
-
- VS Code 1.
|
|
214
|
+
- VS Code `^1.105.0`
|
|
215
|
+
- Node `>=20.19` for the CLI and TypeScript script runtime
|
|
235
216
|
|
|
236
217
|
## License
|
|
237
218
|
|
package/build.d.ts
CHANGED
|
@@ -2,9 +2,14 @@ import type { BuildRuntime } from "./webview/shared/b3build-model";
|
|
|
2
2
|
export type { NodeDef } from "behavior3";
|
|
3
3
|
export type { NodeData, TreeData } from "./webview/shared/b3type";
|
|
4
4
|
export type {
|
|
5
|
+
BatchDecorator,
|
|
6
|
+
BatchHook,
|
|
7
|
+
BatchHookClass,
|
|
8
|
+
BatchScript,
|
|
5
9
|
BuildEnv,
|
|
6
10
|
CheckDecorator,
|
|
7
11
|
BuildDecorator,
|
|
12
|
+
BuildHook,
|
|
8
13
|
BuildHookClass,
|
|
9
14
|
BuildLogger,
|
|
10
15
|
BuildRuntime,
|