mirror of
https://github.com/hansjone/netxops.git
synced 2026-10-09 03:53:15 +08:00
Auto-install the Netx Ops agent preset on plugin activate.
Copy presets into ~/.dsh/.agent-presets (not a Windows junction — DSH discovery skips those) so dsh plugin add alone surfaces Custom → Netx Ops with skills. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
4854101afd
commit
5179eb74b1
9 changed files with 174 additions and 82 deletions
|
|
@ -1,4 +1,6 @@
|
|||
# Link presets/netxops into the DSH user agent-presets root (Windows junction).
|
||||
# Link / install presets/netxops into the DSH user agent-presets root.
|
||||
# Prefer a real directory copy: DSH discovery skips Windows junctions
|
||||
# (Dirent.isDirectory() is false for reparse points).
|
||||
$ErrorActionPreference = "Stop"
|
||||
$RepoRoot = Split-Path -Parent $PSScriptRoot
|
||||
$Source = Join-Path $RepoRoot "presets\netxops"
|
||||
|
|
@ -6,18 +8,14 @@ $DshHome = if ($env:DSH_HOME) { $env:DSH_HOME } else { Join-Path $env:USERPROFIL
|
|||
$TargetParent = Join-Path $DshHome ".agent-presets"
|
||||
$Target = Join-Path $TargetParent "netxops"
|
||||
|
||||
if (-not (Test-Path $Source)) {
|
||||
if (-not (Test-Path (Join-Path $Source "agent.cordis.yml"))) {
|
||||
throw "Missing preset dir: $Source"
|
||||
}
|
||||
New-Item -ItemType Directory -Force -Path $TargetParent | Out-Null
|
||||
if (Test-Path $Target) {
|
||||
$item = Get-Item $Target -Force
|
||||
if ($item.Attributes -band [IO.FileAttributes]::ReparsePoint) {
|
||||
cmd /c "rmdir `"$Target`""
|
||||
} else {
|
||||
throw "Target exists and is not a junction: $Target — remove or rename it first."
|
||||
}
|
||||
Remove-Item -Recurse -Force $Target
|
||||
}
|
||||
cmd /c "mklink /J `"$Target`" `"$Source`""
|
||||
Write-Host "Linked $Target -> $Source"
|
||||
Write-Host "Restart dsh / open a new session and select preset 'netxops' (Netx Ops)."
|
||||
Copy-Item -Recurse -Force $Source $Target
|
||||
Set-Content -Path (Join-Path $Target ".dsh-netxops-managed") -Value ((Get-Date).ToString("o"))
|
||||
Write-Host "Installed $Target (copy from $Source)"
|
||||
Write-Host "Open Settings → Agent presets → Custom → Netx Ops (or new session)."
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
#!/usr/bin/env bash
|
||||
# Install presets/netxops into $DSH_HOME/.agent-presets (copy, not symlink).
|
||||
set -euo pipefail
|
||||
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
SOURCE="$REPO_ROOT/presets/netxops"
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
SRC="$ROOT/presets/netxops"
|
||||
DSH_HOME="${DSH_HOME:-$HOME/.dsh}"
|
||||
TARGET_PARENT="$DSH_HOME/.agent-presets"
|
||||
TARGET="$TARGET_PARENT/netxops"
|
||||
DEST_PARENT="$DSH_HOME/.agent-presets"
|
||||
DEST="$DEST_PARENT/netxops"
|
||||
|
||||
if [[ ! -d "$SOURCE" ]]; then
|
||||
echo "Missing preset dir: $SOURCE" >&2
|
||||
if [[ ! -f "$SRC/agent.cordis.yml" ]]; then
|
||||
echo "Missing preset dir: $SRC" >&2
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p "$TARGET_PARENT"
|
||||
if [[ -e "$TARGET" || -L "$TARGET" ]]; then
|
||||
rm -rf "$TARGET"
|
||||
fi
|
||||
ln -s "$SOURCE" "$TARGET"
|
||||
echo "Linked $TARGET -> $SOURCE"
|
||||
echo "Restart dsh / open a new session and select preset 'netxops' (Netx Ops)."
|
||||
mkdir -p "$DEST_PARENT"
|
||||
rm -rf "$DEST"
|
||||
cp -R "$SRC" "$DEST"
|
||||
date -u +%Y-%m-%dT%H:%M:%SZ > "$DEST/.dsh-netxops-managed"
|
||||
echo "Installed $DEST"
|
||||
echo "Open Settings → Agent presets → Custom → Netx Ops"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue