Skip to content

0.9.0

Choose a tag to compare

@Newmannn91 Newmannn91 released this 14 Nov 07:37
· 4 commits to main since this release

Maintenance & archiving release. Part 1: tag editing (parts 2–3 — archive/restore and the two-step plan/apply cleanup — follow in the same release).

Added

  • edit_tags tool. Add, remove, or rename one tag on an existing note, in front matter (tags:, inline or block form) or body (#tag), one operation per call. Only the tag lines change; the rest of the file stays byte-identical. Adding a tag to a note with no front matter creates a minimal ---\ntags: [tag]\n--- block at the top; adding a body tag appends #tag on its own line at the end of the file. The search index updates at once, so the note is searchable by its new tags immediately. Adding a tag that is already there, removing one that is not there, and renaming to a name that already exists are no-ops, not errors. Tag names are case-insensitive.
  • archive_file tool. Move a file into the library top-level archive/ folder (created on demand), preserving its relative path (notes/foo.md becomes archive/notes/foo.md). Refuses to overwrite an existing file at the destination, and rejects directories, missing files, archive/ itself, or files already under archive/. The top-level archive/ folder is excluded from search_files (both indexed and direct-scan fallback), while list_directory still shows archive/ at the root. This also applies to a pre-existing top-level archive/ folder the user already had before upgrading — its notes are no longer searchable (whole-library search and an explicit path: 'archive' search both return nothing), while list_directory still shows archive/ and its contents. On Linux and other case-sensitive filesystems, a folder named Archive/ (or any other capitalisation) is likewise treated as the archive folder, because the archive check is case-insensitive; its notes are not searchable either, and archive_file will not move files inside it.
  • restore_file tool. Move a file from archive/ back to its original path by stripping the leading archive/ segment, creating parent directories as needed. Refuses to overwrite an existing file at the destination and rejects paths outside archive/. Updates the search index immediately so the restored file is searchable again.
  • plan_cleanup tool. Generate a read-only cleanup plan for the library (two-step confirmation). Proposes archiving empty files (0 bytes), duplicate files (keeps the earliest-modified copy), and orphan attachment candidates (unreferenced for over 24h); writes the plan as JSON in the per-library cache dir and returns the plan ID and a human-readable preview. Changes nothing. Dotfiles, dot-directories, and files under archive/ are never proposed. A plan holds at most 200 actions; the preview says so and to regenerate after applying. When the orphan scan is withheld (a note could not be read), the preview says how many notes were skipped. No permanent deletion anywhere in 0.9.0 — empty files are archived, not deleted. Paths that fail the sandbox write check (for example a file name containing ':') are never proposed.
  • memdrive-mcp apply <plan-id> command. Execute a cleanup plan from the command line (the MCP server never starts). Before executing, each action is re-verified: the plan ID must match YYYYMMDDHHmmss-<6 hex>, every path is checked against the sandbox (no absolute paths, .., archive/, or dot-segments) and canonicalized, and a fresh diagnostics scan confirms the reason still holds (empty file still empty, duplicate group still intact, orphan still unreferenced). Actions that no longer hold are skipped with the reason. Plans older than 7 days are rejected. The command exits non-zero when every action is skipped. File hashes are computed by streaming, never by loading a whole file into memory. A single action whose path fails the sandbox write check is skipped on its own instead of refusing the whole plan. Each action now carries a kind ('empty', 'duplicate', or 'orphan'); apply re-validates by kind and rejects unknown kinds. The archive/ path check is case-insensitive, matching the archive detection. Duplicate re-validation also requires the keeper to be a different file from the one being archived and still present on disk; the archive/ check in plan generation is case-insensitive too. Duplicate keeper checks treat an unreadable keeper as missing (the re-check never crashes the apply run); keeper paths are screened against the sandbox path rules first.
  • apply_plan tool. Execute a cleanup plan from chat, by its plan ID. Same re-verification and execution as the memdrive-mcp apply <plan-id> command (paths, SHA-256, and modification times are re-checked; actions that no longer hold are skipped; plans older than 7 days are rejected), but callable by the model in conversation — the user just asks to execute the plan in natural language, no terminal needed. The command-line apply is unchanged and still works.

Fixed

  • Hardening & edge cases. edit_tags preserves a leading UTF-8 BOM; search_files reports out-of-range offsets cleanly, applies file_types before the 200-hit direct-scan cap, and guards background index warm-up against unhandled rejections; save_file escapes ] in Markdown image alt text and cleans up saved images only when the document write itself fails; read_file and edit_tags reject files over 256 MB before loading them into memory.
  • Cross-platform filename validation on write. File names containing characters that are invalid on Windows (notably : and trailing dots or spaces) are rejected on write (save_file, archive_file, and restore_file), while files with such names that already exist in the library can still be read.
  • Archive diagnostics counts archived notes' references. scanDiagnostics now also reads Markdown under archive/, resolving each image reference at both the note's current archived position and its original pre-archive position, so images referenced only by an archived note are no longer falsely listed as orphan candidates.
  • Diagnostics withholds the orphan list when the scan is incomplete. If a note cannot be read (oversize, cloud placeholder, or read error), the report now says so — naming the note and the reason — and withholds the whole orphan list rather than risk a false positive that Part 3 cleanup would delete. A placeholder file is only treated as dataless on macOS (via isDatalessFile), so a genuinely existing file that merely reports zero blocks on other platforms is still read.
  • Diagnostics only withholds the orphan list for unreadable Markdown notes. The scan-incomplete marker is now set only when a Markdown note cannot be read (oversize, cloud placeholder, or read error); a large non-Markdown file (.log, .csv, .json, .txt) no longer hides the orphan list, since only Markdown notes are scanned for image references.
  • Scoped diagnostics report explains out-of-scope skipped notes. When a diagnostics run is scoped to a directory, the report now says when a skipped note lies outside the requested scope — such notes still withhold the orphan list, because a note anywhere in the library may reference an image inside the scope.
  • moveFile no longer overwrites an existing target, and cleans up on failure. moveFile creates the target with fs.link (falling back to copyFile with COPYFILE_EXCL when hard links are unavailable or the move crosses devices) and only then removes the source; if removing the source fails, or a fallback copy fails midway, the just-created target is deleted before the error is rethrown. A copyFile failure with EEXIST leaves the pre-existing target untouched, since it was not created by the move.