Haygen

Sessions/2026-05-04-initial-build.md

Session 1 — Initial Build (2026-05-04)

What happened

Full greenfield build of heygen-avatar npm + heygen_avatar Python package in a single session using subagent-driven development (10 tasks, TDD + 2-stage spec/quality review per task).

Journey

  1. Requirements gathering — brainstormed the vision, clarified Full vs Lite modes, locked scope vs Phase 2 (screen annotation)
  2. PRD — written at docs/requirements/PRD-heygen-avatar-package.md
  3. Implementation plan — 10-task TDD plan with Protocol Read Receipts for all SDK APIs
  4. Worktreegit worktree add .worktrees/feature-heygen-avatar-package -b feature/heygen-avatar-package
  5. Tasks 0–9 — all built, spec-reviewed, quality-reviewed, APPROVED

Key bugs found and fixed during build

Bug Where caught Fix
tsup shebang banner applied to ALL entries (not just CLI) Code quality review Split tsup config into array of two configs
CLI tree-shaking — dist/cli.js was empty Code quality review (Task 8) Point tsup entry directly at src/cli/index.ts; delete stub
USER_END_MESSAGE has no message field Plan research / ADR-003 Accumulation pattern in attachLiteLoop
@heygen/streaming-avatar CJS/ESM conflict in vitest Test run failure server.deps.inline in vitest.config.ts
Two-phase SDK init needed for test timing Test failure analysis Sync Phase 1 creates SDK before first await
types condition after import/require in exports map Code quality review Reorder: types first
Extra validation guards removed then re-added Spec review oscillation Root cause: spec review summary was incomplete; fixed by using full plan text

Final state

  • 40 TypeScript tests passing (9 files)
  • 7 Python tests passing (2 files)
  • Build clean, typecheck clean
  • All 10 tasks APPROVED
  • Smoke test scaffolded at example/nextjs — awaiting HEYGEN_API_KEY

Commits

21 commits on feature/heygen-avatar-package. See git log --oneline in worktree.

Next session

  1. Run smoke test with real API key
  2. Write README
  3. Merge to main, publish npm + PyPI