Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(agent): generate C# bindings from Cody agent protocol #120

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions scripts/agent-bindings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

# Function to determine the operating system
get_os() {
case "$(uname -s)" in
Darwin*) echo "mac" ;;
MINGW* | CYGWIN* | MSYS*) echo "windows" ;;
*) echo "unknown" ;;
esac
}

# Get the current operating system
OS=$(get_os)

# Function to execute commands based on the OS
execute_command() {
if [ "$OS" = "windows" ]; then
powershell -Command "$1"
else
eval "$1"
fi
}

# Check if cody-dist directory exists
if [ ! -d "cody-dist" ]; then
echo "cody-dist directory not found. Cloning repository..."
execute_command "git clone https://github.com/sourcegraph/cody.git cody-dist"

else
echo "cody-dist directory found."
fi

echo "Installing dependencies and building..."
execute_command "cd cody-dist && pnpm install && cd agent && pnpm build && cd .."

# Navigate to cody-dist directory and run the ts-node command
execute_command "pnpm exec ts-node agent/src/cli/scip-codegen/command.ts --output \"agent/bindings/csharp\" --language \"csharp\" --kotlin-package \"Cody.Core.Agent.Protocol\""

# Navigate back to repo root
execute_command "cd .."

execute_command "pwd"

# Move files from cody-dist/agent/bindings/csharp to src/Cody.Core/Agent/Protocol
if [ "$OS" = "windows" ]; then
execute_command "Move-Item -Force cody-dist/agent/bindings/csharp/* src/Cody.Core/Agent/Protocol/"
else
execute_command "mv -f cody-dist/agent/bindings/csharp/* src/Cody.Core/Agent/Protocol/"
fi

echo "Script execution completed."
Loading