Files
install-sh/install-graphify.ps1
T

155 lines
6.1 KiB
PowerShell

<#
.SYNOPSIS
graphify install and vibe coding agent integration script for Windows PowerShell.
.DESCRIPTION
Installs graphify via Astral uv tool and sets up agent integrations
(Antigravity, Claude, Codex, OpenCode) along with Gemini MCP configuration.
.NOTES
Author: mcchae
#>
[CmdletBinding()]
param()
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
# Enforce TLS 1.2+ for HTTPS downloads
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# ────────────────────────────────────────────
# Utility functions (English only to prevent Windows console encoding issues)
# ────────────────────────────────────────────
function Info { Write-Host "[INFO] $args" -ForegroundColor Cyan }
function Warn { Write-Host "[WARN] $args" -ForegroundColor Yellow }
function Success { Write-Host "[OK] $args" -ForegroundColor Green }
function ErrExit { Write-Host "[ERROR] $args" -ForegroundColor Red; exit 1 }
# ────────────────────────────────────────────
# Check uv prerequisite
# ────────────────────────────────────────────
function Check-Requirements {
$uvCmd = Get-Command uv -ErrorAction SilentlyContinue
if (-not $uvCmd) {
Write-Host ""
Write-Host "=================================================================" -ForegroundColor Red
Write-Host "[ERROR] 'uv' package manager is not installed or not in PATH." -ForegroundColor Red
Write-Host "graphify requires 'uv' to be installed first." -ForegroundColor Yellow
Write-Host "Please install uv using the following command:" -ForegroundColor Yellow
Write-Host ""
Write-Host " powershell -ExecutionPolicy ByPass -c `"irm https://astral.sh/uv/install.ps1 | iex`"" -ForegroundColor White
Write-Host "=================================================================" -ForegroundColor Red
Write-Host ""
exit 1
}
}
# ────────────────────────────────────────────
# Gemini MCP configuration
# ────────────────────────────────────────────
function Configure-GeminiMcp {
$geminiDir = Join-Path $env:USERPROFILE ".gemini\antigravity"
$configFile = Join-Path $geminiDir "mcp_config.json"
if (-not (Test-Path $geminiDir)) {
New-Item -ItemType Directory -Path $geminiDir -Force | Out-Null
}
Info "Configuring Gemini MCP config at: $configFile"
$graphifyEntry = @{
command = "uv"
args = @(
"run",
"--with",
"graphifyy",
"--with",
"mcp",
"-m",
"graphify.serve",
"`${workspace.path}/graphify-out/graph.json"
)
}
$data = @{}
if (Test-Path $configFile) {
try {
$rawContent = Get-Content -Path $configFile -Raw -Encoding UTF8
$trimmed = $rawContent.Trim()
if ($trimmed.StartsWith('{') -and $trimmed.EndsWith('}')) {
$parsed = $trimmed | ConvertFrom-Json
# Convert PSCustomObject to hashtable
if ($parsed -ne $null) {
foreach ($prop in $parsed.PSObject.Properties) {
$data[$prop.Name] = $prop.Value
}
}
}
} catch {
Warn "Could not parse existing $configFile. Creating fresh configuration."
$data = @{}
}
}
if ($data.ContainsKey("mcpServers") -and ($data["mcpServers"] -is [System.Collections.IDictionary] -or $data["mcpServers"] -is [PSCustomObject])) {
$data["mcpServers"].graphify = $graphifyEntry
} else {
$data["graphify"] = $graphifyEntry
}
$jsonOutput = $data | ConvertTo-Json -Depth 10
Set-Content -Path $configFile -Value $jsonOutput -Encoding UTF8
Success "Gemini MCP configuration updated successfully: $configFile"
}
# ────────────────────────────────────────────
# Main Entry Point
# ────────────────────────────────────────────
function Main {
Info "===== Graphify install script (Windows PowerShell) ====="
# 1. Prerequisite check
Check-Requirements
Success "Prerequisite 'uv' found."
# 2. Install graphifyy using uv tool
Info "Installing/upgrading 'graphifyy[pdf,openai,anthropic,gemini]' via uv tool..."
uv tool install --upgrade "graphifyy[pdf,openai,anthropic,gemini]"
if ($LASTEXITCODE -ne 0) {
ErrExit "Failed to install graphifyy via uv tool."
}
Success "graphifyy installed successfully."
# 3. Agent integrations
$agents = @("antigravity", "claude", "codex", "opencode")
foreach ($agent in $agents) {
Info "Configuring agent integration: graphify $agent install"
try {
& uv tool run --from graphifyy graphify $agent install
if ($LASTEXITCODE -eq 0) {
Success "Agent '$agent' integration completed."
} else {
Warn "Agent '$agent' integration returned non-zero code ($LASTEXITCODE). Continuing..."
}
} catch {
Warn "Failed to configure agent '$agent': $_"
}
}
# 4. Configure Gemini MCP
Configure-GeminiMcp
Write-Host ""
Success "===== Graphify installation and agent setup completed successfully! ====="
Info "Getting started:"
Info " 1. Build code graph: graphify ."
Info " 2. Query codebase: graphify query `"Explain project structure`""
Info " 3. Find paths: graphify path `"ClassA`" `"ClassB`""
Info " 4. Explain node: graphify explain `"AuthManager`""
Write-Host ""
}
Main