Overview
VibeLearn implements 5 lifecycle hooks. Each hook is a TypeScript file compiled to an ESM script and run as a subprocess by the IDE.Hook 1: SessionStart
When: Before the agent loop begins (once per session). Input:{ session_id, cwd, project }
What it does:
- Checks if project is in
VIBELEARN_EXCLUDED_PROJECTS→ exit 0 if excluded - Polls
GET /api/readinesson port 37778 (up to 75 retries × 200ms = 15s) - If worker unavailable after retries → starts worker via Bun
- Returns
{ "continue": true }
Hook 2: UserPromptSubmit
When: When user submits a prompt. Input:{ session_id, prompt, cwd }
What it does:
- Strips
<private>...</private>tags from the prompt (viatag-stripping.ts) - Posts
{ contentSessionId, project, prompt }toPOST /api/sessions/init - Returns
{ "continue": true }— never modifies the prompt content
Hook 3: PostToolUse
When: After every tool call (Write, Edit, Bash, MCP tools). Input:{ session_id, tool_name, tool_input, tool_response, cwd }
What it does:
- Maps tool_name to observation type:
Write/Edit→file_edit(extractsfile_path, content truncated at 10KB)Bash→bash_command- Other MCP tools →
mcp_tool
- Posts observation to
POST /api/sessions/observations(fire-and-forget) - Skips tools in
VIBELEARN_SKIP_TOOLSsetting
Hook 4: Stop (Analysis Trigger)
When: Agent loop ends (user stops or AI finishes its task). Input:{ session_id, transcript_path, last_assistant_message }
What it does — calls 5 endpoints sequentially:
Hook 5: SessionEnd
When: Session fully ends (process exiting). What it does: Final cleanup — logs session end, exits 0.Session State Machine
Worker Communication
All hooks communicate with the worker over HTTP onlocalhost:37778. The worker must be running for hooks to function.
If the worker is down:
- SessionStart attempts to restart it
- PostToolUse fails silently (fire-and-forget)
- Stop — each pipeline step fails independently and logs the error
Implementation Reference
Built hooks land at:plugin/scripts/session-start-hook.jsplugin/scripts/user-prompt-submit-hook.jsplugin/scripts/post-tool-use-hook.jsplugin/scripts/summarize-hook.jsplugin/scripts/session-end-hook.js
src/hooks/*.ts. Built with esbuild (scripts/build-hooks.js).
