Skip to content

feat: add uninstall.sh — per-copy uninstaller with confirmation, dry-run, and OneCLI agent cleanup - #2719

Merged
Koshkoshinsk merged 3 commits into
nanocoai:mainfrom
amit-shafnir:feat/uninstall-script
Jun 10, 2026
Merged

feat: add uninstall.sh — per-copy uninstaller with confirmation, dry-run, and OneCLI agent cleanup#2719
Koshkoshinsk merged 3 commits into
nanocoai:mainfrom
amit-shafnir:feat/uninstall-script

Conversation

@amit-shafnir

Copy link
Copy Markdown
Contributor

Type of Change

  • Feature skill - adds a channel or integration (source code changes + SKILL.md)
  • Utility skill - adds a standalone tool (code files in .claude/skills/<name>/, no source changes)
  • Operational/container skill - adds a workflow or agent skill (SKILL.md only, no source changes)
  • Fix - bug fix or security fix to source code
  • Simplification - reduces or simplifies source code
  • Documentation - docs, README, or CONTRIBUTING changes only

None of the boxes fit exactly: this is a root-level lifecycle script alongside nanoclaw.sh and migrate-v2.sh — not a skill, fix, or simplification. Happy to rework as a skill if you'd prefer.

Description

What: uninstall.sh — interactive uninstaller that removes one NanoClaw copy from a machine, plus a README FAQ entry and CLAUDE.md key-files row.

Why: Install and migration have first-class scripts; removal currently requires manually hunting down the slug-named service, image, containers, and OneCLI vault agents.

How it works: Sources setup/lib/install-slug.sh to derive this copy's service label, image name, and container label. Scans four groups (service/containers, data+logs+secrets, agent files, OneCLI agents), shows what exists, and confirms each group before deleting. OneCLI vault agents are matched against agent_groups in data/v2.db (via scripts/q.ts); unmatched ag-* agents are treated as belonging to another copy and never auto-deleted. --dry-run previews, --yes skips prompts, .env is backed up before removal. Shared state (OneCLI app/vault, ~/.config/nanoclaw/, other copies) is left alone.

How it was tested: Ran on a live install: dry-run, interactive, and --yes paths; verified service unload, container/image removal, OneCLI agent deletion by UUID, and that a second copy's artifacts were untouched.

🤖 Generated with Claude Code

@github-actions github-actions Bot added the follows-guidelines PR was created using the current contributing template label Jun 9, 2026
amit-shafnir and others added 3 commits June 10, 2026 15:50
…run, and OneCLI agent cleanup

Removes only what belongs to this checkout (slug-scoped): background
service, containers + image, data/, logs/, groups/, ncl symlink, and
this copy's OneCLI vault agents. Shared tools (OneCLI app, credentials,
other copies) are left alone. Interactive per-group confirmation with
--dry-run and --yes modes; .env is backed up before removal.

Documented in README FAQ and the CLAUDE.md key-files table.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…isting installs in setup

Replaces the standalone bash uninstall.sh with a TypeScript flow inside the
setup driver (setup/uninstall/): scan (slug-scoped inventory), plan (pure
ordered removal actions), remove (per-action executor that absorbs failures
into notes), and flow (clack UI). uninstall.sh is now a 3-line pointer that
execs nanoclaw.sh --uninstall.

- nanoclaw.sh --uninstall short-circuits before diagnostics/bootstrap; with
  no node_modules it prints manual cleanup commands and exits 1
- setup:auto routes --uninstall before initProgressionLog so an uninstall
  never resets logs/setup.log
- fresh setup runs detect an existing install (service registration or
  data/v2.db) and offer keep-and-continue (default) or uninstall-and-exit;
  suppressed on fail()-retry and sg re-exec resumes
- self-deletion safety: static imports only, dist/ + node_modules/ removed
  dead last, nothing but console.log after the runtime tail
- --yes never deletes orphan ag-* vault agents; their manual delete
  commands (by vault uuid) are printed instead

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- .env backup and removal are now one atomic action: a failed backup
  throws into executePlan's catch and the deletion never runs (the bash
  original's set -e gave the same guarantee; the port had lost it)
- containers are re-listed by install label at removal time instead of
  removed from scan-time ids — the live host can spawn containers during
  the confirm phase
- uninstall telemetry no longer creates data/install-id (persistId:false
  on emit), so --dry-run truly changes nothing and the already-clean
  exit can fire
- runtime-tail failure notes are printed before the Done line instead
  of being discarded
- uninstall.sh translates the old short flags (-n/-y) instead of
  silently dropping them (-n used to fall through to a real interactive
  uninstall)
- nanoclaw.sh gates the TS uninstaller on node (tsx's interpreter), not
  pnpm, which the direct-exec path never uses
- detectExistingInstall also checks the system-level systemd unit
- a delete-onecli-agent spawn failure now notes the manual command
  instead of claiming the agent was already gone
- setupLog.userInput is skipped when logs/ is absent so the uninstall
  doesn't recreate it

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@amit-shafnir
amit-shafnir force-pushed the feat/uninstall-script branch from 0bd00e5 to d8748e3 Compare June 10, 2026 12:50
@Koshkoshinsk

Copy link
Copy Markdown
Collaborator

'NEEDS CHANGES

One cross-platform bug to fix before this can land:

xargs -r in fallback guidance (nanoclaw.sh)xargs -r is Linux-only and not available on macOS. The fallback block echoes manual cleanup guidance using xargs -r $RUNTIME rm -f. On macOS with no matching containers, xargs without -r passes empty input to docker rm -f, which errors. Fix: use grep . | xargs $RUNTIME rm -f or equivalent.


Notes for maintainers (not blocking):

  • Re-run UX change: detectExistingInstall in auto.ts now shows a keep-or-uninstall prompt whenever any user re-runs bash nanoclaw.sh on an existing install. Default is keep (one extra Enter), but it is a behavior change for all reconfiguration re-runs.
  • Flag namespace: --dry-run and --yes are in the global setup config but only apply to --uninstall. Low risk now, worth noting for future.
  • nanoclaw.pid dual-registration: Appears in both inv.service.pidFile and inv.data — correct and intentional, but a comment in scan.ts would help future readers.

Architecture, safety, and test coverage are all solid.

@Koshkoshinsk
Koshkoshinsk merged commit f16ea0c into nanocoai:main Jun 10, 2026
1 check passed
teknium1 added a commit to NousResearch/hermes-agent that referenced this pull request Jul 7, 2026
Port from nanocoai/nanoclaw#2719: let operators preview the uninstall plan without stopping services or deleting files.
technicalpickles pushed a commit to technicalpickles/nanoclaw that referenced this pull request Jul 12, 2026
feat: add uninstall.sh — per-copy uninstaller with confirmation, dry-run, and OneCLI agent cleanup
santhreal pushed a commit to santhreal/hermes-agent that referenced this pull request Jul 13, 2026
Port from nanocoai/nanoclaw#2719: let operators preview the uninstall plan without stopping services or deleting files.
justemu pushed a commit to justemu/hermes-agent that referenced this pull request Jul 18, 2026
Port from nanocoai/nanoclaw#2719: let operators preview the uninstall plan without stopping services or deleting files.
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
Port from nanocoai/nanoclaw#2719: let operators preview the uninstall plan without stopping services or deleting files.
leewenjie pushed a commit to leewenjie/hermes-agent that referenced this pull request Aug 7, 2026
Port from nanocoai/nanoclaw#2719: let operators preview the uninstall plan without stopping services or deleting files.
randlee pushed a commit to randlee/hermes-agent that referenced this pull request Aug 11, 2026
Port from nanocoai/nanoclaw#2719: let operators preview the uninstall plan without stopping services or deleting files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

follows-guidelines PR was created using the current contributing template

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants