Skip to content

[ENG-3386] Signal Patchstack when the package is uninstalled from a project - #103

Merged
daniloradovic merged 1 commit into
mainfrom
danilo/eng-3386-signal-package-removed
Jul 29, 2026
Merged

[ENG-3386] Signal Patchstack when the package is uninstalled from a project#103
daniloradovic merged 1 commit into
mainfrom
danilo/eng-3386-signal-package-removed

Conversation

@daniloradovic

Copy link
Copy Markdown
Contributor

Ref ENG-3386 (closes via patchstack/saas#1096)

Problem

When an AI agent removes Patchstack from a vibe-coded project by prompt, the site record on SaaS lives on and keeps consuming a site slot. AGENT-INSTALL.md explicitly said account-side deletion was impossible from the CLI.

Changes

  • New patchstack-connect uninstall command — POSTs a package-removed signal to POST /monitor/pulse/package-removed/{uuid} (new endpoint in patchstack/saas#1096). Signal-only: local file removal stays with the documented uninstall steps, and a failed/unreachable signal warns without failing the flow.
    • Unclaimed site → server deletes the anonymous record, CLI reports it
    • Claimed site → server flags it; CLI tells the user the owner frees the slot in the dashboard
    • Already gone → reported as nothing-to-do
  • postPackageRemoved / buildPackageRemovedUrl in client.ts — endpoint-override aware (same /manifest suffix mapping as the rules URL), never throws
  • AGENT-INSTALL.md — the signal is step 5 of Uninstalling (run while the package and .patchstackrc.json still exist), and the closing guidance now instructs agents to report the site UUID + dashboard link instead of "there is no CLI command for account-side deletion". Authenticating or removing a claimed site on the user's behalf remains forbidden.

Why signal-only and non-destructive

The site UUID ships in the widget snippet on every page of the built site — it is public. A UUID-authorized hard delete of claimed sites would let anyone delete someone's site from their account. The signal is safe precisely because forging it can only cause a "did you remove Patchstack?" prompt.

Testing

  • 9 new vitest cases (URL mapping, deleted/flagged/gone/failed outcomes, no-UUID short-circuit, never-throws); 595 total pass; typecheck clean
  • Verified live against a local SaaS backend: unclaimed site deleted, claimed site flagged (and the flag cleared by a subsequent manifest push)
  • Agent prompt test: a fresh agent given only "please remove patchstack from my project" followed the updated AGENT-INSTALL.md end to end, signalled at the right step, and reported the claimed-site slot guidance

Release order

Publish to npm only after patchstack/saas#1096 is deployed — against an older backend the CLI misreports the route 404 as "site record no longer exists".

🤖 Generated with Claude Code

Prompt-driven uninstalls previously left the site record on Patchstack
untouched — a claimed site kept consuming a site slot with no nudge to
its owner, and AGENT-INSTALL.md documented account-side deletion as
impossible.

Add `patchstack-connect uninstall`: it POSTs a package-removed signal to
the new /monitor/pulse/package-removed/{uuid} endpoint. The server
deletes an unclaimed (anonymous) site record outright and only flags a
claimed one — the UUID is a public identifier, so the signal can be
forged and must never destroy account data. The command is signal-only
(local file removal stays with the uninstall steps) and never fails the
flow: an unreachable server warns and moves on.

AGENT-INSTALL.md's Uninstalling section runs the command as step 5,
while the package and .patchstackrc.json still exist, and now ends by
telling the user their claimed site keeps using a slot until removed in
the dashboard — replacing the "there is no CLI command for account-side
deletion" guidance.

Requires the SaaS endpoint to be deployed first: against an older
backend the 404 is reported as "site record no longer exists".

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderbuds

coderbuds Bot commented Jul 29, 2026

Copy link
Copy Markdown

Well-focused uninstall feature with clear docs, CLI integration, and client logic.

🎯 Quality: 100% Elite · 📦 Size: Medium

📈 This month: Your 81st PR — above team average · Averaging Excellent

See how your team is trending →

@daniloradovic

Copy link
Copy Markdown
Contributor Author

/review

@daniloradovic
daniloradovic merged commit 49a5ada into main Jul 29, 2026
4 checks passed
@daniloradovic
daniloradovic deleted the danilo/eng-3386-signal-package-removed branch July 29, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants