Skip to content

Instantly share code, notes, and snippets.

@renanliberato
Last active October 9, 2025 13:30
Show Gist options
  • Select an option

  • Save renanliberato/02a4921c9dfe7efc5b7a32bd11e76845 to your computer and use it in GitHub Desktop.

Select an option

Save renanliberato/02a4921c9dfe7efc5b7a32bd11e76845 to your computer and use it in GitHub Desktop.
#!/bin/zsh
if [ $# -lt 1 ]; then
echo "Usage: $0 <script_path> [method1 method2 ...]"
echo "If no methods are provided, members (properties and methods) will be retrieved automatically using opencode."
echo "Example: $0 Assets/Class.cs"
echo "Or with specific methods: $0 Assets/Class.cs method1 method2"
exit 1
fi
script_path="$1"
# Check if the provided path is just a filename (no directory separators)
if [[ "$script_path" != *"/"* ]]; then
# Search for the file recursively in the current directory
found_file=$(find . -name "$script_path" -type f | head -n 1)
if [ -n "$found_file" ]; then
script_path="$found_file"
echo "Found file at: $script_path"
else
echo "Error: File '$script_path' not found in current directory or subdirectories"
exit 1
fi
fi
shift # Remove the first argument (script_path) from the argument list
if [ $# -eq 0 ]; then
echo "No methods provided. Retrieving members automatically..."
members=$(opencode run --model openrouter/x-ai/grok-code-fast-1 "list $script_path members separated by comma with no spaces. Just properties and methods")
if [ -z "$members" ] || [ "$members" = "No members found." ]; then
echo "Failed to retrieve members."
exit 1
fi
# Keep members together in a single variable
methods=$members
else
methods=($@)
fi
for method in $methods; do
opencode run "Implement @$script_path $method method strictly with what you find on Ghidra MCP. If you can't connect to Ghidra MCP, do a full stop. If you spot a dependency of this method (in this or another class) that's not implemented, do a method/property/field call as if it was implemented, add a comment '// TODO: validate dependency'. Never try to spawn another terminal or to run ./decompile.sh yourself."
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment