Appearance
The Vibe server router coordinates prompts, session state, and workspace changes.
Prompt lifecycle
- The client sends
POST /_vibe-agent/promptwith a prompt and component path. - The router builds a structured prompt using
promptBuilder()(including component hierarchy when provided). agentRouter.routePrompt()dispatches to either localclaude-codeor the remote Claude host, based on environment flags.- Session updates trigger
eventEmitterbroadcasts so SSE clients stay in sync. - After the prompt finishes, the workspace is scanned for changes and
triggerHMR()touches modified files.
Session updates
- Session state is held by
session()and exposed viaGET /_vibe-agent/session-response. GET /_vibe-agent/sseinitializes the SSE stream and immediately publishes the current session.DELETE /_vibe-agent/session-responseclears the response and think steps.
Workspace tracking
The workspace helper:
- Calculates additions, deletions, affected files, and branch name via git.
- Drops changes with
git checkout -- .andgit clean -fd. - Resets to main with
git reset --hard origin/main.