# 2026-02-05 Session Notes

## Major Features Implemented

### Sell Phase - DealsBoard React Component
- Replaced static HTML iframe with native React component
- Notes/stage changes now persist to `deals.yaml` via API
- Real-time updates, no page refresh needed

### AI Generation - Streaming UX
- Built SSE streaming endpoint `/api/products/[slug]/sell/generate-stream`
- Real-time text streaming with blinking cursor (like ChatGPT)
- Uses Anthropic API directly with `ANTHROPIC_API_KEY` in `.env.local`
- Generates outreach emails and proposals
- Now references full marketing context: prd.md, target-market.md, pricing.md, gtm-strategy.md, landing-page.md

### Apollo Enrichment
- Built instant enrichment endpoint `/api/products/[slug]/sell/enrich`
- Uses Apollo API key in `.env.local`
- Endpoint: `POST https://api.apollo.io/v1/people/match`
- Header: `x-api-key` (lowercase)
- Fixed name parsing to strip honorifics (Dr., Fr., etc.)
- Updates deal in deals.yaml with email, phone, LinkedIn

### Build Phase - New 2-Stage Workflow
1. **Stage 1**: Generate `build-plan.md` + `build-plan.html` (20%) → PAUSE at `plan_ready`
2. **Human reviews** the plan
3. **Stage 2**: Click "Start Build" → Coding agent executes (40% → 100%)
4. Saves to `build-details.yaml` → Component displays controls

Created:
- `agency/templates/build-plan-prompt.md` - Comprehensive build plan template
- `/api/products/[slug]/build/start/route.ts` - Start build endpoint
- `/api/products/[slug]/build/details/route.ts` - Get build details
- `src/components/build/BuildSummary.tsx` - React component with Start/Stop/View/GitHub

### GitHub Team Access
- All repos now get `@symphco/symph-devs` team with Write access
- Command: `gh api -X PUT /orgs/symphco/teams/symph-devs/repos/symphco/{slug} -f permission=push`

## Key Files Modified
- `.env.local` - Added ANTHROPIC_API_KEY and APOLLO_API_KEY
- `next.config.mjs` - Exposed env vars
- `HEARTBEAT.md` - Updated build pipeline, added generate-outreach/proposal job handlers

## Technical Learnings
- Next.js needs rebuild to pick up new env vars in production
- Use `.env.local` instead of systemd Environment= for secrets
- Apollo API uses `x-api-key` header (lowercase)
- Name parsing needs to handle honorifics (Dr., Fr., Prof.)
- Spawn subagents for long tasks to stay responsive

## AI Teacher Assistant
- Reset build phase to test new workflow
- Preserved: port 3003, domain, GitHub repo
- Generated new build plan with architecture, diagrams, flows, timeline
- Status: `plan_ready` - waiting for human review before coding starts
