Files
broodcicada-glitch 7154ed7fa5 Add Cursor generator plugin with slash commands and installers. (#417)
Ship a first-class Cursor adaptation (commands, skill, rules, marketplace manifest, CI installer tests) and document generator vs Hub consumer install paths in README/README_CN.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-21 15:25:52 +08:00

59 lines
1.9 KiB
PowerShell

# Shared helpers for CLI-Anything Cursor plugin install/uninstall (PowerShell).
function Normalize-CliAnythingPathKey {
param([Parameter(Mandatory = $true)][string]$Path)
return $Path.Replace("/", "\").TrimEnd("\").ToLowerInvariant()
}
function Resolve-CliAnythingPluginsHome {
param(
[Parameter(Mandatory = $true)][string]$Raw,
[switch]$Create
)
if ([string]::IsNullOrWhiteSpace($Raw) -or $Raw -eq "." -or $Raw -eq "..") {
throw "Invalid CURSOR_PLUGINS_HOME: $Raw"
}
if ($Raw.StartsWith("~")) {
$homePath = if ($env:USERPROFILE) { $env:USERPROFILE } else { $env:HOME }
$Raw = Join-Path $homePath $Raw.Substring(1).TrimStart("\", "/")
}
if (-not [System.IO.Path]::IsPathRooted($Raw)) {
$Raw = Join-Path (Get-Location).Path $Raw
}
# GetFullPath collapses ".." without creating the directory.
$full = [System.IO.Path]::GetFullPath($Raw)
$name = [System.IO.Path]::GetFileName($full.TrimEnd("\", "/"))
if ($name -ne "plugins") {
throw "CURSOR_PLUGINS_HOME must resolve to a directory named 'plugins' (got: $full)`nExample: $env:USERPROFILE\.cursor\plugins"
}
if ($Create) {
New-Item -ItemType Directory -Path $full -Force | Out-Null
}
return $full
}
function Test-CliAnythingInstallPath {
param([Parameter(Mandatory = $true)][string]$Path)
$key = Normalize-CliAnythingPathKey $Path
if (-not $key.EndsWith("\local\cli-anything")) {
return $false
}
return ([System.IO.Path]::GetFileName($key) -eq "cli-anything")
}
function Get-CliAnythingDiscoveryPointerPath {
$userCursor = if ($env:USERPROFILE) {
Join-Path $env:USERPROFILE ".cursor"
} elseif ($env:HOME) {
Join-Path $env:HOME ".cursor"
} else {
throw "USERPROFILE/HOME unavailable."
}
return (Join-Path $userCursor "cli-anything-generator.root")
}