gdharness 0.12.16 → 0.12.18
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/build/cli.js +11 -2
- package/build/godot/addons/auto_reload/auto_reload.gd +9 -2
- package/build/godot/addons/gdharness_editor/bridge_client.gd +11 -5
- package/build/godot/addons/gdharness_editor/plugin.gd +17 -4
- package/build/godot/addons/gdharness_editor/reading.gd +64 -0
- package/build/godot/addons/gdharness_editor/reading.gd.uid +1 -0
- package/build/godot/addons/gdharness_editor/tools/animation_tools.gd +30 -12
- package/build/godot/addons/gdharness_editor/tools/class_tools.gd +5 -2
- package/build/godot/addons/gdharness_editor/tools/play_tools.gd +3 -1
- package/build/godot/addons/gdharness_editor/tools/resource_tools.gd +50 -27
- package/build/godot/addons/gdharness_editor/tools/scene_tools.gd +92 -42
- package/build/godot/addons/gdharness_runtime/reading.gd +64 -0
- package/build/godot/addons/gdharness_runtime/reading.gd.uid +1 -0
- package/build/godot/addons/gdharness_runtime/runtime_autoload.gd +24 -10
- package/build/godot/addons/gdharness_runtime/runtime_capture.gd +7 -5
- package/build/godot/addons/gdharness_runtime/runtime_input.gd +24 -22
- package/build/godot/addons/gdharness_runtime/runtime_queries.gd +16 -13
- package/build/godot/addons/gdharness_runtime/runtime_values.gd +24 -8
- package/build/godot/addons/gdharness_runtime/runtime_waits.gd +7 -4
- package/build/godot/operations/audio_buses.gd +7 -6
- package/build/godot/operations/class_cache.gd +14 -9
- package/build/godot/operations/classdb_queries.gd +4 -3
- package/build/godot/operations/dependencies.gd +19 -16
- package/build/godot/operations/file_walk.gd +4 -2
- package/build/godot/operations/gdscript_analysis.gd +2 -3
- package/build/godot/operations/gdscript_authoring.gd +20 -8
- package/build/godot/operations/godot_operations.gd +7 -2
- package/build/godot/operations/import_pipeline.gd +5 -4
- package/build/godot/operations/input_actions.gd +13 -9
- package/build/godot/operations/patterns.gd +22 -0
- package/build/godot/operations/plugins.gd +10 -6
- package/build/godot/operations/project_config.gd +3 -2
- package/build/godot/operations/reading.gd +66 -0
- package/build/godot/operations/serialisation.gd +41 -9
- package/build/index.js +8 -1
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
extends RefCounted
|
|
2
2
|
|
|
3
|
+
const Read = preload("reading.gd")
|
|
3
4
|
const Log = preload("logger.gd")
|
|
4
5
|
|
|
5
6
|
# The key names a caller may write, and what the engine calls them.
|
|
@@ -106,7 +107,7 @@ func _init(p_log: Log) -> void:
|
|
|
106
107
|
func add_input_action(params: Dictionary) -> Dictionary:
|
|
107
108
|
var action_name: String = str(params.get("action_name", ""))
|
|
108
109
|
var events: Array = params.get("events", [])
|
|
109
|
-
var deadzone: float =
|
|
110
|
+
var deadzone: float = Read.as_float(params.get("deadzone", 0.5), 0.5)
|
|
110
111
|
|
|
111
112
|
_log.info("Adding input action: " + action_name)
|
|
112
113
|
_log.debug("Events: " + JSON.stringify(events))
|
|
@@ -200,26 +201,29 @@ func build_input_action(deadzone: float, events: Array) -> Dictionary:
|
|
|
200
201
|
match evt_class:
|
|
201
202
|
"InputEventKey":
|
|
202
203
|
var key: InputEventKey = InputEventKey.new()
|
|
203
|
-
key.keycode =
|
|
204
|
-
key.ctrl_pressed =
|
|
205
|
-
key.alt_pressed =
|
|
206
|
-
key.shift_pressed =
|
|
204
|
+
key.keycode = Read.as_int(event.get("keycode", 0)) as Key
|
|
205
|
+
key.ctrl_pressed = Read.as_bool(event.get("ctrl_pressed", false))
|
|
206
|
+
key.alt_pressed = Read.as_bool(event.get("alt_pressed", false))
|
|
207
|
+
key.shift_pressed = Read.as_bool(event.get("shift_pressed", false))
|
|
207
208
|
built.append(key)
|
|
208
209
|
|
|
209
210
|
"InputEventMouseButton":
|
|
210
211
|
var mouse: InputEventMouseButton = InputEventMouseButton.new()
|
|
211
|
-
mouse.button_index = (
|
|
212
|
+
mouse.button_index = (
|
|
213
|
+
Read.as_int(event.get("button_index", MOUSE_BUTTON_LEFT), MOUSE_BUTTON_LEFT)
|
|
214
|
+
as MouseButton
|
|
215
|
+
)
|
|
212
216
|
built.append(mouse)
|
|
213
217
|
|
|
214
218
|
"InputEventJoypadButton":
|
|
215
219
|
var pad: InputEventJoypadButton = InputEventJoypadButton.new()
|
|
216
|
-
pad.button_index =
|
|
220
|
+
pad.button_index = Read.as_int(event.get("button_index", 0)) as JoyButton
|
|
217
221
|
built.append(pad)
|
|
218
222
|
|
|
219
223
|
"InputEventJoypadMotion":
|
|
220
224
|
var motion: InputEventJoypadMotion = InputEventJoypadMotion.new()
|
|
221
|
-
motion.axis =
|
|
222
|
-
motion.axis_value =
|
|
225
|
+
motion.axis = Read.as_int(event.get("axis", 0)) as JoyAxis
|
|
226
|
+
motion.axis_value = Read.as_float(event.get("axis_value", 1.0), 1.0)
|
|
223
227
|
built.append(motion)
|
|
224
228
|
|
|
225
229
|
_:
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
extends RefCounted
|
|
2
|
+
|
|
3
|
+
# A compiled regular expression, with a pattern that will not compile said rather than dropped.
|
|
4
|
+
#
|
|
5
|
+
# `RegEx.compile()` answers with an Error, and every caller here passes a literal its author had
|
|
6
|
+
# already checked by eye, so the answer was thrown away eleven times. A project holding
|
|
7
|
+
# `return_value_discarded` at error level will not compile a script that does that, and these
|
|
8
|
+
# scripts are compiled under the target project's warning levels rather than under this package's:
|
|
9
|
+
# one project turning that warning on loses every headless operation at once.
|
|
10
|
+
#
|
|
11
|
+
# A pattern that fails here is a mistake in this repository rather than anything a caller did, so
|
|
12
|
+
# it goes to the engine's error stream, where the operation's answer carries it back under
|
|
13
|
+
# `engine_messages`. The empty RegEx it then returns matches nothing, which is the honest result of
|
|
14
|
+
# a pattern that does not exist.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
static func compiled(expression: String) -> RegEx:
|
|
18
|
+
var regex: RegEx = RegEx.new()
|
|
19
|
+
var built: Error = regex.compile(expression)
|
|
20
|
+
if built != OK:
|
|
21
|
+
push_error("gdharness: could not compile the pattern " + expression)
|
|
22
|
+
return regex
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
extends RefCounted
|
|
2
2
|
|
|
3
|
+
const Patterns = preload("patterns.gd")
|
|
3
4
|
const Log = preload("logger.gd")
|
|
4
5
|
|
|
5
6
|
var _log: Log
|
|
@@ -30,8 +31,7 @@ func list_plugins(_params: Dictionary) -> Dictionary:
|
|
|
30
31
|
var enabled_count: int = 0
|
|
31
32
|
|
|
32
33
|
var dir: DirAccess = DirAccess.open(addons_path)
|
|
33
|
-
if dir:
|
|
34
|
-
dir.list_dir_begin()
|
|
34
|
+
if dir and dir.list_dir_begin() == OK:
|
|
35
35
|
var folder_name: String = dir.get_next()
|
|
36
36
|
|
|
37
37
|
while folder_name != "":
|
|
@@ -122,8 +122,7 @@ func disable_plugin(params: Dictionary) -> Dictionary:
|
|
|
122
122
|
# type; the String form is what an older hand-edited file can carry.
|
|
123
123
|
func _enabled_plugin_names() -> Array[String]:
|
|
124
124
|
var names: Array[String] = []
|
|
125
|
-
var regex: RegEx =
|
|
126
|
-
regex.compile("res://addons/([^/]+)/plugin.cfg")
|
|
125
|
+
var regex: RegEx = Patterns.compiled("res://addons/([^/]+)/plugin.cfg")
|
|
127
126
|
|
|
128
127
|
var enabled_value: Variant = ProjectSettings.get_setting("editor_plugins/enabled", PackedStringArray())
|
|
129
128
|
if enabled_value is PackedStringArray:
|
|
@@ -151,9 +150,14 @@ func _save_enabled_plugins(names: Array[String]) -> Error:
|
|
|
151
150
|
ProjectSettings.set_setting("editor_plugins/enabled", null)
|
|
152
151
|
return ProjectSettings.save()
|
|
153
152
|
|
|
154
|
-
|
|
153
|
+
# Gathered in an Array[String] and converted at the end, because appending to a packed array
|
|
154
|
+
# answers with whether it worked and a project holding return_value_discarded at error level
|
|
155
|
+
# will not compile a script that drops that answer. The conversion is what matters: an
|
|
156
|
+
# Array[String] handed to set_setting is written as Array[String]([...]), which the editor does
|
|
157
|
+
# not read as a plugin list at all.
|
|
158
|
+
var enabled_paths: Array[String] = []
|
|
155
159
|
for name: String in names:
|
|
156
160
|
enabled_paths.append("res://addons/" + name + "/plugin.cfg")
|
|
157
161
|
|
|
158
|
-
ProjectSettings.set_setting("editor_plugins/enabled", enabled_paths)
|
|
162
|
+
ProjectSettings.set_setting("editor_plugins/enabled", PackedStringArray(enabled_paths))
|
|
159
163
|
return ProjectSettings.save()
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
extends RefCounted
|
|
2
2
|
|
|
3
|
+
const Read = preload("reading.gd")
|
|
3
4
|
const Log = preload("logger.gd")
|
|
4
5
|
const Serialisation = preload("serialisation.gd")
|
|
5
6
|
|
|
@@ -85,7 +86,7 @@ func set_project_setting(params: Dictionary) -> Dictionary:
|
|
|
85
86
|
func _wanted_type(setting_path: String, current: Variant) -> int:
|
|
86
87
|
for info: Dictionary in ProjectSettings.get_property_list():
|
|
87
88
|
if str(info.get("name", "")) == setting_path:
|
|
88
|
-
return
|
|
89
|
+
return Read.as_int(info.get("type", TYPE_NIL), TYPE_NIL)
|
|
89
90
|
return typeof(current)
|
|
90
91
|
|
|
91
92
|
|
|
@@ -101,7 +102,7 @@ func _converts_faithfully(value: Variant, to: int) -> bool:
|
|
|
101
102
|
func add_autoload(params: Dictionary) -> Dictionary:
|
|
102
103
|
var name: String = str(params.get("name", ""))
|
|
103
104
|
var path: String = str(params.get("path", ""))
|
|
104
|
-
var enabled: bool =
|
|
105
|
+
var enabled: bool = Read.as_bool(params.get("enabled", true), true)
|
|
105
106
|
|
|
106
107
|
if not path.begins_with("res://"):
|
|
107
108
|
path = "res://" + path
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
extends RefCounted
|
|
2
|
+
|
|
3
|
+
# A value out of a dictionary that came from JSON, as the type the operation wants.
|
|
4
|
+
#
|
|
5
|
+
# `int(value)`, `float(value)` and `bool(value)` take a Variant, and a project holding
|
|
6
|
+
# `unsafe_call_argument` at error level will not compile a script that hands one over. These
|
|
7
|
+
# scripts are compiled under the target project's warning levels rather than under this package's,
|
|
8
|
+
# because `--path` makes that project the loaded one and the file's living in the npm cache
|
|
9
|
+
# changes nothing: one project turning that warning on lost every headless operation at once.
|
|
10
|
+
#
|
|
11
|
+
# The conversion itself is the same. What changes is that the type is established first, on a
|
|
12
|
+
# typed local, and the conversion happens from that. Here rather than at each of the thirty-one
|
|
13
|
+
# places that read a parameter, because thirty-one is how many chances there are to write the old
|
|
14
|
+
# form again, and the error does not appear until somebody sets the warning.
|
|
15
|
+
#
|
|
16
|
+
# `fallback` answers a value that is there and is null, which is a caller sending JSON null where a
|
|
17
|
+
# number was expected. Absent keys never reach here: the callers pass their own default to
|
|
18
|
+
# `Dictionary.get`, so what arrives is that default.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
static func as_int(value: Variant, fallback: int = 0) -> int:
|
|
22
|
+
if value is int:
|
|
23
|
+
var already: int = value
|
|
24
|
+
return already
|
|
25
|
+
if value is float:
|
|
26
|
+
var real: float = value
|
|
27
|
+
return int(real)
|
|
28
|
+
if value is bool:
|
|
29
|
+
var flag: bool = value
|
|
30
|
+
return 1 if flag else 0
|
|
31
|
+
if value is String:
|
|
32
|
+
var text: String = value
|
|
33
|
+
return text.to_int()
|
|
34
|
+
return fallback
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
static func as_float(value: Variant, fallback: float = 0.0) -> float:
|
|
38
|
+
if value is float:
|
|
39
|
+
var already: float = value
|
|
40
|
+
return already
|
|
41
|
+
if value is int:
|
|
42
|
+
var whole: int = value
|
|
43
|
+
return float(whole)
|
|
44
|
+
if value is bool:
|
|
45
|
+
var flag: bool = value
|
|
46
|
+
return 1.0 if flag else 0.0
|
|
47
|
+
if value is String:
|
|
48
|
+
var text: String = value
|
|
49
|
+
return text.to_float()
|
|
50
|
+
return fallback
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
static func as_bool(value: Variant, fallback: bool = false) -> bool:
|
|
54
|
+
if value is bool:
|
|
55
|
+
var already: bool = value
|
|
56
|
+
return already
|
|
57
|
+
if value is int:
|
|
58
|
+
var whole: int = value
|
|
59
|
+
return whole != 0
|
|
60
|
+
if value is float:
|
|
61
|
+
var real: float = value
|
|
62
|
+
return not is_zero_approx(real)
|
|
63
|
+
if value is String:
|
|
64
|
+
var text: String = value
|
|
65
|
+
return not text.is_empty()
|
|
66
|
+
return fallback
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
extends RefCounted
|
|
2
2
|
|
|
3
|
+
const Read = preload("reading.gd")
|
|
4
|
+
|
|
3
5
|
# What each Godot type becomes on the wire, as one table you can read rather than an order you
|
|
4
6
|
# have to trust. Keyed on typeof() rather than written as a chain of `is` tests, because the
|
|
5
7
|
# order mattered: Resource had to be tested before Object or every resource came back as a bare
|
|
@@ -60,26 +62,56 @@ func deserialize_value(value: Variant) -> Variant:
|
|
|
60
62
|
rebuilt[key] = deserialize_value(fields[key])
|
|
61
63
|
return rebuilt
|
|
62
64
|
|
|
65
|
+
# Each component read as the type the constructor wants before it is handed over. These come
|
|
66
|
+
# out of JSON as Variant, and a project holding `unsafe_call_argument` at error level refuses
|
|
67
|
+
# to compile a script that gives a Variant to a typed parameter: the operations are compiled
|
|
68
|
+
# under the target project's warning levels, so one such project lost every headless call.
|
|
63
69
|
match fields["_type"]:
|
|
64
70
|
"Vector2":
|
|
65
|
-
return Vector2(fields.get("x", 0), fields.get("y", 0))
|
|
71
|
+
return Vector2(Read.as_float(fields.get("x", 0)), Read.as_float(fields.get("y", 0)))
|
|
66
72
|
"Vector3":
|
|
67
|
-
return Vector3(
|
|
73
|
+
return Vector3(
|
|
74
|
+
Read.as_float(fields.get("x", 0)),
|
|
75
|
+
Read.as_float(fields.get("y", 0)),
|
|
76
|
+
Read.as_float(fields.get("z", 0))
|
|
77
|
+
)
|
|
68
78
|
"Vector2i":
|
|
69
|
-
return Vector2i(fields.get("x", 0), fields.get("y", 0))
|
|
79
|
+
return Vector2i(Read.as_int(fields.get("x", 0)), Read.as_int(fields.get("y", 0)))
|
|
70
80
|
"Vector3i":
|
|
71
|
-
return Vector3i(
|
|
81
|
+
return Vector3i(
|
|
82
|
+
Read.as_int(fields.get("x", 0)),
|
|
83
|
+
Read.as_int(fields.get("y", 0)),
|
|
84
|
+
Read.as_int(fields.get("z", 0))
|
|
85
|
+
)
|
|
72
86
|
"Color":
|
|
73
|
-
return Color(
|
|
87
|
+
return Color(
|
|
88
|
+
Read.as_float(fields.get("r", 0)),
|
|
89
|
+
Read.as_float(fields.get("g", 0)),
|
|
90
|
+
Read.as_float(fields.get("b", 0)),
|
|
91
|
+
Read.as_float(fields.get("a", 1), 1.0)
|
|
92
|
+
)
|
|
74
93
|
"Rect2":
|
|
75
|
-
|
|
76
|
-
var size: Variant = deserialize_value(fields.get("size", {}))
|
|
77
|
-
return Rect2(position, size)
|
|
94
|
+
return _rect_from(fields)
|
|
78
95
|
"NodePath":
|
|
79
|
-
return NodePath(fields.get("path", ""))
|
|
96
|
+
return NodePath(str(fields.get("path", "")))
|
|
80
97
|
return fields
|
|
81
98
|
|
|
82
99
|
|
|
100
|
+
## A Rect2 out of its two tagged corners, or the fields back when they do not describe one.
|
|
101
|
+
##
|
|
102
|
+
## Its own function because the components have to be read as Vector2 before the constructor is
|
|
103
|
+
## given them, and a branch that can also answer with the fields would push the match above past
|
|
104
|
+
## the return count this project holds itself to.
|
|
105
|
+
func _rect_from(fields: Dictionary) -> Variant:
|
|
106
|
+
var position: Variant = deserialize_value(fields.get("position", {}))
|
|
107
|
+
var size: Variant = deserialize_value(fields.get("size", {}))
|
|
108
|
+
if not (position is Vector2 and size is Vector2):
|
|
109
|
+
return fields
|
|
110
|
+
var at: Vector2 = position
|
|
111
|
+
var extent: Vector2 = size
|
|
112
|
+
return Rect2(at, extent)
|
|
113
|
+
|
|
114
|
+
|
|
83
115
|
func _serialize_nil(_value: Variant) -> Variant:
|
|
84
116
|
return null
|
|
85
117
|
|
package/build/index.js
CHANGED
|
@@ -10040,6 +10040,13 @@ function addonMismatch(addonVersion, serverVersion) {
|
|
|
10040
10040
|
}
|
|
10041
10041
|
return `${both} Restart it with editor_launch restart to pick the new one up.`;
|
|
10042
10042
|
}
|
|
10043
|
+
function markIfStale(answer, addonVersion, serverVersion) {
|
|
10044
|
+
const staleNote = addonMismatch(addonVersion, serverVersion);
|
|
10045
|
+
if (staleNote === undefined || typeof answer !== "object" || answer === null || Array.isArray(answer)) {
|
|
10046
|
+
return answer;
|
|
10047
|
+
}
|
|
10048
|
+
return { ...answer, addonIsStale: true, staleNote };
|
|
10049
|
+
}
|
|
10043
10050
|
|
|
10044
10051
|
// src/issues.ts
|
|
10045
10052
|
var NEW_ISSUE = "https://github.com/Aureliolo/gdharness/issues/new";
|
|
@@ -31111,7 +31118,7 @@ class GodotServer {
|
|
|
31111
31118
|
]);
|
|
31112
31119
|
}
|
|
31113
31120
|
try {
|
|
31114
|
-
return this.jsonTextResponse(await this.godotBridge.invokeTool(toolName, args));
|
|
31121
|
+
return this.jsonTextResponse(markIfStale(await this.godotBridge.invokeTool(toolName, args), this.godotBridge.getStatus().addonVersion, SERVER_VERSION));
|
|
31115
31122
|
} catch (error) {
|
|
31116
31123
|
return this.createErrorResponse(`The editor answered ${toolName} with an error: ${errorMessage(error)}`);
|
|
31117
31124
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gdharness",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.18",
|
|
4
4
|
"mcpName": "io.github.Aureliolo/gdharness",
|
|
5
5
|
"description": "A harness for driving a Godot 4 project from an agent: editor addons, a runtime bridge into the running game, an MCP server in front of them, and a CLI that installs and diagnoses the Godot side.",
|
|
6
6
|
"type": "module",
|