How It Works
Automatic Activation
File watching starts automatically afterindex_codebase completes:
start_watch separately.
Event Processing
Debouncing
SHARC waits 2 seconds after the last file change before processing. This:- Batches rapid changes (e.g., IDE auto-save)
- Reduces redundant API calls
- Prevents indexing incomplete saves
Deduplication
If the same file changes multiple times within the debounce window, only the final state is indexed.Hash Checking
Before re-indexing a file, SHARC compares SHA-256 hashes:- Same hash: Skip (no actual change)
- Different hash: Re-index the file
Syntax Guard
SHARC validates syntax before indexing to prevent corrupted vectors:Supported Languages
Full AST validation for:- TypeScript / JavaScript
- Python
- Go
- Rust
- Java
- C / C++
- C#
- Scala
How It Works
- Parse file syntax
- Check for syntax errors
- If errors found:
- Keep old vectors (don’t corrupt the index)
- Skip indexing until syntax is fixed
- If valid:
- Remove old vectors
- Index new content
Example Scenario
File Filters
Soft ignore rules
SHARC merges ignore rules from four sources, in this precedence order:- Default ignore patterns
- Root
.gitignorepatterns - Root
.sharcignorepatterns ignorePatternspassed toindex_codebase
Hard safety blocks
Some paths and files are always blocked even if they are not in ignore patterns. Blocked system paths:- Windows:
C:\Windows,C:\Program Files,C:\Program Files (x86),C:\ProgramData,$Recycle.Bin,System Volume Information - POSIX:
/proc,/sys,/dev,/run,/boot,/lib,/lib64,/system,/Library,/private/var/vm
- Secret/env files:
.env,.env.*(except.env.example) - Key/cert files:
.pem,.key,.p12,.pfx - Binaries/media/archives/docs: executable, object, image, audio/video, archive, and office/PDF file types
- OS/editor artifacts:
.DS_Store,Thumbs.db,.suo,.ntvs_analysis.dat
Size Limits
- Maximum file size: 1MB
- Files larger than this are skipped (usually generated/minified code)
Custom Extensions
Add custom file types during indexing:Custom Ignore Patterns
Exclude specific files or directories:static/**excludes a directory tree*.tmpexcludes matching files at any depthprivate/**excludes private source trees
vendor/**, third_party/**, and generated/** are not enabled by default; add them via ignorePatterns when needed.
Performance
| Event | Processing Time | Notes |
|---|---|---|
| Single file modify | ~2-3s | Debounce + embed + store |
| Multiple files (batch) | ~3-5s | Parallel embedding |
| Large file (>100 chunks) | ~5-8s | More chunks to process |
| No actual change | ~0.1s | Hash check, skip |
| Syntax error | ~0.1s | Skip, keep old vectors |
Manual Control
Stop Watching
To disable automatic updates:Resume Watching
To re-enable:Check Status
Troubleshooting
Changes Not Detected
- Verify watching is active:
get_watch_status - Check file extension is supported
- Ensure file is not in ignored patterns
- File might be too large (>1MB)
Slow Updates
- Check network connectivity
- Large files take longer to process
- Many simultaneous changes batch together