@geekbeer/minion 2.42.5 → 2.43.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,7 @@
6
6
  # Usage:
7
7
  # sudo minion-cli setup [options] # Set up minion agent service (root)
8
8
  # sudo minion-cli reconfigure [options] # Re-register with new HQ credentials (root)
9
+ # sudo minion-cli uninstall [--keep-data] # Remove agent and services (root)
9
10
  # sudo minion-cli start # Start agent service (root)
10
11
  # sudo minion-cli stop # Stop agent service (root)
11
12
  # sudo minion-cli restart # Restart agent service (root)
@@ -807,6 +808,167 @@ CFEOF
807
808
  fi
808
809
  }
809
810
 
811
+ # ============================================================
812
+ # uninstall subcommand
813
+ # ============================================================
814
+ do_uninstall() {
815
+ local KEEP_DATA=false
816
+
817
+ # Parse arguments
818
+ while [[ $# -gt 0 ]]; do
819
+ case "$1" in
820
+ --keep-data)
821
+ KEEP_DATA=true
822
+ shift
823
+ ;;
824
+ *)
825
+ echo "Unknown option: $1"
826
+ echo "Usage: sudo minion-cli uninstall [--keep-data]"
827
+ exit 1
828
+ ;;
829
+ esac
830
+ done
831
+
832
+ echo "========================================="
833
+ echo " @geekbeer/minion Uninstall"
834
+ echo "========================================="
835
+ echo ""
836
+ echo "This will remove the minion agent and all related services."
837
+ if [ "$KEEP_DATA" = true ]; then
838
+ echo " --keep-data: /opt/minion-agent/.env will be preserved."
839
+ else
840
+ echo " Config directory /opt/minion-agent/ will be deleted."
841
+ fi
842
+ echo ""
843
+ echo -n "Type 'yes' to continue: "
844
+ read -r CONFIRM
845
+ if [ "$CONFIRM" != "yes" ]; then
846
+ echo "Uninstall cancelled."
847
+ exit 0
848
+ fi
849
+ echo ""
850
+
851
+ local TOTAL_STEPS=5
852
+
853
+ # Step 1: Stop and disable services
854
+ echo "[1/${TOTAL_STEPS}] Stopping and disabling services..."
855
+ case "$PROC_MGR" in
856
+ systemd)
857
+ for svc in minion-agent tmux-init novnc vnc autocutsel fluxbox xvfb; do
858
+ if [ -f "/etc/systemd/system/${svc}.service" ]; then
859
+ $SUDO systemctl stop "$svc" 2>/dev/null || true
860
+ $SUDO systemctl disable "$svc" 2>/dev/null || true
861
+ $SUDO rm -f "/etc/systemd/system/${svc}.service"
862
+ echo " -> Removed ${svc}.service"
863
+ fi
864
+ done
865
+ $SUDO systemctl daemon-reload
866
+ ;;
867
+ supervisord)
868
+ for conf in minion-agent cloudflared; do
869
+ local CONF_FILE="/etc/supervisor/conf.d/${conf}.conf"
870
+ if [ -f "$CONF_FILE" ]; then
871
+ $SUDO supervisorctl stop "$conf" 2>/dev/null || true
872
+ $SUDO rm -f "$CONF_FILE"
873
+ echo " -> Removed ${conf}.conf"
874
+ fi
875
+ done
876
+ if $SUDO supervisorctl status &>/dev/null; then
877
+ $SUDO supervisorctl reread 2>/dev/null || true
878
+ $SUDO supervisorctl update 2>/dev/null || true
879
+ fi
880
+ ;;
881
+ *)
882
+ echo " -> No supported process manager found, skipping"
883
+ ;;
884
+ esac
885
+
886
+ # Step 2: Remove sudoers file
887
+ echo "[2/${TOTAL_STEPS}] Removing sudoers configuration..."
888
+ local SUDOERS_FILE="/etc/sudoers.d/minion-agent"
889
+ if [ -f "$SUDOERS_FILE" ]; then
890
+ $SUDO rm -f "$SUDOERS_FILE"
891
+ echo " -> Removed $SUDOERS_FILE"
892
+ else
893
+ echo " -> Not found, skipping"
894
+ fi
895
+
896
+ # Step 3: Remove config directory
897
+ echo "[3/${TOTAL_STEPS}] Removing config directory..."
898
+ if [ "$KEEP_DATA" = true ]; then
899
+ echo " -> Skipped (--keep-data)"
900
+ else
901
+ if [ -d /opt/minion-agent ]; then
902
+ $SUDO rm -rf /opt/minion-agent
903
+ echo " -> Removed /opt/minion-agent/"
904
+ else
905
+ echo " -> Not found, skipping"
906
+ fi
907
+ fi
908
+
909
+ # Step 4: Remove deployed skills and rules
910
+ echo "[4/${TOTAL_STEPS}] Removing deployed skills and rules..."
911
+
912
+ # Detect target user home (best-effort from existing service config)
913
+ local UNINSTALL_HOME="$TARGET_HOME"
914
+
915
+ local CLAUDE_SKILLS_DIR="${UNINSTALL_HOME}/.claude/skills"
916
+ local CLAUDE_RULES_DIR="${UNINSTALL_HOME}/.claude/rules"
917
+
918
+ # Remove bundled skills (only skills that ship with the package)
919
+ local NPM_ROOT
920
+ NPM_ROOT="$(npm root -g 2>/dev/null)" || true
921
+ local BUNDLED_SKILLS_DIR="${NPM_ROOT}/@geekbeer/minion/skills"
922
+
923
+ if [ -d "$BUNDLED_SKILLS_DIR" ] && [ -d "$CLAUDE_SKILLS_DIR" ]; then
924
+ for skill_dir in "$BUNDLED_SKILLS_DIR"/*/; do
925
+ if [ -d "$skill_dir" ]; then
926
+ local skill_name
927
+ skill_name=$(basename "$skill_dir")
928
+ if [ -d "${CLAUDE_SKILLS_DIR}/${skill_name}" ]; then
929
+ rm -rf "${CLAUDE_SKILLS_DIR}/${skill_name}"
930
+ echo " -> Removed skill: $skill_name"
931
+ fi
932
+ fi
933
+ done
934
+ else
935
+ echo " -> No bundled skills to remove"
936
+ fi
937
+
938
+ # Remove deployed rules
939
+ if [ -f "${CLAUDE_RULES_DIR}/core.md" ]; then
940
+ rm -f "${CLAUDE_RULES_DIR}/core.md"
941
+ echo " -> Removed rules: core.md"
942
+ fi
943
+
944
+ # Step 5: Remove Cloudflare Tunnel config
945
+ echo "[5/${TOTAL_STEPS}] Removing Cloudflare Tunnel configuration..."
946
+ if [ -d /etc/cloudflared ]; then
947
+ # Stop cloudflared service if running via systemd
948
+ if [ "$PROC_MGR" = "systemd" ]; then
949
+ $SUDO systemctl stop cloudflared 2>/dev/null || true
950
+ $SUDO systemctl disable cloudflared 2>/dev/null || true
951
+ fi
952
+ $SUDO rm -rf /etc/cloudflared
953
+ echo " -> Removed /etc/cloudflared/"
954
+ else
955
+ echo " -> Not found, skipping"
956
+ fi
957
+
958
+ echo ""
959
+ echo "========================================="
960
+ echo " Uninstall Complete!"
961
+ echo "========================================="
962
+ echo ""
963
+ echo "The minion agent services have been removed."
964
+ echo ""
965
+ echo "To also remove the npm package:"
966
+ echo " npm uninstall -g @geekbeer/minion"
967
+ echo ""
968
+ echo "Software installed by setup (Claude Code, Gemini CLI, VNC, etc.)"
969
+ echo "was NOT removed. Uninstall them manually if needed."
970
+ }
971
+
810
972
  # ============================================================
811
973
  # reconfigure subcommand
812
974
  # ============================================================
@@ -1007,6 +1169,12 @@ case "${1:-}" in
1007
1169
  do_setup "$@"
1008
1170
  ;;
1009
1171
 
1172
+ uninstall)
1173
+ require_root uninstall
1174
+ shift
1175
+ do_uninstall "$@"
1176
+ ;;
1177
+
1010
1178
  reconfigure)
1011
1179
  require_root reconfigure
1012
1180
  shift
@@ -1142,6 +1310,7 @@ case "${1:-}" in
1142
1310
  echo "Usage:"
1143
1311
  echo " sudo minion-cli setup [options] # Set up agent service (root)"
1144
1312
  echo " sudo minion-cli reconfigure [options] # Re-register with new HQ credentials (root)"
1313
+ echo " sudo minion-cli uninstall [options] # Remove agent and services (root)"
1145
1314
  echo " sudo minion-cli start # Start agent service (root)"
1146
1315
  echo " sudo minion-cli stop # Stop agent service (root)"
1147
1316
  echo " sudo minion-cli restart # Restart agent service (root)"
@@ -1164,6 +1333,9 @@ case "${1:-}" in
1164
1333
  echo " --minion-id <UUID> Minion ID (required)"
1165
1334
  echo " --api-token <TOKEN> API token (required)"
1166
1335
  echo ""
1336
+ echo "Uninstall options:"
1337
+ echo " --keep-data Keep /opt/minion-agent/.env (preserve credentials)"
1338
+ echo ""
1167
1339
  echo "Status values: online, offline, busy"
1168
1340
  echo ""
1169
1341
  echo "Environment:"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geekbeer/minion",
3
- "version": "2.42.5",
3
+ "version": "2.43.1",
4
4
  "description": "AI Agent runtime for Minion - manages status and skill deployment on VPS",
5
5
  "main": "linux/server.js",
6
6
  "bin": {
@@ -3,6 +3,7 @@
3
3
  # Usage:
4
4
  # minion-cli-win setup --hq-url https://... --minion-id <UUID> --api-token <TOKEN>
5
5
  # minion-cli-win setup --setup-tunnel
6
+ # minion-cli-win uninstall [--keep-data]
6
7
  # minion-cli-win start | stop | restart | status | health | diagnose | version | help
7
8
 
8
9
  # Parse arguments manually to avoid issues with npm wrapper passing $args as array
@@ -11,17 +12,19 @@ $HqUrl = ''
11
12
  $MinionId = ''
12
13
  $ApiToken = ''
13
14
  $SetupTunnel = $false
15
+ $KeepData = $false
14
16
 
15
17
  $i = 0
16
18
  while ($i -lt $args.Count) {
17
19
  $arg = [string]$args[$i]
18
20
  switch -Regex ($arg) {
19
- '^(setup|reconfigure|start|stop|restart|status|health|diagnose|version|help)$' { $Command = $arg }
21
+ '^(setup|reconfigure|uninstall|start|stop|restart|status|health|diagnose|version|help)$' { $Command = $arg }
20
22
  '^(-v|--version)$' { $Command = 'version' }
21
23
  '^--hq-url$' { $i++; if ($i -lt $args.Count) { $HqUrl = [string]$args[$i] } }
22
24
  '^--minion-id$' { $i++; if ($i -lt $args.Count) { $MinionId = [string]$args[$i] } }
23
25
  '^--api-token$' { $i++; if ($i -lt $args.Count) { $ApiToken = [string]$args[$i] } }
24
26
  '^--setup-tunnel$' { $SetupTunnel = $true }
27
+ '^--keep-data$' { $KeepData = $true }
25
28
  '^(-h|--help)$' { $Command = 'help' }
26
29
  }
27
30
  $i++
@@ -421,6 +424,23 @@ New-Item -Path `$LogDir -ItemType Directory -Force | Out-Null
421
424
  # Write PID of this watchdog process
422
425
  Set-Content -Path `$PidFile -Value `$PID
423
426
 
427
+ # Helper: find websockify executable
428
+ function Get-WebsockifyCommand {
429
+ if (Get-Command websockify -ErrorAction SilentlyContinue) {
430
+ return @((Get-Command websockify).Source)
431
+ }
432
+ if (Get-Command python -ErrorAction SilentlyContinue) {
433
+ `$scriptsDir = & python -c "import sysconfig; print(sysconfig.get_path('scripts'))" 2>`$null
434
+ if (`$scriptsDir) {
435
+ `$wsExe = Join-Path `$scriptsDir 'websockify.exe'
436
+ if (Test-Path `$wsExe) { return @(`$wsExe) }
437
+ }
438
+ `$check = & python -c "import websockify" 2>&1
439
+ if (`$LASTEXITCODE -eq 0) { return @('python', '-m', 'websockify') }
440
+ }
441
+ return `$null
442
+ }
443
+
424
444
  # Start TightVNC + websockify if available
425
445
  `$vncExe = `$null
426
446
  if (Test-Path 'C:\Program Files\TightVNC\tvnserver.exe') {
@@ -784,6 +804,152 @@ Remove-Item `$PidFile -Force -ErrorAction SilentlyContinue
784
804
  Write-Host " Get-Content $(Join-Path $LogDir 'service-stdout.log') -Tail 50 # View logs"
785
805
  }
786
806
 
807
+ # ============================================================
808
+ # Uninstall
809
+ # ============================================================
810
+
811
+ function Invoke-Uninstall {
812
+ Write-Host ""
813
+ Write-Host "=========================================" -ForegroundColor Red
814
+ Write-Host " @geekbeer/minion Uninstall" -ForegroundColor Red
815
+ Write-Host "=========================================" -ForegroundColor Red
816
+ Write-Host ""
817
+ Write-Host "This will remove the minion agent and all related configuration."
818
+ if ($KeepData) {
819
+ Write-Host " --keep-data: $EnvFile will be preserved."
820
+ }
821
+ else {
822
+ Write-Host " Data directory $DataDir will be deleted."
823
+ }
824
+ Write-Host ""
825
+ $confirm = Read-Host " Type 'yes' to continue"
826
+ if ($confirm -ne 'yes') {
827
+ Write-Host "Uninstall cancelled."
828
+ exit 0
829
+ }
830
+ Write-Host ""
831
+
832
+ $totalSteps = 5
833
+
834
+ # Step 1: Stop agent and child processes
835
+ Write-Step 1 $totalSteps "Stopping agent and related processes..."
836
+ Stop-MinionProcess
837
+
838
+ # Stop VNC server
839
+ $vncProc = Get-Process -Name tvnserver -ErrorAction SilentlyContinue
840
+ if ($vncProc) {
841
+ Stop-Process -Name tvnserver -Force -ErrorAction SilentlyContinue
842
+ Write-Detail "TightVNC server stopped"
843
+ }
844
+
845
+ # Stop websockify
846
+ $wsProc = Get-Process -Name websockify -ErrorAction SilentlyContinue
847
+ if ($wsProc) {
848
+ Stop-Process -Name websockify -Force -ErrorAction SilentlyContinue
849
+ Write-Detail "websockify stopped"
850
+ }
851
+
852
+ # Stop cloudflared
853
+ $cfProc = Get-Process -Name cloudflared -ErrorAction SilentlyContinue
854
+ if ($cfProc) {
855
+ Stop-Process -Name cloudflared -Force -ErrorAction SilentlyContinue
856
+ Write-Detail "cloudflared stopped"
857
+ }
858
+
859
+ Write-Detail "All processes stopped"
860
+
861
+ # Step 2: Remove startup shortcut
862
+ Write-Step 2 $totalSteps "Removing auto-start registration..."
863
+ $startupDir = [Environment]::GetFolderPath('Startup')
864
+ $shortcutPath = Join-Path $startupDir 'MinionAgent.lnk'
865
+ if (Test-Path $shortcutPath) {
866
+ Remove-Item $shortcutPath -Force
867
+ Write-Detail "Removed $shortcutPath"
868
+ }
869
+ else {
870
+ Write-Detail "Startup shortcut not found, skipping"
871
+ }
872
+
873
+ # Step 3: Remove data directory (or keep .env)
874
+ Write-Step 3 $totalSteps "Removing data directory..."
875
+ if ($KeepData) {
876
+ # Remove everything except .env
877
+ if (Test-Path $DataDir) {
878
+ Get-ChildItem -Path $DataDir -Recurse -File | Where-Object { $_.FullName -ne $EnvFile } | Remove-Item -Force -ErrorAction SilentlyContinue
879
+ Get-ChildItem -Path $DataDir -Recurse -Directory | Sort-Object { $_.FullName.Length } -Descending | ForEach-Object {
880
+ if ((Get-ChildItem $_.FullName -Force | Measure-Object).Count -eq 0) {
881
+ Remove-Item $_.FullName -Force -ErrorAction SilentlyContinue
882
+ }
883
+ }
884
+ Write-Detail "Data directory cleaned (kept .env)"
885
+ }
886
+ else {
887
+ Write-Detail "Data directory not found, skipping"
888
+ }
889
+ }
890
+ else {
891
+ if (Test-Path $DataDir) {
892
+ Remove-Item $DataDir -Recurse -Force
893
+ Write-Detail "Removed $DataDir"
894
+ }
895
+ else {
896
+ Write-Detail "Data directory not found, skipping"
897
+ }
898
+ }
899
+
900
+ # Step 4: Remove deployed skills and rules
901
+ Write-Step 4 $totalSteps "Removing deployed skills and rules..."
902
+ $claudeSkillsDir = Join-Path $env:USERPROFILE '.claude\skills'
903
+ $claudeRulesDir = Join-Path $env:USERPROFILE '.claude\rules'
904
+
905
+ # Remove bundled skills (only skills that ship with the package)
906
+ $npmRoot = & npm root -g 2>$null
907
+ $bundledSkillsDir = Join-Path $npmRoot '@geekbeer\minion\skills'
908
+ if ((Test-Path $bundledSkillsDir) -and (Test-Path $claudeSkillsDir)) {
909
+ Get-ChildItem -Path $bundledSkillsDir -Directory | ForEach-Object {
910
+ $targetSkill = Join-Path $claudeSkillsDir $_.Name
911
+ if (Test-Path $targetSkill) {
912
+ Remove-Item $targetSkill -Recurse -Force
913
+ Write-Detail "Removed skill: $($_.Name)"
914
+ }
915
+ }
916
+ }
917
+ else {
918
+ Write-Detail "No bundled skills to remove"
919
+ }
920
+
921
+ # Remove deployed rules
922
+ $coreRule = Join-Path $claudeRulesDir 'core.md'
923
+ if (Test-Path $coreRule) {
924
+ Remove-Item $coreRule -Force
925
+ Write-Detail "Removed rules: core.md"
926
+ }
927
+
928
+ # Step 5: Remove Cloudflare Tunnel configuration
929
+ Write-Step 5 $totalSteps "Removing Cloudflare Tunnel configuration..."
930
+ $cfConfigDir = Join-Path $env:USERPROFILE '.cloudflared'
931
+ if (Test-Path $cfConfigDir) {
932
+ Remove-Item $cfConfigDir -Recurse -Force
933
+ Write-Detail "Removed $cfConfigDir"
934
+ }
935
+ else {
936
+ Write-Detail "Not found, skipping"
937
+ }
938
+
939
+ Write-Host ""
940
+ Write-Host "=========================================" -ForegroundColor Green
941
+ Write-Host " Uninstall Complete!" -ForegroundColor Green
942
+ Write-Host "=========================================" -ForegroundColor Green
943
+ Write-Host ""
944
+ Write-Host "The minion agent has been removed."
945
+ Write-Host ""
946
+ Write-Host "To also remove the npm package:"
947
+ Write-Host " npm uninstall -g @geekbeer/minion"
948
+ Write-Host ""
949
+ Write-Host "Software installed by setup (Node.js, Claude Code, TightVNC, etc.)"
950
+ Write-Host "was NOT removed. Uninstall them manually if needed."
951
+ }
952
+
787
953
  # ============================================================
788
954
  # Reconfigure
789
955
  # ============================================================
@@ -869,6 +1035,9 @@ switch ($Command) {
869
1035
  'setup' {
870
1036
  Invoke-Setup
871
1037
  }
1038
+ 'uninstall' {
1039
+ Invoke-Uninstall
1040
+ }
872
1041
  'reconfigure' {
873
1042
  Invoke-Reconfigure
874
1043
  }
@@ -945,6 +1114,7 @@ switch ($Command) {
945
1114
  Write-Host "Usage (no admin required):"
946
1115
  Write-Host " minion-cli-win setup [options] # Set up agent (auto-start on login)"
947
1116
  Write-Host " minion-cli-win reconfigure [options] # Re-register with new HQ credentials"
1117
+ Write-Host " minion-cli-win uninstall [options] # Remove agent and configuration"
948
1118
  Write-Host " minion-cli-win start # Start agent process"
949
1119
  Write-Host " minion-cli-win stop # Stop agent process"
950
1120
  Write-Host " minion-cli-win restart # Restart agent process"
@@ -964,6 +1134,9 @@ switch ($Command) {
964
1134
  Write-Host " --minion-id <UUID> Minion ID (required)"
965
1135
  Write-Host " --api-token <TOKEN> API token (required)"
966
1136
  Write-Host ""
1137
+ Write-Host "Uninstall options:"
1138
+ Write-Host " --keep-data Keep .env file (preserve credentials)"
1139
+ Write-Host ""
967
1140
  Write-Host "Data directory: $DataDir"
968
1141
  Write-Host ""
969
1142
  Write-Host "Environment:"