# What Makes AetherGuard Unique
AetherGuard is a CLI-installed, local-first daemon that watches a repo, uses Gemini
to predict next-logical code, and audits/auto-fixes bugs and vulnerabilities in
real time. A few implementation details set it apart from typical "AI coding
assistant" side projects.
# 1. Auto-applies security fixes to live files — unattended
triggerAutoAudit() doesn't just flag critical vulnerabilities, it patches them
directly on disk when AUTO_FIX_ENABLED is on — but only after verifying the
exact old code still matches at that line:
that guard against stale or hallucinated line numbers is the detail that
separates "cool demo" from "safe to run unattended."

## 2. Debounced, watch-triggered self-healing loop
File change → chokidar fires → 2s debounce collapses rapid edits into one
audit → Gemini call → auto-fix → write back to disk, in a closed loop with no
human in it unless AUTO_FIX_ENABLED=false. Every applied fix is logged
(`autoFixLog`, capped at 200 entries) so there's an audit trail of what the AI
changed and why.
3. Model failover baked into every AI call
callGeminiWithFailover tries gemini-2.5-flash, then falls back to
gemini-2.0-flash-lite, with retry-on-transient-error logic (503, 429,
"overloaded", etc.). Most hobby AI tools call the model once and just fail;
this treats API flakiness as an expected condition.
## 4. BYOK as a first-class runtime feature, not just an env var
/api/set-key lets a user set their Gemini key at runtime through the UI — no
restart needed — and /api/key-status reports whether the key came from env
or was set live. That's built for handing the tool to other people, not just
running it yourself.
# 5. Path-traversal guard on live file read/write
readLiveFile / writeLiveFile check fullPath.startsWith(TARGET_DIR) before
touching disk. Since this tool can read and write arbitrary files in a
directory you point it at, that check is load-bearing, not decorative.
## 6. The prediction UI sells "pattern learning" at the UX level
CodeEditor.tsx badges predictions as "Pattern Matches Found" and offers
ranked alternatives (not just one completion), with an "Auto-Inject
Completion" action that splices into the exact cursor line — reinforcing the
repo-pattern-learning pitch in the UI, not just in the system prompt.
# Honest caveat: pattern learning is re-derived, not persisted
The "pattern learning" is prompt-driven — Gemini reads the full repo content
on every audit call and is instructed to detect patterns fresh each time. It's
not a trained or persisted model. In practice, "learns your patterns" means
"re-derives them from full repo context every audit," which is simpler than it
sounds and currently has no long-term memory of patterns between sessions
unless the patterns output is being stored somewhere outside server.ts.