Skip to content

Add safe delete Native Plugin example - #312

Merged
yyjeqhc merged 3 commits into
mainfrom
feat/safe-delete-plugin-pr
Sep 5, 2026
Merged

Add safe delete Native Plugin example#312
yyjeqhc merged 3 commits into
mainfrom
feat/safe-delete-plugin-pr

Conversation

@yyjeqhc

@yyjeqhc yyjeqhc commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Summary

Add an optional safe_delete Native Tool Plugin example that moves one file or directory under the configured Plugin cwd to the operating-system Trash / Recycle Bin instead of permanently deleting it.

  • project-root-fenced relative paths only
  • rejects root deletion, parent traversal, paths escaping the root, symlink/junction targets, and unsupported file types
  • one path per call; no batch or force mode
  • Linux: same-filesystem freedesktop Home Trash first, then gio trash, then trash-put only when gio is unavailable
  • macOS: Foundation NSFileManager Trash API through built-in JXA, without Finder UI automation
  • Windows: Microsoft.VisualBasic.FileIO Recycle Bin backend
  • no permanent-delete fallback for the requested path
  • bounded/sanitized results; raw backend stderr is never returned

Reviewer hardening

Independent review fixed two replay/outcome issues before publication:

  1. safe_delete is now explicitly non-idempotent. An already-absent path is a safe no-op, but after an unknown result a replacement object may appear at the same name, so callers must not blindly retry.
  2. If an external Trash backend reports failure but the original path is already absent (or its postcondition cannot be inspected), the tool reports outcome=unknown rather than a definite failure.

The review branch was rebuilt directly from current origin/main so an unrelated local tunnel-diagnostics commit is not part of this PR.

Validation

  • node --check plugins/safe-delete/plugin.mjs
  • node --test plugins/safe-delete/plugin.test.mjs — 16/16 passed
  • python3 scripts/check_markdown_links.py — 0 missing links
  • git diff --check origin/main...HEAD
  • workspace hygiene clean

The example tests are intentionally not wired into a new CI lane in this PR; the current goal is an optional dogfood Plugin, and adding CI workflow/release-gate changes would trigger the full native matrix. Real Runner/OS Trash behavior will be dogfooded after deployment.

@yyjeqhc
yyjeqhc merged commit 7052703 into main Sep 5, 2026
17 checks passed
@yyjeqhc
yyjeqhc deleted the feat/safe-delete-plugin-pr branch September 5, 2026 11:54
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.

1 participant