Skip to content

okf-mail-watch

Local Outlook thread-precedent mail filing watcher - watches the firm inbox and files new mail into the Clio Manage Open tree by thread precedent. Use when asked about the mail watcher, filing new inbox mail by thread precedent, rebuilding the thread index, or checking what the watcher has filed.

Source: .opencode/skills/okf-mail-watch/SKILL.md — site rebuilt 2026-09-05.


okf-mail-watch — local Outlook thread-precedent mail filing watcher

Watches the firm inbox and files new mail into the Clio Manage\The Building Law Practice Limited\Open\<client>\<matter> tree by thread precedent — the same rule that proved itself in the 2026-08-11 sweep (every thread had a clear home; the only misfiles were threads whose number/name had to be resolved by hand).

How it files

For each new item in the Inbox tree (Inbox + subfolders, last 2 hours):

  1. Read its ConversationIndex base (first 32 hex chars — the thread's stable ID, shared by every reply in both directions).
  2. Look up the most recent item in that thread already filed under ...\Open\ (cached index of thread ID -> folder path, rebuilt every 6 hours or with -RebuildIndex).
  3. Precedent folder under Open -> move the new item there.
  4. No precedent (opponent cold-starts a fresh subject) or precedent outside Open (e.g. House/Office threads) -> leave in Inbox, log it. With -Suggest, a no-precedent item whose Subject contains exactly one 5-digit number matching an OPEN Clio matter is tagged in place with category OKF-<num>? for the user to confirm by moving — the move then becomes thread precedent for the rest of the thread.

Moves file mail; suggest-tags are advisory only and never move anything. Nothing is ever deleted. The watcher never guesses: ambiguous or unmatched subjects are left alone.

Files

  • tools/okf_mail_watch.ps1 — the watcher. Deployment copy (space-free path for Task Scheduler) lives at %LOCALAPPDATA%\okf-mail-watch\.
  • State + log: %LOCALAPPDATA%\okf-mail-watch\state.json, watch.log (append-only audit trail of every move/suggestion).
  • Matter cache: %LOCALAPPDATA%\okf-mail-watch\clio_matters.json (open matters only, refreshed at most once per 24 h via the read-only clio skill client — Outlook folder names equal Clio display_number, so the 5-digit prefix is the join key).

Usage

# one poll (what the scheduled task runs)
powershell -NoProfile -ExecutionPolicy Bypass -File <script>

# continuous loop
powershell ... -File <script> -Daemon

# report only, never move, never tag
powershell ... -File <script> -DryRun

# tag no-precedent items with matter number for user confirm
powershell ... -File <script> -Suggest

# report what would be suggested, change nothing (trial mode)
powershell ... -File <script> -Suggest -DryRun

# force full re-index
powershell ... -File <script> -RebuildIndex

Scheduling

Task Scheduler task OKF Mail Watch: schtasks /Create /TN "OKF Mail Watch" /TR "powershell.exe -NoProfile -ExecutionPolicy Bypass -File C:\Users\antho\AppData\Local\okf-mail-watch\okf_mail_watch.ps1" /SC MINUTE /MO 2 /ST 06:00 /DU 999:59 /F

  • Every 2 minutes while the user is logged in (interactive only).
  • Lock file prevents overlapping polls (index scan takes ~2 min).
  • Re-register after editing the source: copy the script to %LOCALAPPDATA%\okf-mail-watch\ again (the task runs the copy).
  • Disable/stop: schtasks /Change /TN "OKF Mail Watch" /DISABLE (or schtasks /Delete /TN "OKF Mail Watch" /F).

Notes / limits

  • Requires Outlook to be running and the mailbox online (local COM).
  • The thread index covers only the Open tree; Pending/Closed/other stores are not scanned.
  • Index staleness: threads first filed by hand are picked up at the next full rescan (≤6 h) — move them manually or run -RebuildIndex after a big filing session to refresh immediately.
  • Graph migration (number-free precedent lookups on conversationId, no Outlook dependency) is the planned upgrade path — see conversation.