Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions python/vibe-coding-ide/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# PyCharm
.idea/

# Docker
.dockerignore

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
34 changes: 34 additions & 0 deletions python/vibe-coding-ide/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## Getting Started

First, run the backend development server:

```bash
cd backend

vercel link
vercel env pull

# or manually set env vars
# cat .env.example > .env

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

python server.py
```

Open [http://localhost:8081/docs](http://localhost:8081/docs) with your browser to see the backend.

Then, run the frontend development server:

```bash
# in a separate terminal
cd frontend

npm i

npm run dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the backend.
4 changes: 4 additions & 0 deletions python/vibe-coding-ide/backend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
VERCEL_TOKEN=your_token_here
VERCEL_PROJECT_ID=prj_...your_project_id_here
VERCEL_TEAM_ID=team_...your_team_here
VERCEL_AI_GATEWAY_API_KEY=vck_...your_key_here
173 changes: 173 additions & 0 deletions python/vibe-coding-ide/backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be added to the global gitignore or merged into this project gitignore. For a PyCharm
# project, it is recommended to ignore the entire .idea directory.
.idea/

# Docker
.dockerignore

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

.vercel
Empty file.
40 changes: 40 additions & 0 deletions python/vibe-coding-ide/backend/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[build-system]
requires = ["hatchling>=1.25.0"]
build-backend = "hatchling.build"

[project]
name = "nfactorial-code-agent-backend"
version = "0.1.0"
description = "Backend for the nfactorial code agent (FastAPI)"
requires-python = ">=3.10"
dependencies = [
"python-dotenv==1.0.0",
"pydantic",
"fastapi~=0.117.0",
"uvicorn",
"openai-agents[litellm]",
"PyJWT==2.9.0",
"vercel>=0.3.2",
"httpx",
"httpx-sse",
"ruff>=0.14.0",
]

[project.optional-dependencies]
dev = [
"ruff>=0.5.0",
"mypy",
]

[project.urls]
homepage = "https://example.com"
repository = "https://example.com/repo"


[tool.hatch.build.targets.wheel]
# Include the src package so Hatch can build the wheel after refactor
only-include = [
"src",
]


9 changes: 9 additions & 0 deletions python/vibe-coding-ide/backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
python-dotenv==1.0.0
pydantic
httpx==0.27.2
httpx-sse==0.4.0
fastapi==0.115.12
uvicorn[standard]==0.34.2
openai-agents[litellm]
PyJWT==2.9.0
vercel>=0.3.2
55 changes: 55 additions & 0 deletions python/vibe-coding-ide/backend/server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import os
import logging
from dotenv import load_dotenv
from fastapi import FastAPI, Request
from fastapi.middleware.cors import CORSMiddleware
from dotenv import load_dotenv
from typing import Callable
from vercel.headers import set_headers

from src.api.agent import router as agent_router
from src.api.sandbox import router as sandbox_router
from src.api.models import router as models_router


load_dotenv()


logger = logging.getLogger("ide_agent.server")
if not logger.handlers:
logger.setLevel(logging.INFO)

app = FastAPI()

is_prod = (
os.getenv("NODE_ENV") or os.getenv("ENV") or "development"
).lower() == "production"

app.add_middleware(
CORSMiddleware,
allow_origins=[],
allow_origin_regex=r"^https://.*\.labs\.vercel\.dev(:\d+)?$" if is_prod else r".*",
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)

@app.middleware("http")
async def vercel_context_middleware(request: Request, call_next: Callable):
set_headers(request.headers)
return await call_next(request)

app.include_router(models_router)
app.include_router(agent_router)
app.include_router(sandbox_router)


@app.get("/")
def read_root():
return {"Hello": "IDE Agent"}


if __name__ == "__main__":
import uvicorn

uvicorn.run("server:app", host="0.0.0.0", port=8081, factory=False)
Empty file.
Empty file.
Loading