dsh-folderwatch: Wake Agent on Directory Changes with Diff and Self-Write Filtering

Preface

In DeepSeek Harness (DSH), agents can already be woken up via scheduled tasks (clock) and HTTP webhooks. Neither of these two mechanisms addresses another kind of situation that arises during an ongoing session: someone or some process outside the conversation modifies files — a build finishes, a formatting tool rewrites the directory tree, tests produce reports, downloads land on disk, or a colleague pushes content into a shared directory. If the agent does not proactively look, it often only notices on the next turn.

dsh-folderwatch targets the workflow of “watching a directory and notifying the agent when it changes”. When the directory tree changes, the agent receives an actionable change list (creations, modifications, deletions, and file sizes), and can choose to wake immediately (wake) or process it on the next step (queue). At the same time, paths written by tool calls within this session are recorded as “own writes” within a short window and filtered out of notifications, avoiding the “write file → get woken → re-read the file you just wrote” loop, as well as wake loops caused by continuous disk writes from build/format/test processes.

The following sections introduce the plugin’s positioning, design highlights, installation configuration, and typical usage. Facts are subject to the GitHub repository README; community directory page: skillhub plugin entry.

What is this

  • Name: dsh-folderwatch (maintainer: 11111353535)
  • Category: Workflow
  • One-liner: Arm a directory against the agent that armed it; on tree changes it gives precise change descriptions, and can wake the agent or queue message injections.
  • Version (package.json): 0.1.0; License: MIT; Runtime: Node ^22.19.0 || >=24.0.0

The plugin declares no dsh-* peer dependencies; it only uses node:* plus @deepseek-ai/dsh-tools, @deepseek-ai/dsh-llm, and @deepseek-ai/schemastery, which are resolved and installed by the Harness itself.

Difference from “raw fs.watch + callbacks”

The README summarizes three design decisions that determine whether it can stay mounted for long-term use rather than being uninstalled the same afternoon.

1. Snapshot and diff, not raw events

fs.watch only says “something changed” — it does not clarify what changed; on Windows it may fire twice, sometimes without a filename, and loses events under high load. This plugin performs snapshotting and diffing on directories, correctly categorizing renames, deletions, and bursts of changes across platforms, and includes file sizes. fs.watch serves only as a hint to “re-scan as soon as possible”; periodic re-scanning is the correctness path.

2. Echo suppression (filtering this session’s writes)

When watching a directory the agent itself is editing, the typical failure mode is: the agent writes src/app.ts, the watcher fires, the agent is told the file changed and goes to read it — if the build, formatting, or test process was launched by the agent itself and keeps writing to disk, it gets woken repeatedly, wasting tokens.

Therefore, tool calls that name files are recorded in a short-lived ledger; changes to those paths within the window are recorded as suppressed rather than delivered. The window is intentionally short (echoWindowMs, default 2500ms): a file written by the agent ten minutes ago that changes now still counts as a real external change. Each notification batch reports how many entries were filtered, making it easy to distinguish “nothing happened” from “the agent wrote it itself”.

3. Delivery mode can be selected per watch

mode call effect
wake (default) agent.followup(message) start a new round
queue agent.inject(message) appears at the agent’s next step

A watcher that can interrupt at any time is hard to keep on for long-term use; queue requires only one parameter and is suitable for keeping a watch mounted throughout the session without handing over interrupt rights.

Notification example (README):

[folderwatch] 3 changes under /work/shop/reports
watch: reports · 14:02:11
1 created · 1 modified · 1 deleted
  + /work/shop/reports/run-42.json  18KB
  ~ /work/shop/reports/latest.json  18KB
  - /work/shop/reports/run-41.json
