feat: AI-assisted flow builder with 4-stage wizard #87

Merged
chihlasm merged 25 commits from feat/ai-flow-builder into main 2026-02-23 05:03:54 +00:00
chihlasm commented 2026-02-20 13:07:27 +00:00 (Migrated from github.com)

Summary

  • Implements complete AI flow builder using a 4-stage guided wizard (Foundation → Scaffold → Branch Detail → Review & Assemble) with Claude Haiku for cost-efficient structured JSON generation (~$0.01-0.03/flow)
  • Backend: new ai_conversations and ai_usage tables, Alembic migration, quota enforcement (monthly + daily with billing anchor), Anthropic API integration with static system prompts for prompt caching, tree structure validation, conversation CRUD with 24h TTL + APScheduler cleanup, 5 API endpoints (GET /ai/quota, POST /ai/start, /scaffold, /branch-detail, /assemble)
  • Frontend: Zustand store for wizard state, 7 components (AIFlowBuilderModal, WizardStepIndicator, FoundationForm, BranchSelector, BranchDetailView, TreePreviewCard, QuotaDisplay), "Build with AI" button in MyTreesPage create menu (hidden when ANTHROPIC_API_KEY not set)
  • 25 tests: 14 validator unit tests + 11 endpoint integration tests with mocked Anthropic (zero real API spend)

Test plan

  • alembic upgrade head — new tables created, seed values inserted
  • pytest tests/test_ai_tree_validator.py tests/test_ai_endpoints.py — 25 tests pass
  • Set ANTHROPIC_API_KEY, verify GET /ai/quota returns ai_enabled: true
  • Remove key, verify button hidden and ai_enabled: false
  • Full wizard flow: Foundation → Scaffold → Branch Detail → Review → Open in Editor
  • npm run build — zero TypeScript errors

🤖 Generated with Claude Code

## Summary - Implements complete AI flow builder using a 4-stage guided wizard (Foundation → Scaffold → Branch Detail → Review & Assemble) with Claude Haiku for cost-efficient structured JSON generation (~$0.01-0.03/flow) - Backend: new `ai_conversations` and `ai_usage` tables, Alembic migration, quota enforcement (monthly + daily with billing anchor), Anthropic API integration with static system prompts for prompt caching, tree structure validation, conversation CRUD with 24h TTL + APScheduler cleanup, 5 API endpoints (`GET /ai/quota`, `POST /ai/start`, `/scaffold`, `/branch-detail`, `/assemble`) - Frontend: Zustand store for wizard state, 7 components (AIFlowBuilderModal, WizardStepIndicator, FoundationForm, BranchSelector, BranchDetailView, TreePreviewCard, QuotaDisplay), "Build with AI" button in MyTreesPage create menu (hidden when `ANTHROPIC_API_KEY` not set) - 25 tests: 14 validator unit tests + 11 endpoint integration tests with mocked Anthropic (zero real API spend) ## Test plan - [ ] `alembic upgrade head` — new tables created, seed values inserted - [ ] `pytest tests/test_ai_tree_validator.py tests/test_ai_endpoints.py` — 25 tests pass - [ ] Set `ANTHROPIC_API_KEY`, verify `GET /ai/quota` returns `ai_enabled: true` - [ ] Remove key, verify button hidden and `ai_enabled: false` - [ ] Full wizard flow: Foundation → Scaffold → Branch Detail → Review → Open in Editor - [ ] `npm run build` — zero TypeScript errors 🤖 Generated with [Claude Code](https://claude.com/claude-code)
railway-app[bot] commented 2026-02-20 13:07:36 +00:00 (Migrated from github.com)

🚅 Deployed to the patherly-pr-87 environment in selfless-grace

Service Status Web Updated (UTC)
hopeful-liberation Success (View Logs) Web Feb 23, 2026 at 4:56 am
patherly Success (View Logs) Web Feb 23, 2026 at 4:56 am
<!-- railway-bot-comment-version=2 --> <!-- railway-project-id="22b9b58c-271b-42e5-a10e-6fdec8d00134" railway-project-name="selfless-grace" --> 🚅 Deployed to the [patherly-pr-87](https://railway.com/project/22b9b58c-271b-42e5-a10e-6fdec8d00134?environmentId=59252617-b8e0-417c-898c-325305287475) environment in **[selfless-grace](https://railway.com/project/22b9b58c-271b-42e5-a10e-6fdec8d00134)** | **Service** | **Status** | **Web** | **Updated** (UTC) | | :--- | :--- | :--- | :--- | | hopeful-liberation | ✅ Success ([View Logs](https://railway.com/project/22b9b58c-271b-42e5-a10e-6fdec8d00134/service/e1db2ee3-d241-4f45-abe4-c9c5fdf483d5?id=0977b77e-bc2a-485b-9994-86aba046ee3c&environmentId=59252617-b8e0-417c-898c-325305287475)) | [Web](https://hopeful-liberation-patherly-pr-87.up.railway.app) | Feb 23, 2026 at 4:56 am | | patherly | ✅ Success ([View Logs](https://railway.com/project/22b9b58c-271b-42e5-a10e-6fdec8d00134/service/95f556ff-5264-4116-a0c2-618a2fc53ba4?id=b76e891e-d15e-4337-839c-b92e6986475e&environmentId=59252617-b8e0-417c-898c-325305287475)) | [Web](https://patherly-patherly-pr-87.up.railway.app) | Feb 23, 2026 at 4:56 am |
Sign in to join this conversation.