Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
dee4354
Dev environment fixes: replace rolldown-vite with Vite, disable Cloud…
Oct 4, 2025
97174b7
chore: workspace housekeeping (ignore .history)
Oct 4, 2025
71e3e21
chore(worker): update wrangler.jsonc config for production and local dev
Oct 4, 2025
e67347f
ci: switch to npm (npm ci) and ignore bun.lock to fix Cloudflare froz…
Oct 4, 2025
b21352d
chore: trigger Cloudflare build (use npm ci)
Oct 4, 2025
86530d8
build: remove @cloudflare/vite-plugin to resolve npm peer conflict (v…
Oct 4, 2025
866500d
build(ci): regenerate package-lock and remove @vitejs/plugin-react-ox…
Oct 4, 2025
5b625a8
build(vite): reduce Cloudflare build heap by disabling sourcemaps and…
Oct 4, 2025
84df736
chore(dev): remove Jest-related deps to eliminate inflight/glob@7 dep…
Oct 4, 2025
ded1574
feat: add worker tsconfig and update vite config with shared/worker a…
Oct 4, 2025
4b08bd2
Squashed 'external/drpower-vibe-production/' content from commit 8194f23
Oct 11, 2025
6ff760d
Merge commit '4b08bd26ba3d0be865e7e8cf010bd75a75096c8e' as 'external/…
Oct 11, 2025
4f9a8d9
Merge drpower production repo via subtree; fix lint issues; ignore .h…
Oct 11, 2025
827bf37
chore(cf): adjust wrangler config for workers.dev deploy; disable rou…
Oct 11, 2025
dd603b7
chore(cf): disable routes entirely; enable preview URLs for workers.d…
Oct 11, 2025
88023e2
fix(config): set CUSTOM_DOMAIN and CUSTOM_PREVIEW_DOMAIN for workers.…
Oct 11, 2025
8599004
fix(error-handling): update error handling during auth flow; local de…
Oct 11, 2025
1987ac6
chore(repo): save workspace state; ensure ignores for local env and c…
Oct 12, 2025
db384ee
chore: add prod curl headers/cookies payload files for Access testing…
Oct 12, 2025
1b28a31
Fix user registration by removing ALLOWED_EMAIL restriction
Oct 13, 2025
83417c8
Remove OAuth check from registration to allow email/password signups
Oct 13, 2025
82921cb
chore: add mock API response files for testing
Oct 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 6 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v1
- name: Setup Node
uses: actions/setup-node@v4
with:
bun-version: latest
node-version: '22.x'
cache: 'npm'

- name: Install dependencies
run: bun install --frozen-lockfile
run: npm ci

- name: Run build
run: bun run build
run: npm run build

# - name: Run linter
# run: bun run lint
Expand Down
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ temp/
templates
debugging.ipynb

#bun.lock
bun.lock
#*.lock

debug-tools/*.json
# Sentry Config File
.env.sentry-build-plugin
data-dump
data-dump
# Local history (do not commit)
.history/
1 change: 1 addition & 0 deletions body-60909.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"success":true,"data":{"token":"977680572f4a19a8754f198073026f3703b2a6d68807aa00925343c00f3205af","headerName":"X-CSRF-Token","expiresIn":7200}}
1 change: 1 addition & 0 deletions body-8787.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"success":true,"data":{"token":"f692bb6007704315c85d5cd8a98c03305e7250c5feb40e4f7b685e6fb7deab66","headerName":"X-CSRF-Token","expiresIn":7200}}
1 change: 1 addition & 0 deletions body-health-8787.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"status":"ok"}
1 change: 1 addition & 0 deletions body-register-8787.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"success":false,"error":{"message":"Registration failed","name":"Error"},"message":"An error occurred"}
5 changes: 5 additions & 0 deletions cookies-8787.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Netscape HTTP Cookie File
# https://curl.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.

#HttpOnly_localhost FALSE / TRUE 1760329085 csrf-token %7B%22token%22%3A%22f692bb6007704315c85d5cd8a98c03305e7250c5feb40e4f7b685e6fb7deab66%22%2C%22timestamp%22%3A1760321885725%7D
5 changes: 5 additions & 0 deletions cookies-prod.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Netscape HTTP Cookie File
# https://curl.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.

#HttpOnly_vibesdk-production.isaactrinidadllc.workers.dev FALSE / TRUE 1760315017 CF_AppSession ca7ae1cd14326343
5 changes: 5 additions & 0 deletions cookies.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Netscape HTTP Cookie File
# https://curl.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.

#HttpOnly_localhost FALSE / TRUE 1760329216 csrf-token %7B%22token%22%3A%22977680572f4a19a8754f198073026f3703b2a6d68807aa00925343c00f3205af%22%2C%22timestamp%22%3A1760322016202%7D
36 changes: 36 additions & 0 deletions external/drpower-vibe-production/.dev.vars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Security Configuration
#CUSTOM_DOMAIN="your-domain.com" # Your custom domain for CORS
#ENVIRONMENT="prod" # Options: dev, staging, prod

# Essential Secrets:
#CLOUDFLARE_AI_GATEWAY_TOKEN="" # If this has read and edit permissions, the AI Gateway will be created automatically. run is required at the least

# Provider specific secrets:
#ANTHROPIC_API_KEY=""
#OPENAI_API_KEY=""
GOOGLE_AI_STUDIO_API_KEY=""
#OPENROUTER_API_KEY="default"
#GROQ_API_KEY="default"

# Stuff for Oauths:
#GOOGLE_CLIENT_SECRET=""
#GOOGLE_CLIENT_ID=""

# GitHub OAuth
#GITHUB_CLIENT_ID=""
#GITHUB_CLIENT_SECRET=""

# Github Export OAuth
# GITHUB_EXPORTER_CLIENT_SECRET=""
# GITHUB_EXPORTER_CLIENT_ID=""

# Secrets for various internal services of this platform
JWT_SECRET=""
WEBHOOK_SECRET=""

# AI Gateway URL Override (Leave as-is if not going to set it)
#CLOUDFLARE_AI_GATEWAY_URL=""

# Cloudflare API Key and Account ID. This is important
# CLOUDFLARE_API_TOKEN=""
# CLOUDFLARE_ACCOUNT_ID=""
15 changes: 15 additions & 0 deletions external/drpower-vibe-production/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = tab
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 4
50 changes: 50 additions & 0 deletions external/drpower-vibe-production/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Logs
logs
*.log*
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
.tmp
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# wrangler files
.wrangler
.dev.vars
.prod.vars
.env
.env.*

runner/downloads
/generated/prisma

/generated/prisma
test.ts
temp/

templates
debugging.ipynb

#bun.lock
#*.lock

debug-tools/*.json
# Sentry Config File
.env.sentry-build-plugin
data-dump
140 changes: 140 additions & 0 deletions external/drpower-vibe-production/CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview
This is an official Cloudflare product - a React+Vite frontend with Cloudflare Workers backend that features a Durable Object-based AI agent capable of building webapps phase-wise from user prompts.

**Important Context:**
- Core functionality: AI-powered webapp generation via Durable Objects
- Authentication system and database schemas are currently under development (existing code is AI-generated and needs review/rewrite)
- Full Cloudflare stack: Workers, D1, Durable Objects, R2 (planned)
- All tests in the project are AI-generated and need replacement

## Development Commands

### Frontend Development
```bash
npm run dev # Start Vite dev server with hot reload
npm run build # Build production frontend
npm run lint # Run ESLint
npm run preview # Preview production build
```

### Worker Development
```bash
npm run local # Run Worker locally with Wrangler
npm run cf-typegen # Generate TypeScript types for CF bindings
npm run deploy # Deploy to Cloudflare Workers + secrets
```

### Database (D1) - Under Development
```bash
npm run db:setup # Initial database setup
npm run db:generate # Generate migrations (local)
npm run db:migrate:local # Apply migrations locally
npm run db:migrate:remote # Apply migrations to production
npm run db:studio # Open Drizzle Studio for local DB
```

### Testing - Needs Rewrite
```bash
npm run test # Run Jest tests (current tests need replacement)
```

## Core Architecture: AI Code Generation

### Phase-wise Generation System (`worker/agents/codegen/`)
The heart of the system is the `CodeGeneratorAgent` Durable Object that implements sophisticated code generation:

1. **Blueprint Phase**: Analyzes user requirements and creates project blueprint
2. **Incremental Generation**: Generates code phase-by-phase with specific files per phase
3. **SCOF Protocol**: Structured Code Output Format for streaming generated code
4. **Review Cycles**: Multiple automated review passes including:
- Static analysis (linting, type checking)
- Runtime validation via Runner Service
- AI-powered error detection and fixes
5. **Diff Support**: Efficient file updates using unified diff format

### Key Components
- **Durable Object**: `worker/agents/codegen/phasewiseGenerator.ts` - Stateful code generation
- **State Management**: `worker/agents/codegen/state.ts` - Generation state tracking
- **WebSocket Protocol**: Real-time streaming of generation progress
- **Runner Service**: External service for code execution and validation

### Frontend-Worker Communication
- **Initial Request**: POST `/api/agent`
- **WebSocket Connection**: `/api/agent/:agentId/ws` for real-time updates
- **Message Types**: Typed protocol for file updates, errors, phase transitions

## Areas Under Development

### Authentication System (Needs Review/Rewrite)
Current implementation in `worker/auth/` and `worker/api/controllers/authController.ts`:
- OAuth providers (Google, GitHub) - needs production hardening
- JWT session management - requires security review
- Database schema for users/sessions - needs optimization

### Database Architecture (In Progress)
- Currently using Drizzle ORM with D1
- Schema in `worker/database/schema.ts` - under active development
- Migration system needs refinement

### Testing Strategy (Needs Implementation)
- All current tests are AI-generated placeholders
- Need proper unit tests for core generation logic
- Integration tests for Durable Objects
- E2E tests for generation workflow

## Working with the Codebase

### Adding Features to Code Generation
1. Modify agent logic in `worker/agents/codegen/phasewiseGenerator.ts`
2. Update state types in `worker/agents/codegen/state.ts`
3. Add new message types for WebSocket protocol
4. Update frontend handler in `src/routes/chat/hooks/use-chat.ts`

### Cloudflare-Specific Patterns
- **Durable Objects**: Used for stateful, long-running operations
- **D1 Database**: SQLite-based, use batch operations for performance
- **Environment Bindings**: Access via `env` parameter (AI, DB, CodeGenObject)
- **Service Bindings**: Runner service accessed via `env.RUNNER_SERVICE`

### Environment Variables
Required in `.dev.vars` for local development:
- `JWT_SECRET` - For session management (under development)
- `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GOOGLE_AI_STUDIO_API_KEY` - AI providers
- `RUNNER_SERVICE_API_KEY` - For code execution service
- OAuth credentials (being redesigned)

## Important Notes
- Focus on core AI generation functionality when making changes
- Prioritize Cloudflare-native solutions (D1, Durable Objects, R2)
- Always **strictly** follow DRY principles
- Keep code quality high and maintainability in mind
- Always research and understand the codebase before making changes
- Never use 'any' type. If you see 'any', Find the proper appropriate type in the project and then replace it. If nothing is found, then write a type for it.
- Never use dynamic imports. If you see dynamic imports, Correct it!
- Implement everything the 'right' and 'correct' way instead of 'fast' and 'quick'.
- Don't add comments for explaining your changes to me. Comments should be professional, to the point and should be there to explain the code, not your changes
- Don't start writing new 'corrected' versions of files instead of working on fixing the existing ones

## Common Tasks

### Debugging Code Generation
1. Monitor Durable Object logs: `npm run local`
2. Check WebSocket messages in browser DevTools
3. Verify Runner Service connectivity
4. Review generation state in `CodeGeneratorAgent`

### Working with Durable Objects
- Class: `worker/agents/codegen/phasewiseGenerator.ts`
- Binding: `env.CodeGenObject`
- ID Generation: Based on session/user context
- State Persistence: Automatic via Cloudflare

### Runner Service Integration
- Executes generated code in isolated environment
- Provides runtime error feedback
- Returns preview URLs for generated apps
- Configuration in `wrangler.jsonc`
21 changes: 21 additions & 0 deletions external/drpower-vibe-production/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Cloudflare

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading