unity-agentic-tools 0.5.0 → 0.6.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.
Files changed (99) hide show
  1. package/README.md +49 -103
  2. package/dist/animator-utils.d.ts +46 -0
  3. package/dist/animator-utils.d.ts.map +1 -0
  4. package/dist/animator-utils.js +161 -0
  5. package/dist/animator-utils.js.map +1 -0
  6. package/dist/bridge-install.d.ts +11 -0
  7. package/dist/bridge-install.d.ts.map +1 -0
  8. package/dist/bridge-install.js +23 -0
  9. package/dist/bridge-install.js.map +1 -0
  10. package/dist/build-settings.d.ts +43 -0
  11. package/dist/build-settings.d.ts.map +1 -0
  12. package/dist/build-settings.js +196 -0
  13. package/dist/build-settings.js.map +1 -0
  14. package/dist/build-version.d.ts +40 -0
  15. package/dist/build-version.d.ts.map +1 -0
  16. package/dist/build-version.js +114 -0
  17. package/dist/build-version.js.map +1 -0
  18. package/dist/class-ids.d.ts +30 -0
  19. package/dist/class-ids.d.ts.map +1 -0
  20. package/dist/class-ids.js +322 -0
  21. package/dist/class-ids.js.map +1 -0
  22. package/dist/cleanup.d.ts +21 -0
  23. package/dist/cleanup.d.ts.map +1 -0
  24. package/dist/cleanup.js +161 -0
  25. package/dist/cleanup.js.map +1 -0
  26. package/dist/cli-output.d.ts +7 -0
  27. package/dist/cli-output.d.ts.map +1 -0
  28. package/dist/cli-output.js +24 -0
  29. package/dist/cli-output.js.map +1 -0
  30. package/dist/cli.d.ts +3 -0
  31. package/dist/cli.d.ts.map +1 -0
  32. package/dist/cli.js +795 -8143
  33. package/dist/cli.js.map +1 -0
  34. package/dist/doc-indexer-cli.js +1 -1
  35. package/dist/editor-client.d.ts +18 -0
  36. package/dist/editor-client.d.ts.map +1 -0
  37. package/dist/editor-client.js +256 -0
  38. package/dist/editor-client.js.map +1 -0
  39. package/dist/editor-discovery.d.ts +17 -0
  40. package/dist/editor-discovery.d.ts.map +1 -0
  41. package/dist/editor-discovery.js +248 -0
  42. package/dist/editor-discovery.js.map +1 -0
  43. package/dist/editor-transport.d.ts +30 -0
  44. package/dist/editor-transport.d.ts.map +1 -0
  45. package/dist/editor-transport.js +175 -0
  46. package/dist/editor-transport.js.map +1 -0
  47. package/dist/gitignore.d.ts +3 -0
  48. package/dist/gitignore.d.ts.map +1 -0
  49. package/dist/gitignore.js +40 -0
  50. package/dist/gitignore.js.map +1 -0
  51. package/dist/guid-cache.d.ts +45 -0
  52. package/dist/guid-cache.d.ts.map +1 -0
  53. package/dist/guid-cache.js +111 -0
  54. package/dist/guid-cache.js.map +1 -0
  55. package/dist/index.d.ts +11 -0
  56. package/dist/index.d.ts.map +1 -0
  57. package/dist/index.js +743 -8040
  58. package/dist/index.js.map +1 -0
  59. package/dist/loaded-protection.d.ts +6 -0
  60. package/dist/loaded-protection.d.ts.map +1 -0
  61. package/dist/loaded-protection.js +95 -0
  62. package/dist/loaded-protection.js.map +1 -0
  63. package/dist/packages.d.ts +55 -0
  64. package/dist/packages.d.ts.map +1 -0
  65. package/dist/packages.js +102 -0
  66. package/dist/packages.js.map +1 -0
  67. package/dist/params.d.ts +54 -0
  68. package/dist/params.d.ts.map +1 -0
  69. package/dist/params.js +106 -0
  70. package/dist/params.js.map +1 -0
  71. package/dist/project-search.d.ts +16 -0
  72. package/dist/project-search.d.ts.map +1 -0
  73. package/dist/project-search.js +538 -0
  74. package/dist/project-search.js.map +1 -0
  75. package/dist/scanner.d.ts +150 -0
  76. package/dist/scanner.d.ts.map +1 -0
  77. package/dist/scanner.js +223 -0
  78. package/dist/scanner.js.map +1 -0
  79. package/dist/setup.d.ts +25 -0
  80. package/dist/setup.d.ts.map +1 -0
  81. package/dist/setup.js +185 -0
  82. package/dist/setup.js.map +1 -0
  83. package/dist/types.d.ts +390 -0
  84. package/dist/types.d.ts.map +1 -0
  85. package/dist/types.js +3 -0
  86. package/dist/types.js.map +1 -0
  87. package/dist/util.d.ts +2 -0
  88. package/dist/util.d.ts.map +1 -0
  89. package/dist/util.js +7 -0
  90. package/dist/util.js.map +1 -0
  91. package/dist/utils.d.ts +82 -0
  92. package/dist/utils.d.ts.map +1 -0
  93. package/dist/utils.js +291 -0
  94. package/dist/utils.js.map +1 -0
  95. package/native/unity-file-tools.darwin-arm64.node +0 -0
  96. package/native/unity-file-tools.darwin-x64.node +0 -0
  97. package/native/unity-file-tools.linux-x64-gnu.node +0 -0
  98. package/native/unity-file-tools.win32-x64-msvc.node +0 -0
  99. package/package.json +4 -3
