Add GSP init and AI usage tooling

This commit is contained in:
2026-05-06 19:40:55 +08:00
parent 67a1bf2600
commit 1478972e53
17 changed files with 870 additions and 8 deletions

View File

@@ -0,0 +1,38 @@
param(
[string]$InstallDir = "$HOME\.gsp\bin"
)
$ErrorActionPreference = "Stop"
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$ToolkitDir = Resolve-Path -LiteralPath (Join-Path $ScriptDir "..")
$TargetDir = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($InstallDir)
$TargetExe = Join-Path $TargetDir "gsp.exe"
New-Item -ItemType Directory -Force -Path $TargetDir | Out-Null
Push-Location $ToolkitDir
try {
go build -o $TargetExe .\cmd\gsp
}
finally {
Pop-Location
}
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
$parts = @()
if ($userPath) {
$parts = $userPath -split ";" | Where-Object { $_ -ne "" }
}
if ($parts -notcontains $TargetDir) {
$newPath = (($parts + $TargetDir) -join ";")
[Environment]::SetEnvironmentVariable("Path", $newPath, "User")
Write-Host "Installed gsp to $TargetExe"
Write-Host "Added $TargetDir to the user PATH. Open a new terminal before running gsp."
}
else {
Write-Host "Installed gsp to $TargetExe"
}
& $TargetExe version

View File

@@ -0,0 +1,27 @@
#!/usr/bin/env sh
set -eu
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
TOOLKIT_DIR=$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd)
INSTALL_DIR=${GSP_INSTALL_DIR:-"$HOME/.gsp/bin"}
TARGET="$INSTALL_DIR/gsp"
mkdir -p "$INSTALL_DIR"
(
cd "$TOOLKIT_DIR"
go build -o "$TARGET" ./cmd/gsp
)
chmod +x "$TARGET"
echo "Installed gsp to $TARGET"
case ":$PATH:" in
*":$INSTALL_DIR:"*) ;;
*)
echo "Add this to your shell profile if gsp is not found:"
echo "export PATH=\"$INSTALL_DIR:\$PATH\""
;;
esac
"$TARGET" version