Bundled plugin

disk-cleanup

Auto-tracks and cleans up ephemeral files the agent creates during a session — test scripts, temp outputs, cron logs, stale Chrome profiles. Default-on, scoped strictly to $FLOWLY_HOME and /tmp/flowly-*. Zero agent involvement.

What it does

The agent regularly creates throwaway files: test_*.py while debugging, tmp_* for staging output, cron job logs that pile up over weeks. Without disk-cleanup, these accumulate forever — your ~/.flowly/ grows by megabytes per session.

disk-cleanup hooks into the agent runtime, watches every file the agent creates, and silently cleans them up at the end of each turn (for test files) or after configured retention windows (for temp / cron output). The agent never knows about it.

Why a hook, not a tool
We could have shipped a cleanup_disk tool the agent calls when it remembers to. But the agent forgets, gets distracted, or runs into context limits — temp files would still accumulate. A hook is invisible: it runs whether or not the agent cooperates.

How it works

Two hooks wired in at register(ctx):

python
def register(ctx):
    ctx.register_hook("post_tool_call", on_post_tool_call)
    ctx.register_hook("on_session_end", on_session_end)
    ctx.register_command("disk-cleanup", handler=slash_handler, ...)
  1. post_tool_call fires after every successful write_file, edit_file, or exec tool call. The hook scans the params/output for paths inside $FLOWLY_HOME matching one of the tracked patterns and adds them to tracked.json.
  2. on_session_end fires at the end of each turn (every user message + agent reply pair). Tracked files past their retention window are deleted. Failures are logged, never raised.

The slash command /disk-cleanup lets the user run cleanup manually, view status, or untrack files. It never modifies the tracking store except via explicit subcommands.

Cleanup rules

Files are categorized at track time and cleaned according to category-specific retention. Anything outside these categories is ignored.

PatternCategoryRetention
test_*, tmp_*, *.test.pytestend of every turn
$FLOWLY_HOME/cron/*cron-output14 days
$FLOWLY_HOME/cache/*temp7 days
research filesresearch30 days, prompts before delete
chrome user-data dirschrome-profile14 days, prompts

Safety guarantees

Plugin-level safety is enforced before anything is added to the tracking store, not just at delete time:

  • Path scope — only files inside $FLOWLY_HOME or /tmp/flowly-* are eligible. Windows mounts (/mnt/c), system paths, anything under ~/Documents — all rejected at track time.
  • Protected top-level dirs — even inside $FLOWLY_HOME, these are never tracked: sessions, skills, plugins, credentials, audit, workspace, profiles, logs, memories, trajectories, subagents, screenshots, media.
  • State directory — the plugin's own state at $FLOWLY_HOME/disk-cleanup/ is excluded self-referentially.
  • Error containment — any failure during tracking or deletion is logged to $FLOWLY_HOME/disk-cleanup/cleanup.log and swallowed. The agent loop is never affected.
Files you create yourself
If you, the user, place a file matching one of the tracked patterns inside $FLOWLY_HOME/ root (e.g. ~/.flowly/test_my_data.py), it will be deleted at session end. Don't use ~/.flowly/ as a working directory — keep your own files in ~/.flowly/workspace/ (which is protected) or outside Flowly entirely.

Slash commands

text
/disk-cleanup status         Per-category breakdown + 10 largest tracked files
/disk-cleanup dry-run        Preview what /quick would delete
/disk-cleanup quick          Run safe cleanup now (no prompts)
/disk-cleanup track <path> <category>   Manually add a path
/disk-cleanup forget <path>  Remove from tracking (does not delete)
/disk-cleanup help           Usage help

Categories accepted by track: temp, test, research, download, chrome-profile, cron-output, other.

State files

text
$FLOWLY_HOME/disk-cleanup/
├── tracked.json       Currently tracked paths with timestamps + category
├── tracked.json.bak   Backup written before each save
└── cleanup.log        Append-only audit log (TRACKED, DELETED, ERROR events)

To inspect what's been deleted recently:

bash
tail -50 ~/.flowly/disk-cleanup/cleanup.log

Opting out

bash
flowly plugins disable disk-cleanup
flowly service restart

State files at $FLOWLY_HOME/disk-cleanup/ are preserved across disable / re-enable, so re-enabling later resumes tracking from the previous state.

Source: flowly/plugins_bundled/disk-cleanup/. Originally contributed to Hermes Agent by @LVT382009 (PR #12212). Ported to Flowly with adaptations for the local plugin API.