package/README.md CHANGED
@@ -1,132 +1,78 @@
1
1
  # unity-agentic-tools
2
2
 
3
- Token-efficient CLI and library for parsing, analyzing, and editing Unity YAML files. Powered by a native Rust backend (napi-rs).
4
-
5
- ## Overview
6
-
7
- Fast CLI for Unity scene, prefab, and asset files. Extracts GameObject hierarchies, components, properties, materials, animations, and project settings with minimal token output for AI agent consumption. Includes a live editor bridge (WebSocket/JSON-RPC) for play mode control, UI interaction, input simulation, and annotated screenshots.
3
+ Compact Unity Editor command runner for AI agents.
8
4
 
9
5
  ## Quick Start
10
6
 
11
7
  ```bash
12
8
  npm install -g unity-agentic-tools
13
- unity-agentic-tools read scene MyScene.unity
14
- unity-agentic-tools read gameobject MyScene.unity "Main Camera" -p
15
- unity-agentic-tools editor invoke UnityAgenticTools.Update.Objects Transform --args '["Assets/Scenes/Main.unity","Main Camera","0,5,-10"]'
9
+ unity-agentic-tools install -p /path/to/UnityProject
10
+ unity-agentic-tools status -p /path/to/UnityProject
11
+ unity-agentic-tools list create -p /path/to/UnityProject
12
+ unity-agentic-tools run query.scene Assets/Scenes/Main.unity -p /path/to/UnityProject
13
+ unity-agentic-tools stream console -p /path/to/UnityProject
14
+ unity-agentic-tools cleanup -p /path/to/UnityProject
16
15
  ```
17
16
 
18
17
  ## Command Surface
19
18
 
20
- Unsafe scene and prefab graph mutations no longer live under top-level `create` / `update`. Use the editor bridge instead:
21
-
22
- ```bash
23
- unity-agentic-tools editor invoke UnityAgenticTools.Create.Scenes GameObject --args '["Assets/Scenes/Main.unity","EnemyRoot","Gameplay"]'
24
- unity-agentic-tools editor invoke UnityAgenticTools.Create.Prefabs PrefabInstance --args '["Assets/Scenes/Boot.unity","Assets/Prefabs/AppRoot.prefab"]'
25
- unity-agentic-tools editor invoke UnityAgenticTools.Update.Objects Component --args '["Assets/Scenes/Main.unity","Player","BoxCollider","0","m_IsTrigger","true"]'
26
- unity-agentic-tools editor invoke UnityAgenticTools.Update.Serialized BatchComponents --args '["Assets/Scenes/Main.unity","[{\"gameObjectPath\":\"Player\",\"componentType\":\"BoxCollider\",\"componentIndex\":0,\"propertyPath\":\"m_IsTrigger\",\"value\":\"true\"}]"]'
27
- ```
28
-
29
- Top-level CLI commands remain for file-safe asset and project mutations. `UnityAgenticTools.Create.*` / `UnityAgenticTools.Update.*` require a reachable live editor bridge; they do not fall back to handwritten YAML.
30
-
31
- ### Read (20)
32
- `read scene` | `read gameobject` | `read asset` | `read scriptable-object` | `read material` | `read dependencies` | `read dependents` | `read unused` | `read settings` | `read build` | `read overrides` | `read component` | `read reference` | `read script` | `read scripts` | `read meta` | `read animation` | `read animator` | `read manifest` | `read input-actions`
33
-
34
- ### Create (0 top-level)
35
- Creation is editor-only now. Use `unity-agentic-tools editor invoke UnityAgenticTools.Create.* ...`.
36
-
37
- ### Update (7 top-level)
38
- `update scriptable-object` | `update settings` | `update layer` | `update material` | `update meta` | `update animation` | `update animator`
39
-
40
- ### Delete (6)
41
- `delete gameobject` | `delete component` | `delete build` | `delete prefab` | `delete asset` | `delete package`
42
-
43
- ### Editor (6) -- Live Unity Bridge
44
- `editor status` | `editor invoke` | `editor console-follow` | `editor list` | `editor install` | `editor uninstall`
45
-
46
- ### Utilities (8)
47
- `search` | `grep` | `clone` | `version` | `docs` | `setup` | `cleanup` | `status`
48
-
49
- Run any command with `--help` for full options.
50
-
51
- ## Loaded Edit Protection
19
+ The CLI intentionally exposes seven broad commands:
52
20
 
53
- When editor bridge is connected, file-based mutators that still edit `.unity`/`.prefab` files are soft-protected. If a remaining file-based command targets a loaded file, pass `--bypass-loaded-protection`.
21
+ | Command | Purpose |
22
+ |---------|---------|
23
+ | `list [query]` | Discover built-in aliases, attributed project commands, and optional raw static APIs |
24
+ | `run <target> [args...]` | Execute a command alias or raw public static C# method/property through the Unity bridge |
25
+ | `stream [topic]` | Watch real-time bridge events over WebSocket |
26
+ | `install` | Install the Unity bridge package |
27
+ | `uninstall` | Remove the Unity bridge package |
28
+ | `cleanup` | Remove stale bridge state or rebuildable `.unity-agentic` caches |
29
+ | `status` | Check command runner and bridge reachability |
54
30
 
55
- This affects scene/prefab mutators including:
56
- - `clone`
57
- - `delete gameobject|component|prefab|asset`
31
+ There are no hidden local serialized-file mutation commands or editor APIs.
58
32
 
59
- Scene/prefab graph creation and mutation should now go through `editor invoke UnityAgenticTools.Create.* ...` or `UnityAgenticTools.Update.* ...`, not `--bypass-loaded-protection`.
33
+ ## Examples
60
34
 
61
- If editor bridge is offline/unreachable, the remaining file-based operations behave the same as before, but `editor invoke UnityAgenticTools.Create.* ...` and `UnityAgenticTools.Update.* ...` cannot run.
62
-
63
- ## Editor-Only Scene / Prefab Mutation APIs
35
+ ```bash
36
+ unity-agentic-tools list scene -p <project>
37
+ unity-agentic-tools run project.refresh -p <project>
38
+ unity-agentic-tools run scene.open Assets/Scenes/Main.unity false -p <project>
39
+ unity-agentic-tools run create.gameobject Assets/Scenes/Main.unity EnemyRoot Gameplay -p <project>
40
+ unity-agentic-tools run update.transform Assets/Scenes/Main.unity Player 1,2,3 0,90,0 1,1,1 -p <project>
41
+ unity-agentic-tools run delete.component Assets/Scenes/Main.unity Player BoxCollider 0 -p <project>
42
+ unity-agentic-tools stream console --type Error -p <project>
43
+ unity-agentic-tools cleanup --cache -p <project>
44
+ ```
64
45
 
65
- `UnityAgenticTools.Create.Scenes`
66
- - `Scene(assetPath, includeDefaults = false)`
67
- - `GameObject(assetPath, name, parentPath = "")`
68
- - `Component(assetPath, gameObjectPath, componentType)`
69
- - `ComponentCopy(assetPath, sourceGameObjectPath, sourceComponentType, sourceComponentIndex, targetGameObjectPath)`
46
+ Use `--args '<json array>'` when an argument itself is structured JSON.
70
47
 
71
- `UnityAgenticTools.Create.Prefabs`
72
- - `Prefab(assetPath, name = "")`
73
- - `PrefabVariant(sourcePrefabPath, outputPath, variantName = "")`
74
- - `PrefabInstance(assetPath, prefabPath, parentPath = "", instanceName = "", localPosX = 0, localPosY = 0, localPosZ = 0)`
48
+ ## Project Commands
75
49
 
76
- `UnityAgenticTools.Create.Assets`
77
- - `ScriptableObject(assetPath, script, initialValuesJson = "")`
78
- - `Meta(scriptPath)`
79
- - `Material(assetPath, shaderGuid, materialName = "")`
80
- - `InputActions(assetPath, name)`
81
- - `Animation(assetPath, clipName = "", sampleRate = 60, loopTime = false)`
82
- - `Animator(assetPath, controllerName = "", layerName = "Base Layer")`
50
+ Expose project-specific behavior by adding `[AgenticCommand]` to public static editor methods/properties:
83
51
 
84
- `UnityAgenticTools.Create.Project`
85
- - `Build(scenePath, position = -1)`
86
- - `Package(name, version)`
52
+ ```csharp
53
+ using UnityAgenticTools.Commands;
87
54
 
88
- `UnityAgenticTools.Update.Objects`
89
- - `GameObject(assetPath, gameObjectPath, propertyPath, value)`
90
- - `Component(assetPath, gameObjectPath, componentType, componentIndex, propertyPath, value)`
91
- - `Transform(assetPath, gameObjectPath, position = "", rotation = "", scale = "")`
92
- - `Parent(assetPath, gameObjectPath, newParentPath = "")`
93
- - `SiblingIndex(assetPath, gameObjectPath, index)`
55
+ public static class BuildCommands
56
+ {
57
+ [AgenticCommand("build.addressables", "Build Addressables content.")]
58
+ public static object BuildAddressables(string profile)
59
+ {
60
+ return new { success = true, profile };
61
+ }
62
+ }
63
+ ```
94
64
 
95
- `UnityAgenticTools.Update.Serialized`
96
- - `Array(assetPath, gameObjectPath, componentType, componentIndex, arrayProperty, action, payloadJson = "")`
97
- - `Batch(assetPath, editsJson)`
98
- - `BatchComponents(assetPath, editsJson)`
99
- - `ManagedReference(assetPath, gameObjectPath, componentType, componentIndex, fieldPath, typeName, initialValuesJson = "", append = false)`
65
+ Then run:
100
66
 
101
- `UnityAgenticTools.Update.Prefabs`
102
- - `PrefabUnpack(assetPath, prefabInstancePath, mode = "OutermostRoot")`
103
- - `PrefabOverride(assetPath, gameObjectPath, componentType, componentIndex, propertyPath, value)`
104
- - `PrefabBatchOverrides(assetPath, editsJson)`
105
- - `PrefabManagedReference(assetPath, gameObjectPath, componentType, componentIndex, fieldPath, typeName, initialValuesJson = "", append = false)`
106
- - `PrefabRemoveOverride(assetPath, gameObjectPath, componentType, componentIndex, propertyPath)`
107
- - `PrefabRemoveComponent(assetPath, gameObjectPath, componentType, componentIndex)`
108
- - `PrefabRestoreComponent(assetPath, gameObjectPath, componentType, componentIndex)`
109
- - `PrefabRemoveGameObject(assetPath, gameObjectPath)`
110
- - `PrefabRestoreGameObject(assetPath, gameObjectPath)`
67
+ ```bash
68
+ unity-agentic-tools list build -p <project>
69
+ unity-agentic-tools run build.addressables Production -p <project>
70
+ ```
111
71
 
112
72
  ## Requirements
113
73
 
114
74
  - Bun runtime
115
- - Native Rust module (included in npm package, or build from source with `bun run build:rust`)
116
-
117
- ## Troubleshooting
118
-
119
- ### Slow on large scenes
120
-
121
- The Rust backend may not be installed. Run `bun install` in the project root to resolve the native module.
122
-
123
- ### Script names show as GUIDs
124
-
125
- The GUID cache hasn't been built for your project. Run `unity-agentic-tools setup -p <project_path>`.
126
-
127
- ### Parse errors on custom assets
128
-
129
- Some asset types with non-standard YAML may not parse correctly. Open an issue with a sample file.
75
+ - Unity Editor bridge package installed in the target project
130
76
 
131
77
  ## License
132
78
 
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Shared utilities for reading and editing Unity AnimatorController files.
3
+ */
4
+ export interface AnimatorBlock {
5
+ file_id: string;
6
+ class_id: number;
7
+ type_name: string;
8
+ raw: string;
9
+ }
10
+ /**
11
+ * Split a multi-document Unity YAML file into typed blocks.
12
+ * Supports negative 64-bit fileIDs (e.g. &-8508701068132362129).
13
+ */
14
+ export declare function split_yaml_blocks(content: string): AnimatorBlock[];
15
+ /**
16
+ * Extract a YAML field value from a block's raw text.
17
+ */
18
+ export declare function yaml_field(raw: string, field: string): string | null;
19
+ /**
20
+ * Extract an inline reference {fileID: X, guid: Y} from a string.
21
+ * Supports negative fileIDs.
22
+ */
23
+ export declare function parse_inline_ref(str: string): {
24
+ fileID: string;
25
+ guid: string;
26
+ } | null;
27
+ /**
28
+ * Find a state block by its m_Name.
29
+ * Returns the block or null.
30
+ */
31
+ export declare function find_state_by_name(blocks: AnimatorBlock[], name: string): AnimatorBlock | null;
32
+ /**
33
+ * Find the state machine block for a given layer.
34
+ * If layer_name is not specified, returns the first state machine.
35
+ */
36
+ export declare function find_state_machine_for_layer(blocks: AnimatorBlock[], controller_block: AnimatorBlock, layer_name?: string): AnimatorBlock | null;
37
+ /**
38
+ * Generate a positive fileID suitable for new Unity YAML blocks.
39
+ * Uses large positive integers to avoid collisions with existing IDs.
40
+ */
41
+ export declare function generate_file_id(existing_ids: Set<string>): string;
42
+ /**
43
+ * Collect all fileIDs (as strings) from the file content.
44
+ */
45
+ export declare function collect_file_ids(content: string): Set<string>;
46
+ //# sourceMappingURL=animator-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animator-utils.d.ts","sourceRoot":"","sources":["../src/animator-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,aAAa;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;CACf;AAID;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,EAAE,CAqClE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAIpE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAGrF;AAID;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAE9F;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CACxC,MAAM,EAAE,aAAa,EAAE,EACvB,gBAAgB,EAAE,aAAa,EAC/B,UAAU,CAAC,EAAE,MAAM,GACpB,aAAa,GAAG,IAAI,CAqDtB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,CAQlE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAO7D"}
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ /**
3
+ * Shared utilities for reading and editing Unity AnimatorController files.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.split_yaml_blocks = split_yaml_blocks;
7
+ exports.yaml_field = yaml_field;
8
+ exports.parse_inline_ref = parse_inline_ref;
9
+ exports.find_state_by_name = find_state_by_name;
10
+ exports.find_state_machine_for_layer = find_state_machine_for_layer;
11
+ exports.generate_file_id = generate_file_id;
12
+ exports.collect_file_ids = collect_file_ids;
13
+ // ========== Parsing ==========
14
+ /**
15
+ * Split a multi-document Unity YAML file into typed blocks.
16
+ * Supports negative 64-bit fileIDs (e.g. &-8508701068132362129).
17
+ */
18
+ function split_yaml_blocks(content) {
19
+ const blocks = [];
20
+ const doc_re = /^--- !u!(\d+) &(-?\d+)/;
21
+ const lines = content.split(/\r?\n/);
22
+ let current_lines = [];
23
+ let current_class_id = 0;
24
+ let current_file_id = '';
25
+ for (const line of lines) {
26
+ const m = doc_re.exec(line);
27
+ if (m) {
28
+ if (current_lines.length > 0) {
29
+ const type_line = current_lines.find(l => /^\w+:/.test(l.trimStart()));
30
+ blocks.push({
31
+ file_id: current_file_id,
32
+ class_id: current_class_id,
33
+ type_name: type_line ? type_line.trimStart().replace(/:.*/, '') : 'Unknown',
34
+ raw: current_lines.join('\n'),
35
+ });
36
+ }
37
+ current_class_id = parseInt(m[1], 10);
38
+ current_file_id = m[2];
39
+ current_lines = [];
40
+ }
41
+ else if (!line.startsWith('%')) {
42
+ current_lines.push(line);
43
+ }
44
+ }
45
+ if (current_lines.length > 0) {
46
+ const type_line = current_lines.find(l => /^\w+:/.test(l.trimStart()));
47
+ blocks.push({
48
+ file_id: current_file_id,
49
+ class_id: current_class_id,
50
+ type_name: type_line ? type_line.trimStart().replace(/:.*/, '') : 'Unknown',
51
+ raw: current_lines.join('\n'),
52
+ });
53
+ }
54
+ return blocks;
55
+ }
56
+ /**
57
+ * Extract a YAML field value from a block's raw text.
58
+ */
59
+ function yaml_field(raw, field) {
60
+ const re = new RegExp(`^\\s*${field}:\\s*(.*)$`, 'm');
61
+ const m = re.exec(raw);
62
+ return m ? m[1].trim() : null;
63
+ }
64
+ /**
65
+ * Extract an inline reference {fileID: X, guid: Y} from a string.
66
+ * Supports negative fileIDs.
67
+ */
68
+ function parse_inline_ref(str) {
69
+ const m = /\{[^}]*fileID:\s*(-?\d+)(?:[^}]*guid:\s*([a-f0-9]+))?/.exec(str);
70
+ return m ? { fileID: m[1], guid: m[2] || '' } : null;
71
+ }
72
+ // ========== Lookup Helpers ==========
73
+ /**
74
+ * Find a state block by its m_Name.
75
+ * Returns the block or null.
76
+ */
77
+ function find_state_by_name(blocks, name) {
78
+ return blocks.find(b => b.class_id === 1102 && yaml_field(b.raw, 'm_Name') === name) || null;
79
+ }
80
+ /**
81
+ * Find the state machine block for a given layer.
82
+ * If layer_name is not specified, returns the first state machine.
83
+ */
84
+ function find_state_machine_for_layer(blocks, controller_block, layer_name) {
85
+ const sm_blocks = blocks.filter(b => b.class_id === 1107);
86
+ if (sm_blocks.length === 0)
87
+ return null;
88
+ if (!layer_name) {
89
+ // Return the first state machine (Base Layer)
90
+ // Parse m_AnimatorLayers to get the first state machine reference
91
+ const lines = controller_block.raw.split(/\r?\n/);
92
+ let in_layers = false;
93
+ for (const line of lines) {
94
+ const t = line.trimStart();
95
+ if (t.startsWith('m_AnimatorLayers:')) {
96
+ in_layers = !t.endsWith('[]');
97
+ continue;
98
+ }
99
+ if (in_layers && t.startsWith('m_StateMachine:')) {
100
+ const ref = parse_inline_ref(t);
101
+ if (ref) {
102
+ return blocks.find(b => b.file_id === ref.fileID && b.class_id === 1107) || null;
103
+ }
104
+ }
105
+ }
106
+ return sm_blocks[0];
107
+ }
108
+ // Find the layer entry and get its state machine reference
109
+ const lines = controller_block.raw.split(/\r?\n/);
110
+ let in_layers = false;
111
+ let found_layer = false;
112
+ for (const line of lines) {
113
+ const t = line.trimStart();
114
+ if (t.startsWith('m_AnimatorLayers:')) {
115
+ in_layers = !t.endsWith('[]');
116
+ continue;
117
+ }
118
+ if (in_layers) {
119
+ if (t.startsWith('m_Name:') && t.includes(layer_name)) {
120
+ found_layer = true;
121
+ continue;
122
+ }
123
+ if (found_layer && t.startsWith('m_StateMachine:')) {
124
+ const ref = parse_inline_ref(t);
125
+ if (ref) {
126
+ return blocks.find(b => b.file_id === ref.fileID && b.class_id === 1107) || null;
127
+ }
128
+ }
129
+ // Reset if we hit a new layer entry
130
+ if (found_layer && t.startsWith('- serializedVersion:')) {
131
+ found_layer = false;
132
+ }
133
+ }
134
+ }
135
+ return null;
136
+ }
137
+ /**
138
+ * Generate a positive fileID suitable for new Unity YAML blocks.
139
+ * Uses large positive integers to avoid collisions with existing IDs.
140
+ */
141
+ function generate_file_id(existing_ids) {
142
+ let id;
143
+ do {
144
+ // Generate a 10-digit positive integer
145
+ const num = Math.floor(Math.random() * 9000000000) + 1000000000;
146
+ id = String(num);
147
+ } while (existing_ids.has(id));
148
+ return id;
149
+ }
150
+ /**
151
+ * Collect all fileIDs (as strings) from the file content.
152
+ */
153
+ function collect_file_ids(content) {
154
+ const ids = new Set();
155
+ const matches = content.matchAll(/--- !u!\d+ &(-?\d+)/g);
156
+ for (const m of matches) {
157
+ ids.add(m[1]);
158
+ }
159
+ return ids;
160
+ }
161
+ //# sourceMappingURL=animator-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animator-utils.js","sourceRoot":"","sources":["../src/animator-utils.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAiBH,8CAqCC;AAKD,gCAIC;AAMD,4CAGC;AAQD,gDAEC;AAMD,oEAyDC;AAMD,4CAQC;AAKD,4CAOC;AAhKD,gCAAgC;AAEhC;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,OAAe;IAC7C,MAAM,MAAM,GAAoB,EAAE,CAAC;IACnC,MAAM,MAAM,GAAG,wBAAwB,CAAC;IACxC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrC,IAAI,aAAa,GAAa,EAAE,CAAC;IACjC,IAAI,gBAAgB,GAAG,CAAC,CAAC;IACzB,IAAI,eAAe,GAAG,EAAE,CAAC;IAEzB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5B,IAAI,CAAC,EAAE,CAAC;YACJ,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC3B,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;gBACvE,MAAM,CAAC,IAAI,CAAC;oBACR,OAAO,EAAE,eAAe;oBACxB,QAAQ,EAAE,gBAAgB;oBAC1B,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,KAAK,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C,CAAC,CAAC,CAAC;gBAChC,IAAI,GAAG,EAAE,CAAC;oBACN,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC;gBACrF,CAAC;YACL,CAAC;YACD,oCAAoC;YACpC,IAAI,WAAW,IAAI,CAAC,CAAC,UAAU,CAAC,sBAAsB,CAAC,EAAE,CAAC;gBACtD,WAAW,GAAG,KAAK,CAAC;YACxB,CAAC;QACL,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,YAAyB;IACtD,IAAI,EAAU,CAAC;IACf,GAAG,CAAC;QACA,uCAAuC;QACvC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,UAAU,CAAC;QAChE,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC,QAAQ,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;IAC/B,OAAO,EAAE,CAAC;AACd,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,OAAe;IAC5C,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC;IACzD,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACtB,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC"}
@@ -0,0 +1,11 @@
1
+ interface BridgeInstallResult {
2
+ success: true;
3
+ action: 'added' | 'updated' | 'preserved';
4
+ name: string;
5
+ version: string;
6
+ }
7
+ export declare function install_bridge_package(project_path: string): BridgeInstallResult | {
8
+ error: string;
9
+ };
10
+ export {};
11
+ //# sourceMappingURL=bridge-install.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge-install.d.ts","sourceRoot":"","sources":["../src/bridge-install.ts"],"names":[],"mappings":"AAKA,UAAU,mBAAmB;IACzB,OAAO,EAAE,IAAI,CAAC;IACd,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,WAAW,CAAC;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,GAAG,mBAAmB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAiBpG"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.install_bridge_package = install_bridge_package;
4
+ const packages_1 = require("./packages");
5
+ const BRIDGE_PACKAGE_NAME = 'com.unity-agentic-tools.editor-bridge';
6
+ const BRIDGE_PACKAGE_VERSION = 'https://github.com/taconotsandwich/unity-agentic-tools.git?path=unity-package';
7
+ function install_bridge_package(project_path) {
8
+ const manifest_result = (0, packages_1.load_manifest)(project_path);
9
+ if ('error' in manifest_result) {
10
+ return manifest_result;
11
+ }
12
+ const existing_version = manifest_result.manifest.dependencies[BRIDGE_PACKAGE_NAME];
13
+ if (typeof existing_version === 'string' && existing_version.startsWith('file:')) {
14
+ return {
15
+ success: true,
16
+ action: 'preserved',
17
+ name: BRIDGE_PACKAGE_NAME,
18
+ version: existing_version,
19
+ };
20
+ }
21
+ return (0, packages_1.add_package)(project_path, BRIDGE_PACKAGE_NAME, BRIDGE_PACKAGE_VERSION);
22
+ }
23
+ //# sourceMappingURL=bridge-install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge-install.js","sourceRoot":"","sources":["../src/bridge-install.ts"],"names":[],"mappings":";;AAYA,wDAiBC;AA7BD,yCAAwD;AAExD,MAAM,mBAAmB,GAAG,uCAAuC,CAAC;AACpE,MAAM,sBAAsB,GAAG,+EAA+E,CAAC;AAS/G,SAAgB,sBAAsB,CAAC,YAAoB;IACvD,MAAM,eAAe,GAAG,IAAA,wBAAa,EAAC,YAAY,CAAC,CAAC;IACpD,IAAI,OAAO,IAAI,eAAe,EAAE,CAAC;QAC7B,OAAO,eAAe,CAAC;IAC3B,CAAC;IAED,MAAM,gBAAgB,GAAG,eAAe,CAAC,QAAQ,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;IACpF,IAAI,OAAO,gBAAgB,KAAK,QAAQ,IAAI,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/E,OAAO;YACH,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,WAAW;YACnB,IAAI,EAAE,mBAAmB;YACzB,OAAO,EAAE,gBAAgB;SAC5B,CAAC;IACN,CAAC;IAED,OAAO,IAAA,sBAAW,EAAC,YAAY,EAAE,mBAAmB,EAAE,sBAAsB,CAAC,CAAC;AAClF,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { UnityProjectInfo } from './build-version';
2
+ export interface SceneEntry {
3
+ enabled: boolean;
4
+ path: string;
5
+ guid?: string;
6
+ buildIndex: number;
7
+ exists?: boolean;
8
+ }
9
+ export interface EditorBuildSettings {
10
+ scenes: SceneEntry[];
11
+ configObjects?: Record<string, string>;
12
+ }
13
+ export interface BuildProfile {
14
+ name: string;
15
+ path: string;
16
+ platform?: string;
17
+ scenes?: SceneEntry[];
18
+ scriptingDefines?: string[];
19
+ }
20
+ export interface BuildSettingsResult {
21
+ projectInfo: UnityProjectInfo;
22
+ editorBuildSettings: EditorBuildSettings;
23
+ buildProfiles: BuildProfile[];
24
+ activeBuildProfile?: string;
25
+ missingScenes?: string[];
26
+ }
27
+ /**
28
+ * Parse EditorBuildSettings.asset YAML file
29
+ */
30
+ export declare function parse_editor_build_settings(filePath: string): EditorBuildSettings;
31
+ /**
32
+ * Parse a Build Profile .asset file (Unity 6+)
33
+ */
34
+ export declare function parse_build_profile(filePath: string): BuildProfile;
35
+ /**
36
+ * List all build profiles in a Unity 6+ project
37
+ */
38
+ export declare function list_build_profiles(projectPath: string): BuildProfile[];
39
+ /**
40
+ * Get complete build settings for a Unity project
41
+ */
42
+ export declare function get_build_settings(projectPath: string): BuildSettingsResult;
43
+ //# sourceMappingURL=build-settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-settings.d.ts","sourceRoot":"","sources":["../src/build-settings.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAErE,MAAM,WAAW,UAAU;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAChC,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C;AAED,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,mBAAmB;IAChC,WAAW,EAAE,gBAAgB,CAAC;IAC9B,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,GAAG,mBAAmB,CAm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