diff --git a/.agents/skills/uloop-execute-dynamic-code/SKILL.md b/.agents/skills/uloop-execute-dynamic-code/SKILL.md index 9bea37081b..e237a67a7c 100644 --- a/.agents/skills/uloop-execute-dynamic-code/SKILL.md +++ b/.agents/skills/uloop-execute-dynamic-code/SKILL.md @@ -25,8 +25,8 @@ This tool can inspect reachable Unity state, such as GameObjects, components, pu - `--code ''`: Inline C# statements to execute. Use direct statements only; `return` is optional, and `using` directives may appear at the top of the snippet. - `--code-file `: Read the C# statements from a file instead of `--code`. Use this when the active shell or launcher cannot preserve inline code exactly. Exactly one of `--code` or `--code-file` is required; combining them is an error. -- **Shell quoting**: bash/zsh uses single quotes, for example `uloop execute-dynamic-code --code 'using UnityEngine; return Mathf.PI;'`. PowerShell 7 (`pwsh`) preserves C# double quotes inside single-quoted strings. Windows PowerShell 5.1 removes unescaped double quotes when invoking native commands; escape C# double quotes as `\"` there, or use `--code-file` when the snippet has many strings. -- `--parameters {}` (advanced, optional): Pass an object when reusing a snippet with varying data or when keeping values outside the code. Values are exposed as `parameters["param0"]`, `parameters["param1"]`, and so on. Omit this flag for most snippets, and pass an object instead of a JSON string. +- **Shell quoting**: bash/zsh uses single quotes, for example `uloop execute-dynamic-code --code 'using UnityEngine; return Mathf.PI;'`. PowerShell 7 (`pwsh`) can pass multiline snippets without `--code-file` by using a single-quoted here-string, for example `$code = @' ... '@; uloop execute-dynamic-code --code $code`. Windows PowerShell 5.1 removes unescaped double quotes when invoking native commands; escape C# double quotes as `\"` for short inline snippets, or use `--code-file` when the snippet has many strings. +- `--parameters {}` (advanced, optional): Pass a shell-quoted JSON object literal when reusing a snippet with varying data or when keeping values outside the code. Values are exposed as `parameters["param0"]`, `parameters["param1"]`, and so on. Omit this flag for most snippets. Do not pass a JSON string value such as `"{\"param0\":\"value\"}"`. - `--wait-for-domain-reload` (optional): Wait for Domain Reload recovery after snippets that intentionally trigger Unity script reload or import work. Omit this for normal inspection and editor-state workflows. ## Code Rules diff --git a/.agents/skills/uloop-execute-dynamic-code/references/playmode-automation-powershell.md b/.agents/skills/uloop-execute-dynamic-code/references/playmode-automation-powershell.md index a3b4ae84c5..fe39803099 100644 --- a/.agents/skills/uloop-execute-dynamic-code/references/playmode-automation-powershell.md +++ b/.agents/skills/uloop-execute-dynamic-code/references/playmode-automation-powershell.md @@ -24,12 +24,27 @@ Use `execute-dynamic-code` for direct automation and diagnostics, and switch to ## PowerShell Quoting Notes -Use these patterns when you need shell-safe inline code: +Use these patterns when you need shell-safe inline code. +PowerShell's equivalent to a bash heredoc is a single-quoted here-string. +In PowerShell 7 (`pwsh`), it can be passed to `--code` directly without creating a temporary file: + +```powershell +uloop execute-dynamic-code --code @' +using UnityEngine; +using UnityEngine.SceneManagement; + +Scene scene = SceneManager.GetActiveScene(); +GameObject[] objects = UnityEngine.Object.FindObjectsByType(FindObjectsInactive.Include, FindObjectsSortMode.None); +return $"{scene.name}: {objects.Length} objects"; +'@ +``` + +Use `--code-file` when the active shell or launcher cannot preserve inline code exactly, especially for Windows PowerShell 5.1 snippets with many C# string literals. ### Native launcher check -Multi-line `--code` expects PowerShell to call the native `uloop.exe` launcher directly. -If `Get-Command uloop` resolves to an old npm `.cmd` shim, run `uloop install` and open a new terminal before relying on multi-line inline snippets. +Multi-line `--code` expects PowerShell to call the native Go `uloop.exe` launcher directly. +If `Get-Command uloop` resolves to an old `.cmd` shim from a previous installation, run `uloop install` and open a new terminal before relying on multi-line inline snippets. ```powershell (Get-Command uloop).Source @@ -58,9 +73,9 @@ If the C# snippet itself contains a single quote, double it inside the PowerShel uloop execute-dynamic-code --code 'char initial = ''A''; return initial.ToString();' ``` -### JSON-like values passed via `--parameters` +### JSON object values passed via `--parameters` -Wrap the whole expression in single quotes so PowerShell passes the inner double quotes through unchanged. +Pass a JSON object literal, not a JSON string value. Wrap the object literal in single quotes so PowerShell passes the inner double quotes through unchanged. ```powershell uloop execute-dynamic-code --code 'return parameters["param0"];' --parameters '{"param0":"Hello from PowerShell"}' @@ -68,7 +83,7 @@ uloop execute-dynamic-code --code 'return parameters["param0"];' --parameters '{ ### Multi-line C# snippets -Use a here-string when the snippet spans multiple lines in PowerShell 7 (`pwsh`). +Use a here-string variable when you want to prepare or reuse a snippet before executing it in PowerShell 7 (`pwsh`). ```powershell $code = @' @@ -98,7 +113,7 @@ return obj.name; uloop execute-dynamic-code --code $code ``` -You can combine multi-line code with multi-line parameters the same way. +You can combine multi-line code with a multi-line JSON object literal the same way. ```powershell $code = @' diff --git a/.claude/skills/uloop-execute-dynamic-code/SKILL.md b/.claude/skills/uloop-execute-dynamic-code/SKILL.md index 9bea37081b..e237a67a7c 100644 --- a/.claude/skills/uloop-execute-dynamic-code/SKILL.md +++ b/.claude/skills/uloop-execute-dynamic-code/SKILL.md @@ -25,8 +25,8 @@ This tool can inspect reachable Unity state, such as GameObjects, components, pu - `--code ''`: Inline C# statements to execute. Use direct statements only; `return` is optional, and `using` directives may appear at the top of the snippet. - `--code-file `: Read the C# statements from a file instead of `--code`. Use this when the active shell or launcher cannot preserve inline code exactly. Exactly one of `--code` or `--code-file` is required; combining them is an error. -- **Shell quoting**: bash/zsh uses single quotes, for example `uloop execute-dynamic-code --code 'using UnityEngine; return Mathf.PI;'`. PowerShell 7 (`pwsh`) preserves C# double quotes inside single-quoted strings. Windows PowerShell 5.1 removes unescaped double quotes when invoking native commands; escape C# double quotes as `\"` there, or use `--code-file` when the snippet has many strings. -- `--parameters {}` (advanced, optional): Pass an object when reusing a snippet with varying data or when keeping values outside the code. Values are exposed as `parameters["param0"]`, `parameters["param1"]`, and so on. Omit this flag for most snippets, and pass an object instead of a JSON string. +- **Shell quoting**: bash/zsh uses single quotes, for example `uloop execute-dynamic-code --code 'using UnityEngine; return Mathf.PI;'`. PowerShell 7 (`pwsh`) can pass multiline snippets without `--code-file` by using a single-quoted here-string, for example `$code = @' ... '@; uloop execute-dynamic-code --code $code`. Windows PowerShell 5.1 removes unescaped double quotes when invoking native commands; escape C# double quotes as `\"` for short inline snippets, or use `--code-file` when the snippet has many strings. +- `--parameters {}` (advanced, optional): Pass a shell-quoted JSON object literal when reusing a snippet with varying data or when keeping values outside the code. Values are exposed as `parameters["param0"]`, `parameters["param1"]`, and so on. Omit this flag for most snippets. Do not pass a JSON string value such as `"{\"param0\":\"value\"}"`. - `--wait-for-domain-reload` (optional): Wait for Domain Reload recovery after snippets that intentionally trigger Unity script reload or import work. Omit this for normal inspection and editor-state workflows. ## Code Rules diff --git a/.claude/skills/uloop-execute-dynamic-code/references/playmode-automation-powershell.md b/.claude/skills/uloop-execute-dynamic-code/references/playmode-automation-powershell.md index a3b4ae84c5..fe39803099 100644 --- a/.claude/skills/uloop-execute-dynamic-code/references/playmode-automation-powershell.md +++ b/.claude/skills/uloop-execute-dynamic-code/references/playmode-automation-powershell.md @@ -24,12 +24,27 @@ Use `execute-dynamic-code` for direct automation and diagnostics, and switch to ## PowerShell Quoting Notes -Use these patterns when you need shell-safe inline code: +Use these patterns when you need shell-safe inline code. +PowerShell's equivalent to a bash heredoc is a single-quoted here-string. +In PowerShell 7 (`pwsh`), it can be passed to `--code` directly without creating a temporary file: + +```powershell +uloop execute-dynamic-code --code @' +using UnityEngine; +using UnityEngine.SceneManagement; + +Scene scene = SceneManager.GetActiveScene(); +GameObject[] objects = UnityEngine.Object.FindObjectsByType(FindObjectsInactive.Include, FindObjectsSortMode.None); +return $"{scene.name}: {objects.Length} objects"; +'@ +``` + +Use `--code-file` when the active shell or launcher cannot preserve inline code exactly, especially for Windows PowerShell 5.1 snippets with many C# string literals. ### Native launcher check -Multi-line `--code` expects PowerShell to call the native `uloop.exe` launcher directly. -If `Get-Command uloop` resolves to an old npm `.cmd` shim, run `uloop install` and open a new terminal before relying on multi-line inline snippets. +Multi-line `--code` expects PowerShell to call the native Go `uloop.exe` launcher directly. +If `Get-Command uloop` resolves to an old `.cmd` shim from a previous installation, run `uloop install` and open a new terminal before relying on multi-line inline snippets. ```powershell (Get-Command uloop).Source @@ -58,9 +73,9 @@ If the C# snippet itself contains a single quote, double it inside the PowerShel uloop execute-dynamic-code --code 'char initial = ''A''; return initial.ToString();' ``` -### JSON-like values passed via `--parameters` +### JSON object values passed via `--parameters` -Wrap the whole expression in single quotes so PowerShell passes the inner double quotes through unchanged. +Pass a JSON object literal, not a JSON string value. Wrap the object literal in single quotes so PowerShell passes the inner double quotes through unchanged. ```powershell uloop execute-dynamic-code --code 'return parameters["param0"];' --parameters '{"param0":"Hello from PowerShell"}' @@ -68,7 +83,7 @@ uloop execute-dynamic-code --code 'return parameters["param0"];' --parameters '{ ### Multi-line C# snippets -Use a here-string when the snippet spans multiple lines in PowerShell 7 (`pwsh`). +Use a here-string variable when you want to prepare or reuse a snippet before executing it in PowerShell 7 (`pwsh`). ```powershell $code = @' @@ -98,7 +113,7 @@ return obj.name; uloop execute-dynamic-code --code $code ``` -You can combine multi-line code with multi-line parameters the same way. +You can combine multi-line code with a multi-line JSON object literal the same way. ```powershell $code = @' diff --git a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Skill/SKILL.md b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Skill/SKILL.md index 9bea37081b..e237a67a7c 100644 --- a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Skill/SKILL.md +++ b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Skill/SKILL.md @@ -25,8 +25,8 @@ This tool can inspect reachable Unity state, such as GameObjects, components, pu - `--code ''`: Inline C# statements to execute. Use direct statements only; `return` is optional, and `using` directives may appear at the top of the snippet. - `--code-file `: Read the C# statements from a file instead of `--code`. Use this when the active shell or launcher cannot preserve inline code exactly. Exactly one of `--code` or `--code-file` is required; combining them is an error. -- **Shell quoting**: bash/zsh uses single quotes, for example `uloop execute-dynamic-code --code 'using UnityEngine; return Mathf.PI;'`. PowerShell 7 (`pwsh`) preserves C# double quotes inside single-quoted strings. Windows PowerShell 5.1 removes unescaped double quotes when invoking native commands; escape C# double quotes as `\"` there, or use `--code-file` when the snippet has many strings. -- `--parameters {}` (advanced, optional): Pass an object when reusing a snippet with varying data or when keeping values outside the code. Values are exposed as `parameters["param0"]`, `parameters["param1"]`, and so on. Omit this flag for most snippets, and pass an object instead of a JSON string. +- **Shell quoting**: bash/zsh uses single quotes, for example `uloop execute-dynamic-code --code 'using UnityEngine; return Mathf.PI;'`. PowerShell 7 (`pwsh`) can pass multiline snippets without `--code-file` by using a single-quoted here-string, for example `$code = @' ... '@; uloop execute-dynamic-code --code $code`. Windows PowerShell 5.1 removes unescaped double quotes when invoking native commands; escape C# double quotes as `\"` for short inline snippets, or use `--code-file` when the snippet has many strings. +- `--parameters {}` (advanced, optional): Pass a shell-quoted JSON object literal when reusing a snippet with varying data or when keeping values outside the code. Values are exposed as `parameters["param0"]`, `parameters["param1"]`, and so on. Omit this flag for most snippets. Do not pass a JSON string value such as `"{\"param0\":\"value\"}"`. - `--wait-for-domain-reload` (optional): Wait for Domain Reload recovery after snippets that intentionally trigger Unity script reload or import work. Omit this for normal inspection and editor-state workflows. ## Code Rules diff --git a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Skill/references/playmode-automation-powershell.md b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Skill/references/playmode-automation-powershell.md index a3b4ae84c5..fe39803099 100644 --- a/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Skill/references/playmode-automation-powershell.md +++ b/Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Skill/references/playmode-automation-powershell.md @@ -24,12 +24,27 @@ Use `execute-dynamic-code` for direct automation and diagnostics, and switch to ## PowerShell Quoting Notes -Use these patterns when you need shell-safe inline code: +Use these patterns when you need shell-safe inline code. +PowerShell's equivalent to a bash heredoc is a single-quoted here-string. +In PowerShell 7 (`pwsh`), it can be passed to `--code` directly without creating a temporary file: + +```powershell +uloop execute-dynamic-code --code @' +using UnityEngine; +using UnityEngine.SceneManagement; + +Scene scene = SceneManager.GetActiveScene(); +GameObject[] objects = UnityEngine.Object.FindObjectsByType(FindObjectsInactive.Include, FindObjectsSortMode.None); +return $"{scene.name}: {objects.Length} objects"; +'@ +``` + +Use `--code-file` when the active shell or launcher cannot preserve inline code exactly, especially for Windows PowerShell 5.1 snippets with many C# string literals. ### Native launcher check -Multi-line `--code` expects PowerShell to call the native `uloop.exe` launcher directly. -If `Get-Command uloop` resolves to an old npm `.cmd` shim, run `uloop install` and open a new terminal before relying on multi-line inline snippets. +Multi-line `--code` expects PowerShell to call the native Go `uloop.exe` launcher directly. +If `Get-Command uloop` resolves to an old `.cmd` shim from a previous installation, run `uloop install` and open a new terminal before relying on multi-line inline snippets. ```powershell (Get-Command uloop).Source @@ -58,9 +73,9 @@ If the C# snippet itself contains a single quote, double it inside the PowerShel uloop execute-dynamic-code --code 'char initial = ''A''; return initial.ToString();' ``` -### JSON-like values passed via `--parameters` +### JSON object values passed via `--parameters` -Wrap the whole expression in single quotes so PowerShell passes the inner double quotes through unchanged. +Pass a JSON object literal, not a JSON string value. Wrap the object literal in single quotes so PowerShell passes the inner double quotes through unchanged. ```powershell uloop execute-dynamic-code --code 'return parameters["param0"];' --parameters '{"param0":"Hello from PowerShell"}' @@ -68,7 +83,7 @@ uloop execute-dynamic-code --code 'return parameters["param0"];' --parameters '{ ### Multi-line C# snippets -Use a here-string when the snippet spans multiple lines in PowerShell 7 (`pwsh`). +Use a here-string variable when you want to prepare or reuse a snippet before executing it in PowerShell 7 (`pwsh`). ```powershell $code = @' @@ -98,7 +113,7 @@ return obj.name; uloop execute-dynamic-code --code $code ``` -You can combine multi-line code with multi-line parameters the same way. +You can combine multi-line code with a multi-line JSON object literal the same way. ```powershell $code = @'