(4 events suppressed as this session's own writes)

Read the new report and summarise what failed.

Installation and configuration

Installation

Install from a Git host:

dsh plugin add https://github.com/11111353535/dsh-folderwatch

If installing from a local checkout directory, pass an absolute path:

dsh plugin add /absolute/path/to/dsh-folderwatch

Profile-level configuration

The installer inserts a line into ~/.dsh/profiles/<profile>/cordis.patch.yml; you can add a config block per profile, e.g.:

- insert:
    - id: folderwatch
      name: 'dsh-folderwatch'
      config:
        quietMs: 400
        cooldownMs: 5000
        watches:
          - path: E:/work/reports
            label: reports
            pattern: '**/*.json'
            prompt: Read the new report and summarise what failed.
            mode: wake
key default meaning
watches [] list of watches armed at load time; arming via tools during the session is more common
ignore build/VCS/dependency directories applied to each watch, merged with each watch’s own list
quietMs 400 how long the tree must stay quiet before delivering a batch
maxWaitMs 5000 upper-bound wait for reporting even if the tree never goes quiet
cooldownMs 5000 minimum interval between two deliveries for the same watch
pollIntervalMs 1500 re-scan interval
maxWatches 16 upper bound on simultaneously armed watches
maxEntries 20000 upper bound on snapshot entries
echoWindowMs 2500 how long paths stay suppressed after being written by this session
maxEventsPerMessage 60 upper bound on events listed in a single notification (truncated beyond)

Tools and slash commands

folderwatch_add

Arms a watch. Key parameters:

argument meaning
path (required) directory; absolute path or relative to the workspace
label short name used in lists and notifications
prompt instruction attached to each notification
pattern glob, e.g. **/*.log
ignore additional ignore patterns
recursive whether to recurse into subdirectories, default true
once disarm after the first delivery, default false
mode "wake" | "queue", default wake
sessionId session to notify when not the current session

folderwatch_list

Lists each watch’s status, trigger count, and whether there are pending changes awaiting delivery.

folderwatch_check

Immediately re-scans and reports changes since the last scan, without delivering a message; suitable for answering “any new stuff?” within the current round without waiting to be woken.

folderwatch_fire

Skips the quiet period and immediately delivers that watch’s pending changes; if nothing is pending, it states so and does not send.

folderwatch_remove

Disarms and releases filesystem handles; summarizes the number of delivery batches and filtered own-writes during the armed period.

Slash command

/watch                                              # list
/watch add ./reports --pattern '**/*.json'          # arm, wake
/watch add ./build --queue                          # arm, inject next round
/watch add ./inbox --once                           # disarm after first delivery

(The README’s slash command section was truncated in the captured material; the above behavior follows the listed subcommands.)

Typical usage ideas

  1. In-session, have the agent run folderwatch_add (or /watch add) on a report directory, build output, or shared inbox, with pattern and prompt explaining what you want it to do when changes occur.
  2. If you don’t want external disk writes to interrupt the current reasoning, use mode: queue or --queue for the same directory.
  3. After long tasks finish, use folderwatch_check to proactively look at the diff, or folderwatch_fire to verify the delivery pipeline.
  4. Before the session ends, clean up armed watches with folderwatch_list / folderwatch_remove.

Suitable scenarios and caveats

Suitable for: build/test/formatting processes landing results in a directory tree, downloads or colleague writes into shared folders, mid-session automation that needs “change + concrete diff + optional wake”.

Caveats:

  • The plugin accesses the filesystem with the current DSH process’s permissions; review the source code and MIT license yourself before installing.
  • The community directory skillhub.cn is an independent site with no official affiliation with DeepSeek / High-Flyer; the DSH ecosystem follows the “everything is a plugin” philosophy, and this plugin is one of the workflow-type extensions.
  • Stars and versions are subject to real-time information from the repository and directory page; at the time of writing, the GitHub star count was 0.

Conclusion

dsh-folderwatch fills in the wake path for “mid-session, files changed outside the conversation”: snapshot diffing ensures a readable change list, echo suppression prevents the agent from being woken by write loops it triggered itself, and the delivery mode is selectable between wake and queue. Install it with the official command dsh plugin add https://github.com/11111353535/dsh-folderwatch to plug in.

  • Directory page: https://www.skillhub.cn/plugins/11111353535/dsh-folderwatch
  • GitHub: https://github.com/11111353535/dsh-folderwatch
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye