← 返回 Skills 市场
danandbub

Driftwatch

作者 UncleD · GitHub ↗ · v1.1.4 · MIT-0
cross-platform ✓ 安全检测通过
208
总下载
0
收藏
0
当前安装
5
版本数
在 OpenClaw 中安装
/install driftwatch-oc
功能描述
Scan your OpenClaw workspace for truncation risks, compaction anchor health, workspace hygiene, and drift tracking over time. Use when the operator asks to "...
使用说明 (SKILL.md)

Driftwatch — Workspace Health Scanner

Running a Scan

python3 {baseDir}/scripts/scan.py --workspace \x3Cworkspace_path>

The --workspace argument is optional. If omitted, Driftwatch checks the OPENCLAW_WORKSPACE environment variable, then falls back to ~/.openclaw/workspace/. Most of the time just run:

python3 {baseDir}/scripts/scan.py

Output is JSON. Parse it, then present findings conversationally — never dump raw JSON at the operator.

Agent Delivery Rules

Always generate the HTML report when running a scan:

mkdir -p ~/.driftwatch/reports
python3 {baseDir}/scripts/scan.py --html ~/.driftwatch/reports/driftwatch-$(date +%Y-%m-%dT%H%M).html

Reports are stored with timestamps in ~/.driftwatch/reports/ so the operator can review past scans over time. Never overwrite — each scan gets its own file.

After generating:

  1. On messaging surfaces (Telegram, Discord, Signal): send the HTML file to the user, then follow with a 1-3 sentence text summary
  2. In terminal/CLI: print the file path so the operator can open it in a browser

The text summary covers: warning/danger/truncation counts (or "all clear"), notable changes since last scan, one actionable callout if needed. The HTML is the proof — always send both.

Exception: --check mode (cron) skips HTML unless --html is also passed explicitly.

What the Scanner Checks

Four analysis modules run in sequence:

truncation — Measures every bootstrap file's character count against the 20,000-char per-file limit and the 150,000-char aggregate budget. Tracks sequential budget consumption so you can see when MEMORY.md (last in injection order) is getting starved.

compaction — Checks whether AGENTS.md contains two recommended anchor sections: ## Session Startup and ## Red Lines. These are workspace conventions (not source-enforced) that ensure critical instructions are always present. Verifies each is present and within a 3,000-char budget. AGENTS.md is re-injected every turn as a bootstrap file — these sections matter as best-practice conventions, not because OpenClaw source code references them.

hygiene — Checks for duplicate memory files, empty bootstrap slots, missing subagent-required files, and stray markdown files the operator may think are being loaded but aren't.

simulation — Maps which lines and sections fall inside the truncation danger zone. For files over 18,000 chars, it shows exactly what content would be cut first. For files already over 20,000 chars, it shows what's being cut right now.

Severity Levels

  • critical — address immediately. Something is broken or will break.
  • warning — review soon. Not broken yet, but trending bad.
  • info — awareness only. Nothing's wrong, just worth knowing.

Presenting Findings

Lead with critical findings. If there are none, say so first — that's the good news. Then work through warnings and info grouped by module.

Translate numbers into meaning. Don't say "char_count: 18500, percent_of_limit: 92.5". Say: "AGENTS.md is at 18,500 characters — 92% of its 20,000-char limit. If it grows much more, content near the bottom will start getting cut silently."

What not to do: Don't modify any files. Don't attempt to auto-fix anything. Present findings and let the operator decide what to change.


Flags Reference

--save — Persist scan for drift tracking

python3 {baseDir}/scripts/scan.py --save

Saves the scan result to ~/.driftwatch/history/ as a timestamped JSON file. Run with --save regularly (daily cron is ideal) to build a history baseline. Nothing happens if the directory doesn't exist — it's created automatically.

When to suggest this: When the operator asks about trends, when AGENTS.md is growing, or when you want to establish a baseline for future comparisons.

--history — Show drift trends from saved scans

python3 {baseDir}/scripts/scan.py --history

Loads stored scan history and adds a trends section to the output showing per-file growth rates and days-to-limit projections. Requires at least one prior --save scan to produce trend data.

The common combo: --save --history — saves today's scan and shows trends based on all prior saves.

When presenting trends: "AGENTS.md has been growing at about 150 chars per day over the past two weeks. At that rate it hits its 20,000-char limit in roughly 12 days."

--html \x3Cpath> — HTML report

python3 {baseDir}/scripts/scan.py --html ~/.driftwatch/reports/report.html

Generates a self-contained HTML report at the specified path — no external dependencies, no CDN calls. The file includes zone-based progress bars, truncation overlays, and danger zone callouts for at-risk files. This is the primary output format — see Agent Delivery Rules above.

--check — Cron-friendly alert mode

python3 {baseDir}/scripts/scan.py --check

Designed for automation and cron monitoring. Outputs a single summary line to stdout and exits with:

  • 0 — all healthy
  • 1 — warnings present
  • 2 — criticals present

This is the only mode that uses non-zero exit codes. Normal scan mode always exits 0 — the agent interprets the JSON findings. --check is for cron jobs and shell scripts that watch exit codes.

Example one-line outputs:

✓ All clear — 8 files healthy, 18.6% aggregate budget used
⚠ Warning — AGENTS.md at 82% of limit
✗ Critical — MEMORY.md TRUNCATED

Thresholds (configurable in ~/.driftwatch/config.json):

  • Per-file warning: 70% of limit (default)
  • Per-file critical: 90% of limit
  • Aggregate warning: 60%
  • Aggregate critical: 80%
  • Growth rate warning: 200 chars/day

Flag combinations:

  • --check --save — the cron use case: check thresholds AND save a history point
  • --check --json — one-line summary AND full JSON in stdout (both outputs)

--json — Full JSON with --check

python3 {baseDir}/scripts/scan.py --check --json

When --check is used alone, it suppresses the JSON blob and shows only the summary line. Add --json to get both the summary line and the full JSON report.


Truncation Simulation

The simulation module tells you exactly what content is at risk before truncation becomes a problem.

How it works:

OpenClaw keeps the first 14,000 chars (head) and last 4,000 chars (tail) of each bootstrap file. Everything between is cut. The "danger zone" is the gap between those boundaries.

File size Situation
Under 18,000 chars No danger zone — file fits entirely within head + tail
18,001 – 20,000 chars Danger zone exists — content between chars 14,000 and (size - 4,000) is at risk
Over 20,000 chars Actively truncated — that same content is being cut right now

When presenting simulation findings:

If a file is in the danger zone, name the specific sections at risk:

"AGENTS.md has 1,200 characters in the danger zone — lines 350 to 380. If this file grows past 20,000 chars, the ## Delegation Templates section would be the first content your agent loses. Consider moving that section earlier in the file or trimming it."

If a file is actively truncated:

"MEMORY.md is 25,000 characters — 5,000 over the limit. Your agent cannot see lines 290 through 450 right now. That's roughly 7,000 characters of context that's being silently cut every session."

If all files are safe:

"No truncation risk — all files are well under 18,000 characters. The danger zone simulation shows nothing at risk right now."


Suggested Workflows

Baseline + monitoring:

# Establish baseline
python3 {baseDir}/scripts/scan.py --save

# Daily cron check (in crontab: 0 8 * * *)
python3 {baseDir}/scripts/scan.py --check --save

# Weekly review with trends + HTML report
mkdir -p ~/.driftwatch/reports
python3 {baseDir}/scripts/scan.py --history --html ~/.driftwatch/reports/driftwatch-$(date +%Y-%m-%dT%H%M).html

OpenClaw cron integration — add to openclaw.json:

{
  "cron": [
    {
      "schedule": "0 8 * * *",
      "command": "python3 ~/.openclaw/skills/driftwatch/scripts/scan.py --check --save",
      "label": "driftwatch-daily"
    }
  ]
}

When the cron fires and exits non-zero, report the summary line to the operator. Don't be noisy about exit 0.

Sharing a report with teammates:

python3 {baseDir}/scripts/scan.py --history --html ~/.driftwatch/reports/workspace-health.html

Sample Output Interpretation

Here's what a healthy workspace looks like and how to present it:

{
  "summary": { "critical": 0, "warning": 1, "info": 2 },
  "truncation": {
    "files": [
      {
        "file": "AGENTS.md",
        "char_count": 9200,
        "limit": 20000,
        "percent_of_limit": 46.0,
        "status": "ok"
      }
    ],
    "aggregate": {
      "total_chars": 54000,
      "percent_of_aggregate": 36.0,
      "aggregate_status": "ok"
    }
  },
  "compaction": {
    "anchor_sections": [
      { "heading": "Session Startup", "found": true, "char_count": 1200, "status": "ok" },
      { "heading": "Red Lines", "found": true, "char_count": 800, "status": "ok" }
    ]
  },
  "hygiene": {
    "findings": [
      { "severity": "warning", "check": "empty_bootstrap", "message": "IDENTITY.md exists but is empty" }
    ]
  }
}

How to present this:

Workspace looks healthy — no critical issues.

One thing to note: IDENTITY.md exists but is empty. It's taking up a bootstrap slot without contributing anything. Worth filling in or removing.

Bootstrap files are using 54,000 of 150,000 characters (36% of aggregate budget) — plenty of room. AGENTS.md is at 46% of its individual limit, well clear of truncation territory.

Both post-compaction anchor sections are present in AGENTS.md and within the 3,000-char cap.


Notes

  • Character counts, not token counts. OpenClaw enforces char-based limits.
  • Findings are stamped with the OpenClaw version tag they were calibrated against (currently 2026.03). If you're on a different version, limits may differ.
  • The scanner makes zero network calls. Everything runs locally.
  • History data is stored locally in ~/.driftwatch/ — never transmitted.
  • Auto-retention pruning removes history files older than 90 days (configurable in ~/.driftwatch/config.json).
