Watcher & Mining
Automatically capture project knowledge from your code comments without leaving your workflow.
The Watcher
The watcher is a background process that monitors your source files for changes using Chokidar. When it detects modifications, it scans for signal phrases in code comments.
Start the watcher
# Run in the foreground
$ lore watch
# Run as a background daemon
$ lore watch --daemon
# Stop the background daemon
$ lore watch --stop
Signal Phrases
The watcher and miner look for specific phrases in your code comments that indicate lore-worthy knowledge:
| Signal Phrase | Drafted As | Example |
|---|---|---|
WARNING: |
Gotcha | // WARNING: This API returns 201, not 200 |
HACK: |
Gotcha | // HACK: Workaround for async race condition |
IMPORTANT: |
Invariant | // IMPORTANT: Must validate before saving |
we chose |
Decision | // we chose Postgres for ACID compliance |
TODO: |
Gotcha | // TODO: Fix edge case with empty arrays |
Comment Mining
For an immediate one-time scan (instead of continuous watching), use the mine command:
# Scan all files
$ lore mine .
# Scan a specific directory
$ lore mine src/api
# Scan a single file
$ lore mine src/utils/auth.js
Mined comments are saved as drafts in .lore/drafts/, not as confirmed
entries. Review them with lore drafts.
Auto-Drafting Heuristics
Beyond signal phrases, the watcher uses behavioral heuristics:
- File deletion: If a file with more than 100 lines is deleted, a Graveyard draft is created
- Frequent edits: If the same file is modified 5+ times in a week, a Gotcha draft is created
- Large commits: The git post-commit hook intercepts commits with >50 changed lines and prompts you to log a Decision
Reviewing Drafts
# Review all drafts interactively
$ lore drafts
# Auto-accept drafts with high confidence (≥ 0.8)
$ lore drafts --auto
Each draft shows the source file, signal phrase matched, and a confidence score. You can accept, edit, or discard each one.