Commit 88e2ebe
* Accept scene-absolute target_path in animation presets (closes #328)
Animation preset tools (preset_fade/slide/shake/pulse) historically
required target_path to be relative to the AnimationPlayer's root_node,
while every other scene tool takes scene-absolute paths like /Main/Foo.
Agents repeatedly tripped on the inconsistency and got an unhelpful
"Target node not found" error that didn't mention either convention.
_resolve_preset_target now accepts both shapes: scene-absolute paths
(via McpScenePath.resolve) are converted to root_node-relative track
paths via root_node.get_path_to(target). Targets outside the player's
root_node subtree are rejected with a clear error explaining why
animation tracks need that constraint. The relative-path error now
names both supported conventions so callers can self-correct.
Also extracts _player_root_node — the same is_inside_tree → root_node
NodePath → get_parent walk was duplicated three times in the file
(validate_animation, _resolve_track_prop_context, the new resolver).
Coverage: four new GDScript tests (each preset's absolute-path branch,
plus a target-equals-root_node edge case verifying "." track shape and
an outside-subtree rejection). Augmented the existing missing-target
test to lock the improved error message. Live-smoked: scene-absolute
target_path now succeeds end-to-end, animation_manage validate reports
broken_count=0 on the resulting track.
https://claude.ai/code/session_01EduM6GCbywUfRhMQAL8M5N
* Apply Copilot review feedback on preset target_path
Three findings from the PR review:
1. Drop the `is_ancestor_of` strict check on scene-absolute targets. The
relative form already accepts `..`-prefixed paths via
`root_node.get_node_or_null`, and Godot's animation engine stores and
resolves them natively. Rejecting the same node when callers spell it
absolutely made the new shape strictly less capable than the relative
form. `get_path_to` yields the right `..`-prefixed track path.
2. The hardcoded `/Main/World/Cube` example in the not-found error is
misleading in any scene whose root isn't named Main. Use the actual
`scene_root.name` so the hint always points at a valid path shape.
3. Add `test_preset_slide_accepts_scene_absolute_target` so slide gets
the same positive abs-path coverage as fade/shake/pulse, and convert
the old slide rejection test into
`test_preset_slide_accepts_target_outside_root_node` to lock in the
new permissive behavior (track stored as `../ForeignTarget:position`).
Also updates `tools/animation.py` module docstring to match the new
behavior.
ruff check src/ tests/: clean.
script/ci-check-gdscript: clean.
pytest: 762 passed.
https://claude.ai/code/session_01DwmN9ouQq88KnabiW42y2C
* Fix slide preset test animation names
The two new slide tests asserted on `slide_in` but `preset_slide`
actually defaults `animation_name` to `slide_<mode>_<direction>`
(see animation_handler.gd:923). Use `slide_in_left` to match.
Caught by CI (Linux/macOS/Windows Godot test jobs).
https://claude.ai/code/session_01DwmN9ouQq88KnabiW42y2C
---------
Co-authored-by: Claude <noreply@anthropic.com>
1 parent b1aeb9a commit 88e2ebe
3 files changed
Lines changed: 294 additions & 35 deletions
File tree
- plugin/addons/godot_ai/handlers
- src/godot_ai/tools
- test_project/tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
588 | 588 | | |
589 | 589 | | |
590 | 590 | | |
591 | | - | |
592 | | - | |
593 | | - | |
594 | | - | |
595 | | - | |
596 | | - | |
597 | | - | |
| 591 | + | |
598 | 592 | | |
599 | 593 | | |
600 | 594 | | |
| |||
810 | 804 | | |
811 | 805 | | |
812 | 806 | | |
| 807 | + | |
813 | 808 | | |
814 | 809 | | |
815 | 810 | | |
| |||
839 | 834 | | |
840 | 835 | | |
841 | 836 | | |
842 | | - | |
| 837 | + | |
843 | 838 | | |
844 | 839 | | |
845 | 840 | | |
| |||
905 | 900 | | |
906 | 901 | | |
907 | 902 | | |
| 903 | + | |
908 | 904 | | |
909 | 905 | | |
910 | 906 | | |
| |||
937 | 933 | | |
938 | 934 | | |
939 | 935 | | |
940 | | - | |
| 936 | + | |
941 | 937 | | |
942 | 938 | | |
943 | 939 | | |
| |||
1001 | 997 | | |
1002 | 998 | | |
1003 | 999 | | |
| 1000 | + | |
1004 | 1001 | | |
1005 | 1002 | | |
1006 | 1003 | | |
| |||
1048 | 1045 | | |
1049 | 1046 | | |
1050 | 1047 | | |
1051 | | - | |
| 1048 | + | |
1052 | 1049 | | |
1053 | 1050 | | |
1054 | 1051 | | |
| |||
1110 | 1107 | | |
1111 | 1108 | | |
1112 | 1109 | | |
| 1110 | + | |
1113 | 1111 | | |
1114 | 1112 | | |
1115 | 1113 | | |
| |||
1134 | 1132 | | |
1135 | 1133 | | |
1136 | 1134 | | |
1137 | | - | |
| 1135 | + | |
1138 | 1136 | | |
1139 | 1137 | | |
1140 | 1138 | | |
| |||
1165 | 1163 | | |
1166 | 1164 | | |
1167 | 1165 | | |
1168 | | - | |
1169 | | - | |
1170 | | - | |
1171 | | - | |
1172 | | - | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
1173 | 1200 | | |
1174 | | - | |
1175 | | - | |
1176 | | - | |
1177 | | - | |
1178 | | - | |
1179 | | - | |
1180 | | - | |
| 1201 | + | |
1181 | 1202 | | |
1182 | 1203 | | |
1183 | 1204 | | |
1184 | | - | |
1185 | | - | |
1186 | | - | |
1187 | | - | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
1188 | 1237 | | |
1189 | 1238 | | |
1190 | 1239 | | |
| |||
1195 | 1244 | | |
1196 | 1245 | | |
1197 | 1246 | | |
1198 | | - | |
| 1247 | + | |
1199 | 1248 | | |
1200 | 1249 | | |
1201 | 1250 | | |
| |||
1481 | 1530 | | |
1482 | 1531 | | |
1483 | 1532 | | |
1484 | | - | |
1485 | | - | |
1486 | | - | |
1487 | | - | |
1488 | | - | |
1489 | | - | |
1490 | | - | |
| 1533 | + | |
1491 | 1534 | | |
1492 | 1535 | | |
1493 | 1536 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
61 | 68 | | |
62 | 69 | | |
63 | 70 | | |
| |||
76 | 83 | | |
77 | 84 | | |
78 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
79 | 90 | | |
80 | 91 | | |
81 | 92 | | |
| |||
0 commit comments