安全使用建议
Driftwatch is internally consistent: it reads OpenClaw workspace files, computes truncation/compaction/hygiene/trends, writes local JSON/HTML reports to ~/.driftwatch, and claims no network usage. Before installing: (1) Review and, if desired, run the scanner locally on a sample workspace to confirm behavior. (2) Be aware the generated HTML report contains workspace contents (which may include sensitive instructions or memory content); only transmit that file over secure channels and only when you intend to share. (3) The skill will create ~/.driftwatch/{reports,history} and may read ~/.driftwatch/config.json — inspect that config if you rely on custom thresholds. (4) Minor non-security inconsistencies (version string and license text differ inside files) are present but do not affect runtime safety. If you expect the agent to automatically post reports to external messaging platforms, ensure those integrations/channels are trusted and authorized.
功能分析
Type: OpenClaw Skill Name: driftwatch-oc Version: 1.1.4 Driftwatch is a workspace health scanner for OpenClaw that monitors file size limits and growth trends. The code is well-structured and follows its stated purpose, performing only local file system operations (reading workspace markdown files and writing reports/history to ~/.driftwatch/). It demonstrates good security practices, such as using restricted file permissions (0o600) for history files in scripts/scan.py and implementing an HTML escaping function (_esc) in scripts/visual.py to prevent XSS in generated reports. No network calls, obfuscation, or malicious instructions were found.
能力评估
Purpose & Capability
Name/description match the code and runtime requirements: the skill reads bootstrap files, computes truncation/compaction/hygiene/trends, and only needs python3 and access to a workspace directory. Reading/writing files under the user's home directory (~/.driftwatch, ~/.openclaw/workspace/) is consistent with the stated purpose.
Instruction Scope
SKILL.md's runtime instructions stay within the stated purpose (run scan, save history, generate HTML). One operator-facing instruction: 'On messaging surfaces (Telegram, Discord, Signal): send the HTML file to the user' calls for transmitting a local report to messaging channels — that is expected for delivery but is the primary place where sensitive workspace content could leave the machine depending on how the agent is configured. The code itself does not implement network calls.
Install Mechanism
No install spec; skill is instruction+source bundle. All code is local Python with no external package downloads or extract steps. This is low-risk from an install/remote code-fetch perspective.
Credentials
The skill requests no credentials or special env vars. It reads OPENCLAW_WORKSPACE (if set) and standard home-dir paths; it creates ~/.driftwatch/* for reports/history and reads ~/.driftwatch/config.json if present. Those accesses are reasonable and proportionate to workspace scanning and trend tracking.
Persistence & Privilege
The skill stores reports and history under ~/.driftwatch and reads a local config file; it does not request permanent platform-wide privileges or set always:true. It does not modify other skills' configs. This level of persistence is consistent with the stated drift-tracking function.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install driftwatch-oc
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /driftwatch-oc 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.1.4
driftwatch-oc 1.1.4 - Added explicit agent delivery rules: always generate and send an HTML report for each scan, with channel-specific instructions for sharing results. - HTML reports are now timestamped and stored for historical review; never overwritten. - Documented separate behaviors for messaging surfaces versus terminal/CLI. - Exception handling for `--check` mode clarified: skips HTML except when explicitly set. - Added LICENSE file.
v1.1.3
driftwatch-oc 1.1.3 HTML report redesign: Overhauled the bootstrap file size analysis report with zone-based status indicators. Each file now falls into one of four states: healthy (below per-file typical threshold), warning (above typical), danger (approaching 18K), or truncated (≥20K). Per-file typical thresholds based on community best practices. Progress bars change color by zone (green, amber, red) with tick marks at the per-file typical boundary and the 18K danger line. Files over 20K switch to a three-zone truncation view showing HEAD 14K, cut content with exact char count, and TAIL 4K — with the affected line range called out beneath. Aggregate bar shows a two-zone cutoff display when total exceeds 150K. Inline callout text now appears beneath warning and danger bars: "Larger than typical — review for unnecessary content" and "Approaching truncation — trim now to avoid data loss." Truncated files show "Lines X–Y are invisible to your agent right now." Other changes: Summary metrics replaced Critical/Warning/Info with Warning, Danger, Truncated counts. Compaction section renamed to "Compaction survival check" with explanatory subtitle, removed /3,000 cap denominator. Standalone Truncation Simulation card removed — same information now shown inline on each bar. All percentages rounded to whole numbers. Limit labels shortened (20K, 150K, HEAD 14K, TAIL 4K). Tick lines changed to white with red labels for better visibility on dark theme. Flat bar colors throughout. README updated to reflect current features.
v1.1.2
driftwatch-oc 1.1.2 Corrected subagent bootstrap allowlist to 5 files from 2.
v1.1.1
driftwatch-oc V1.1.1 — Accuracy & Hygiene Fixes - Fixed SUBAGENT_FILES constant: reduced from 5 to 2 files to match OpenClaw source (workspace.ts:293). Only AGENTS.md and TOOLS.md are injected into subagent sessions. - Updated missing-subagent hygiene check to reflect the corrected 2-file allowlist. - Reframed compaction anchor sections ("Session Startup", "Red Lines") as recommended workspace conventions, not source-enforced requirements. - Downgraded missing anchor section severity from critical to warning. - Fixed duplicate finding: files caught by the duplicate_memory check no longer appear redundantly in extra_files. - Added .pyc to .gitignore.
v1.1.0
**Driftwatch 1.1.0 — Major Upgrade: Adds Workspace Health Scanning and Visualization** - Introduced modular scanning: now checks for truncation risk, compaction anchor health, workspace hygiene, and identity drift in a single run. - Reorganized codebase with new scripts for scan, hygiene, compaction, simulation, trends, truncation, and visuals. - New output options: JSON, HTML report, terminal bar chart, summary alerts for cron, and drift history tracking. - Added trend analysis, truncation simulation, and visual risk mapping for at-risk files and aggregate workspace health. - Old monolithic script removed; usage is now via the `scripts/` directory and more flexible CLI flags. - SKILL.md rewritten: detailed module descriptions, flags reference, and updated operator guidance.
元数据
Slug driftwatch-oc
版本 1.1.4
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 5
常见问题

Driftwatch 是什么?

Scan your OpenClaw workspace for truncation risks, compaction anchor health, workspace hygiene, and drift tracking over time. Use when the operator asks to "... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 208 次。

如何安装 Driftwatch?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install driftwatch-oc」即可一键安装,无需额外配置。

Driftwatch 是免费的吗?

是的,Driftwatch 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Driftwatch 支持哪些平台?

Driftwatch 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Driftwatch?

由 UncleD(@danandbub)开发并维护,当前版本 v1.1.4。

💬 留言讨论