── Quality Tracker ──
{ "status": "production", "rating": "★★★★★", "last_used": "2026-07-16", "total_uses": 1, "trace": [ {"date": "2026-07-16", "usage": "Added agent-skills", "result": "✅ In production use"} ] }
What does Vite Agent Debugger do?
Gives agents working in Vite projects runtime visibility, running the self-healing loop of "read logs → locate → fix → restart dev → verify".
Companion npm package: vite-plugin-agent-eyes (source code and full docs: webkubor/vite-plugin-agent-eyes).
For agent workflow only, prefer reading AGENT_GUIDE.md; for Codex, Claude, Gemini, Hermes to discover and use autonomously, read AGENT_BOOTSTRAP.md; the README is for human installation and evaluation.
When to Use
- User reports "page broken / can't log in / request failed / cookie issue" — but you shouldn't guess the code — read telemetry first.
- You've made changes and need to verify: restart dev, trigger an action, read logs to confirm correct behavior.
- To restore a logged-in UI or browser console, first check
log/<port>/auth-state.jsonfor the current account profile, then readlog/<port>/interaction.logto replay recent interaction paths. - When a user's commit is blocked by a guard, or you need to proactively avoid obvious errors / code smells, first read
log/guard-report.json. - To instrument a Vite project that hasn't yet been upgraded with these capabilities.
Setup (One-time, 3 Steps)
// 1. vite.config.ts
import { agentDebugger, agentProxy } from 'vite-plugin-agent-eyes'
export default defineConfig({
plugins: [agentDebugger({ screenshots: true })], // screenshots optional, enables CDP screenshots
server: { proxy: { '/api': agentProxy('https://your-api.example.com') } },
})
// 2. Application entry file (main.ts / main.tsx / main.js / index.js — framework-agnostic)
Recommended: one-line auto-instrumentation, which automatically wraps fetch/XHR, route navigation, global errors, full console, DOM snapshots, and sanitized interaction traces:
import { autoInstrument } from 'vite-plugin-agent-eyes/client'
autoInstrument()
Or manual instrumentation (for fine-grained control):
import { installAgentErrorReporter, logApiCall, logConsoleEntry, snapshotDom } from 'vite-plugin-agent-eyes/client'
installAgentErrorReporter() // captures global errors + full console + DOM snapshot
// In fetch/ky/axios interceptor, call after each request completes
logApiCall({ method, path, url, ok, duration_ms, code, status, request_id, error, request, response })
logConsoleEntry('warn', ['deprecated API called'])
Record sanitized account profile after login success:
import { recordLoginSuccess } from 'vite-plugin-agent-eyes/client'
recordLoginSuccess({ userId, email, name, roles, tenantId })
Only sanitized profile is saved; no token/cookie. Accessible in the browser via window.__AGENT_EYES_AUTH__, file at log/<port>/auth-state.json.
Interaction traces are installed by autoInstrument() by default, written to log/<port>/interaction.log. input / change only record <redacted>, never actual form values.
Without the package installed and need temporary use: prefer git / workspace installation of this package; do not just copy src/index.ts / src/client.ts — they depend on cdp, git, guard-* modules in the same directory.
Commit Governance: agentGit / agentGuard / agentSizeWatch (Quick Config Reference)
The three responsibilities (hooks are set/overwritten at dev startup by the plugin with apply:'serve' — after changing configuration or upgrading the package, you must run pnpm dev once for them to take effect; for Astro projects, add to astro.config's vite.plugins):
| Plugin | Timing | Effect |
|---|---|---|
agentGit | Before/after commit | Replaces husky: runs precommit commands + can embed guard; sends Feishu notification after commit. Built-in rebase/cherry-pick replay deduplication |
agentGuard | During commit | Hard blocks staged files: secrets / large files / long lines / TODO / any / console.log. If using agentGit, configure inside agentGit({ guard }), don't mount it separately (would cause pre-commit contention) |
agentSizeWatch | During dev coding | Warns for very long files in the console with [agent-eyes:size]; warns only, never blocks. Specifically for preventing AI-generated bloated CSS |
Example config (as used in this project's three repos):
agentGit({
projectLabel: 'Main Website',
precommit: ['sh scripts/precommit.sh'], // any non-zero exit blocks the commit
webhook: [{ url: 'https://open.feishu.cn/open-apis/bot/v2/hook/xxxx', format: 'feishu' }],
guard: { level: 'block', fileLength: { warn: 400, block: 800 } }, // hard block on code smells
claimHooksPath: true, // if global core.hooksPath (e.g., lefthook) shadows this repo's hooks, set local override
force: true, // take over existing non-plugin pre-commit hooks
})
// Real-time dev warning (optional, mounted independently): agentSizeWatch({ warn: 400, cssWarn: 300 })
level: warn only reports / block (recommended) blocks on red lines / strict currently same as block.
guard.checks: ['secrets','largeFiles','fileLength','todo','noAny','noConsoleLog'], can toggle individually.
Two 0.12.0 behaviors you must know before configuring guard (or you'll think it's a bug):
-
Lockfiles/compressed artifacts are not counted in
fileLength:pnpm-lock.yaml/package-lock.json/yarn.lock/*.lock/go.sum/.min.js|cssare automatically skipped — generated code, not hand-written. To extend the list, modifyGENERATED_FILE_PATTERN(must sync both copies in guard-core + guard-hook). -
Webhook won't self-injure:
agentGitautomatically injects its configured webhook URL into guardallowSecrets, so secret check won't flag it as a leak. To manually allow other string literals, useguard.allowSecrets: [...]. -
guard only checks staged files; latest JSON report is at
log/guard-report.json. -
For full option table, see the README
### agentGit / agentGuard / agentSizeWatchAPI section.
Self-Healing Loop (Core, Execute strictly)
- First read
log/README.md— project self-documentation, confirms which port logs are in and what each stream shows. - Read
log/<port>/errors.log— locate "what broke" (latest first,headis enough). - Drill down based on clues:
- Unclear reproduction path →
log/<port>/interaction.logfor click/input/change/submit/route order. - API/field issues →
log/<port>/api-calls.logfor actual request/response bodies (never guess fields based on types). - Console warnings/debug info →
log/<port>/console.logfor all-level output (React dev warnings, library deprecations, etc.). - Login/cookie/CORS/302 etc. network layer →
log/<port>/proxy-<host>.logforCookie(req)andSet-Cookie. - Restore logged-in UI →
log/<port>/auth-state.jsonfor current account profile. - Visual issues →
log/<port>/snapshots/for error screenshots (PNG) + DOM snapshots (HTML). - Pre-commit guard issues →
log/guard-report.jsonfor block/warning details.
- Unclear reproduction path →
- Noise prediction: 401 on
/auth/sessionwhen not logged in, browser extensionruntime.lastError— these are expected noise, not bugs, don't chase them. - Edit code → restart dev server (Vite config/plugin changes don't reload via HMR, must restart) → re-trigger → re-read logs to verify. Logs are cleared on each startup; you only see the current session.
Signature Diagnosis: Login Succeeds but Constant 401
log/<port>/api-calls.log: POST .../auth/login code=0 ← login success
log/<port>/api-calls.log: GET .../auth/session code=40101 ← immediately after, not logged in
log/<port>/proxy-<host>.log: GET .../auth/session → 200 | Cookie(req): none ← browser didn't send cookie
Root cause: The upstream Set-Cookie header has Domain=<parent domain> + Secure + SameSite=None, locally http://localhost domain mismatch + Secure dropped → cookie rejected.
agentProxy already fixes this by default in dev (removes Domain / strips Secure / changes SameSite=None→Lax). To disable: agentProxy(target, { rewriteCookiesForLocalhost: false }).
Log Quick Reference
| File | What to Look At |
|---|---|
log/<port>/errors.log | API failures + front-end runtime errors (aggregated, deduplicated, with frequency) |
log/<port>/console.log | Full-level console output (log/warn/error/info/debug) |
log/<port>/interaction.log | Sanitized interaction traces (click/input/change/submit/route) |
log/<port>/api-calls.log | All API calls + routes, with request/response bodies |
log/<port>/proxy-<host>.log | Proxy layer Cookie / Set-Cookie attributes / status (per-proxy by host file) |
log/<port>/auth-state.json | Most recent login success sanitized account profile |
log/<port>/snapshots/err-*.png | Error screenshots (requires CDP, auto-detects port) |
log/<port>/snapshots/dom-*.html | DOM snapshots (always available, no CDP needed) |
log/guard-report.json | Most recent pre-commit guard JSON report |