mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-15 13:03:46 +00:00
feat: gigacode (#92)
This commit is contained in:
parent
0a73d1d8e8
commit
a02393436c
40 changed files with 2736 additions and 1327 deletions
|
|
@ -35,6 +35,12 @@ export async function promoteArtifacts(opts: ReleaseOpts) {
|
|||
if (opts.latest) {
|
||||
await uploadInstallScripts(opts, "latest");
|
||||
}
|
||||
|
||||
// Upload gigacode install scripts
|
||||
await uploadGigacodeInstallScripts(opts, opts.version);
|
||||
if (opts.latest) {
|
||||
await uploadGigacodeInstallScripts(opts, "latest");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -55,6 +61,23 @@ async function uploadInstallScripts(opts: ReleaseOpts, version: string) {
|
|||
}
|
||||
}
|
||||
|
||||
async function uploadGigacodeInstallScripts(opts: ReleaseOpts, version: string) {
|
||||
const installScriptPaths = [
|
||||
path.resolve(opts.root, "scripts/release/static/gigacode-install.sh"),
|
||||
path.resolve(opts.root, "scripts/release/static/gigacode-install.ps1"),
|
||||
];
|
||||
|
||||
for (const scriptPath of installScriptPaths) {
|
||||
let scriptContent = await fs.readFile(scriptPath, "utf-8");
|
||||
scriptContent = scriptContent.replace(/__VERSION__/g, version);
|
||||
|
||||
const uploadKey = `${PREFIX}/${version}/${scriptPath.split("/").pop() ?? ""}`;
|
||||
|
||||
console.log(`Uploading gigacode install script: ${uploadKey}`);
|
||||
await uploadContentToReleases(scriptContent, uploadKey);
|
||||
}
|
||||
}
|
||||
|
||||
async function copyPath(sourcePrefix: string, targetPrefix: string) {
|
||||
console.log(`Copying ${sourcePrefix} -> ${targetPrefix}`);
|
||||
await deleteReleasesPath(targetPrefix);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ const CRATES = [
|
|||
"universal-agent-schema",
|
||||
"agent-management",
|
||||
"sandbox-agent",
|
||||
"gigacode",
|
||||
] as const;
|
||||
|
||||
// NPM CLI packages
|
||||
|
|
@ -22,15 +23,69 @@ const CLI_PACKAGES = [
|
|||
"@sandbox-agent/cli-win32-x64",
|
||||
"@sandbox-agent/cli-darwin-x64",
|
||||
"@sandbox-agent/cli-darwin-arm64",
|
||||
"gigacode",
|
||||
"gigacode-linux-x64",
|
||||
"gigacode-linux-arm64",
|
||||
"gigacode-win32-x64",
|
||||
"gigacode-darwin-x64",
|
||||
"gigacode-darwin-arm64",
|
||||
] as const;
|
||||
|
||||
// Mapping from npm package name to Rust target and binary extension
|
||||
const CLI_PLATFORM_MAP: Record<string, { target: string; binaryExt: string }> = {
|
||||
"@sandbox-agent/cli-linux-x64": { target: "x86_64-unknown-linux-musl", binaryExt: "" },
|
||||
"@sandbox-agent/cli-linux-arm64": { target: "aarch64-unknown-linux-musl", binaryExt: "" },
|
||||
"@sandbox-agent/cli-win32-x64": { target: "x86_64-pc-windows-gnu", binaryExt: ".exe" },
|
||||
"@sandbox-agent/cli-darwin-x64": { target: "x86_64-apple-darwin", binaryExt: "" },
|
||||
"@sandbox-agent/cli-darwin-arm64": { target: "aarch64-apple-darwin", binaryExt: "" },
|
||||
const CLI_PLATFORM_MAP: Record<
|
||||
string,
|
||||
{ target: string; binaryExt: string; binaryName: string }
|
||||
> = {
|
||||
"@sandbox-agent/cli-linux-x64": {
|
||||
target: "x86_64-unknown-linux-musl",
|
||||
binaryExt: "",
|
||||
binaryName: "sandbox-agent",
|
||||
},
|
||||
"@sandbox-agent/cli-linux-arm64": {
|
||||
target: "aarch64-unknown-linux-musl",
|
||||
binaryExt: "",
|
||||
binaryName: "sandbox-agent",
|
||||
},
|
||||
"@sandbox-agent/cli-win32-x64": {
|
||||
target: "x86_64-pc-windows-gnu",
|
||||
binaryExt: ".exe",
|
||||
binaryName: "sandbox-agent",
|
||||
},
|
||||
"@sandbox-agent/cli-darwin-x64": {
|
||||
target: "x86_64-apple-darwin",
|
||||
binaryExt: "",
|
||||
binaryName: "sandbox-agent",
|
||||
},
|
||||
"@sandbox-agent/cli-darwin-arm64": {
|
||||
target: "aarch64-apple-darwin",
|
||||
binaryExt: "",
|
||||
binaryName: "sandbox-agent",
|
||||
},
|
||||
"gigacode-linux-x64": {
|
||||
target: "x86_64-unknown-linux-musl",
|
||||
binaryExt: "",
|
||||
binaryName: "gigacode",
|
||||
},
|
||||
"gigacode-linux-arm64": {
|
||||
target: "aarch64-unknown-linux-musl",
|
||||
binaryExt: "",
|
||||
binaryName: "gigacode",
|
||||
},
|
||||
"gigacode-win32-x64": {
|
||||
target: "x86_64-pc-windows-gnu",
|
||||
binaryExt: ".exe",
|
||||
binaryName: "gigacode",
|
||||
},
|
||||
"gigacode-darwin-x64": {
|
||||
target: "x86_64-apple-darwin",
|
||||
binaryExt: "",
|
||||
binaryName: "gigacode",
|
||||
},
|
||||
"gigacode-darwin-arm64": {
|
||||
target: "aarch64-apple-darwin",
|
||||
binaryExt: "",
|
||||
binaryName: "gigacode",
|
||||
},
|
||||
};
|
||||
|
||||
async function npmVersionExists(
|
||||
|
|
@ -246,33 +301,41 @@ export async function publishNpmCli(opts: ReleaseOpts) {
|
|||
let packagePath: string;
|
||||
if (packageName === "@sandbox-agent/cli") {
|
||||
packagePath = join(opts.root, "sdks/cli");
|
||||
} else {
|
||||
} else if (packageName === "gigacode") {
|
||||
packagePath = join(opts.root, "sdks/gigacode");
|
||||
} else if (packageName.startsWith("@sandbox-agent/cli-")) {
|
||||
// Platform-specific packages: @sandbox-agent/cli-linux-x64 -> sdks/cli/platforms/linux-x64
|
||||
const platform = packageName.replace("@sandbox-agent/cli-", "");
|
||||
packagePath = join(opts.root, "sdks/cli/platforms", platform);
|
||||
} else if (packageName.startsWith("gigacode-")) {
|
||||
// Platform-specific packages: gigacode-linux-x64 -> sdks/gigacode/platforms/linux-x64
|
||||
const platform = packageName.replace("gigacode-", "");
|
||||
packagePath = join(opts.root, "sdks/gigacode/platforms", platform);
|
||||
} else {
|
||||
throw new Error(`Unknown CLI package: ${packageName}`);
|
||||
}
|
||||
|
||||
// Download binary from R2 for platform-specific packages
|
||||
const platformInfo = CLI_PLATFORM_MAP[packageName];
|
||||
if (platformInfo) {
|
||||
const binDir = join(packagePath, "bin");
|
||||
const binaryName = `sandbox-agent${platformInfo.binaryExt}`;
|
||||
const localBinaryPath = join(binDir, binaryName);
|
||||
const remoteBinaryPath = `${PREFIX}/${sourceCommit}/binaries/sandbox-agent-${platformInfo.target}${platformInfo.binaryExt}`;
|
||||
// Download binary from R2 for platform-specific packages
|
||||
const platformInfo = CLI_PLATFORM_MAP[packageName];
|
||||
if (platformInfo) {
|
||||
const binDir = join(packagePath, "bin");
|
||||
const binaryName = `${platformInfo.binaryName}${platformInfo.binaryExt}`;
|
||||
const localBinaryPath = join(binDir, binaryName);
|
||||
const remoteBinaryPath = `${PREFIX}/${sourceCommit}/binaries/${platformInfo.binaryName}-${platformInfo.target}${platformInfo.binaryExt}`;
|
||||
|
||||
console.log(`==> Downloading binary for ${packageName}`);
|
||||
console.log(` From: ${remoteBinaryPath}`);
|
||||
console.log(` To: ${localBinaryPath}`);
|
||||
console.log(`==> Downloading binary for ${packageName}`);
|
||||
console.log(` From: ${remoteBinaryPath}`);
|
||||
console.log(` To: ${localBinaryPath}`);
|
||||
|
||||
// Create bin directory
|
||||
await fs.mkdir(binDir, { recursive: true });
|
||||
// Create bin directory
|
||||
await fs.mkdir(binDir, { recursive: true });
|
||||
|
||||
// Download binary
|
||||
await downloadFromReleases(remoteBinaryPath, localBinaryPath);
|
||||
// Download binary
|
||||
await downloadFromReleases(remoteBinaryPath, localBinaryPath);
|
||||
|
||||
// Make binary executable (not needed on Windows)
|
||||
if (!platformInfo.binaryExt) {
|
||||
await fs.chmod(localBinaryPath, 0o755);
|
||||
}
|
||||
// Make binary executable (not needed on Windows)
|
||||
if (!platformInfo.binaryExt) {
|
||||
await fs.chmod(localBinaryPath, 0o755);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
51
scripts/release/static/gigacode-install.ps1
Normal file
51
scripts/release/static/gigacode-install.ps1
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#!/usr/bin/env pwsh
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
|
||||
# Create bin directory for gigacode
|
||||
$BinDir = $env:BIN_DIR
|
||||
$GigacodeInstall = if ($BinDir) {
|
||||
$BinDir
|
||||
} else {
|
||||
"${Home}\.gigacode\bin"
|
||||
}
|
||||
|
||||
if (!(Test-Path $GigacodeInstall)) {
|
||||
New-Item $GigacodeInstall -ItemType Directory | Out-Null
|
||||
}
|
||||
|
||||
$GigacodeExe = "$GigacodeInstall\gigacode.exe"
|
||||
$Version = '__VERSION__'
|
||||
$FileName = 'gigacode-x86_64-pc-windows-gnu.exe'
|
||||
|
||||
Write-Host
|
||||
Write-Host "> Installing gigacode ${Version}"
|
||||
|
||||
# Download binary
|
||||
$DownloadUrl = "https://releases.rivet.dev/sandbox-agent/${Version}/binaries/${FileName}"
|
||||
Write-Host
|
||||
Write-Host "> Downloading ${DownloadUrl}"
|
||||
Invoke-WebRequest $DownloadUrl -OutFile $GigacodeExe -UseBasicParsing
|
||||
|
||||
# Install to PATH
|
||||
Write-Host
|
||||
Write-Host "> Installing gigacode"
|
||||
$User = [System.EnvironmentVariableTarget]::User
|
||||
$Path = [System.Environment]::GetEnvironmentVariable('Path', $User)
|
||||
if (!(";${Path};".ToLower() -like "*;${GigacodeInstall};*".ToLower())) {
|
||||
[System.Environment]::SetEnvironmentVariable('Path', "${Path};${GigacodeInstall}", $User)
|
||||
$Env:Path += ";${GigacodeInstall}"
|
||||
Write-Host "Please restart your PowerShell session or run the following command to refresh the environment variables:"
|
||||
Write-Host "[System.Environment]::SetEnvironmentVariable('Path', '${Path};${GigacodeInstall}', [System.EnvironmentVariableTarget]::Process)"
|
||||
}
|
||||
|
||||
Write-Host
|
||||
Write-Host "> Checking installation"
|
||||
gigacode.exe --version
|
||||
|
||||
Write-Host
|
||||
Write-Host "gigacode was installed successfully to ${GigacodeExe}."
|
||||
Write-Host "Run 'gigacode --help' to get started."
|
||||
Write-Host
|
||||
103
scripts/release/static/gigacode-install.sh
Normal file
103
scripts/release/static/gigacode-install.sh
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
#!/bin/sh
|
||||
# shellcheck enable=add-default-case
|
||||
# shellcheck enable=avoid-nullary-conditions
|
||||
# shellcheck enable=check-unassigned-uppercase
|
||||
# shellcheck enable=deprecate-which
|
||||
# shellcheck enable=quote-safe-variables
|
||||
# shellcheck enable=require-variable-braces
|
||||
set -eu
|
||||
|
||||
rm -rf /tmp/gigacode_install
|
||||
mkdir /tmp/gigacode_install
|
||||
cd /tmp/gigacode_install
|
||||
|
||||
GIGACODE_VERSION="${GIGACODE_VERSION:-__VERSION__}"
|
||||
UNAME="$(uname -s)"
|
||||
ARCH="$(uname -m)"
|
||||
|
||||
# Find asset suffix
|
||||
if [ "$(printf '%s' "$UNAME" | cut -c 1-6)" = "Darwin" ]; then
|
||||
echo
|
||||
echo "> Detected macOS"
|
||||
|
||||
if [ "$ARCH" = "x86_64" ]; then
|
||||
FILE_NAME="gigacode-x86_64-apple-darwin"
|
||||
elif [ "$ARCH" = "arm64" ]; then
|
||||
FILE_NAME="gigacode-aarch64-apple-darwin"
|
||||
else
|
||||
echo "Unknown arch $ARCH" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
elif [ "$(printf '%s' "$UNAME" | cut -c 1-5)" = "Linux" ]; then
|
||||
echo
|
||||
echo "> Detected Linux ($(getconf LONG_BIT) bit)"
|
||||
|
||||
FILE_NAME="gigacode-x86_64-unknown-linux-musl"
|
||||
else
|
||||
echo "Unable to determine platform" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Determine install location
|
||||
set +u
|
||||
if [ -z "$BIN_DIR" ]; then
|
||||
BIN_DIR="/usr/local/bin"
|
||||
fi
|
||||
set -u
|
||||
INSTALL_PATH="$BIN_DIR/gigacode"
|
||||
|
||||
if [ ! -d "$BIN_DIR" ]; then
|
||||
# Find the base parent directory. We're using mkdir -p, which recursively creates directories, so we can't rely on `dirname`.
|
||||
CHECK_DIR="$BIN_DIR"
|
||||
while [ ! -d "$CHECK_DIR" ] && [ "$CHECK_DIR" != "/" ]; do
|
||||
CHECK_DIR=$(dirname "$CHECK_DIR")
|
||||
done
|
||||
|
||||
# Check if the directory is writable
|
||||
if [ ! -w "$CHECK_DIR" ]; then
|
||||
echo
|
||||
echo "> Creating directory $BIN_DIR (requires sudo)"
|
||||
sudo mkdir -p "$BIN_DIR"
|
||||
else
|
||||
echo
|
||||
echo "> Creating directory $BIN_DIR"
|
||||
mkdir -p "$BIN_DIR"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# Download binary
|
||||
URL="https://releases.rivet.dev/sandbox-agent/${GIGACODE_VERSION}/binaries/${FILE_NAME}"
|
||||
echo
|
||||
echo "> Downloading $URL"
|
||||
curl -fsSL "$URL" -o gigacode
|
||||
chmod +x gigacode
|
||||
|
||||
# Move binary
|
||||
if [ ! -w "$BIN_DIR" ]; then
|
||||
echo
|
||||
echo "> Installing gigacode to $INSTALL_PATH (requires sudo)"
|
||||
sudo mv ./gigacode "$INSTALL_PATH"
|
||||
else
|
||||
echo
|
||||
echo "> Installing gigacode to $INSTALL_PATH"
|
||||
mv ./gigacode "$INSTALL_PATH"
|
||||
fi
|
||||
|
||||
# Check if path may be incorrect
|
||||
case ":$PATH:" in
|
||||
*:$BIN_DIR:*) ;;
|
||||
*)
|
||||
echo "WARNING: $BIN_DIR is not in \$PATH"
|
||||
echo "For instructions on how to add it to your PATH, visit:"
|
||||
echo "https://opensource.com/article/17/6/set-path-linux"
|
||||
;;
|
||||
esac
|
||||
|
||||
echo
|
||||
echo "> Checking installation"
|
||||
"$BIN_DIR/gigacode" --version
|
||||
|
||||
echo
|
||||
echo "gigacode was installed successfully."
|
||||
echo "Run 'gigacode --help' to get started."
|
||||
|
|
@ -32,11 +32,21 @@ export async function updateVersion(opts: ReleaseOpts) {
|
|||
find: /"version": ".*"/,
|
||||
replace: `"version": "${opts.version}"`,
|
||||
},
|
||||
{
|
||||
path: "sdks/gigacode/package.json",
|
||||
find: /"version": ".*"/,
|
||||
replace: `"version": "${opts.version}"`,
|
||||
},
|
||||
{
|
||||
path: "sdks/cli/platforms/*/package.json",
|
||||
find: /"version": ".*"/,
|
||||
replace: `"version": "${opts.version}"`,
|
||||
},
|
||||
{
|
||||
path: "sdks/gigacode/platforms/*/package.json",
|
||||
find: /"version": ".*"/,
|
||||
replace: `"version": "${opts.version}"`,
|
||||
},
|
||||
];
|
||||
|
||||
// Update internal crate versions in workspace dependencies
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue