Skip to content

Add Cloud Agent development environment - #685

Open
karrui wants to merge 2 commits into
mainfrom
karrui/cloud-agent-environment-b9b0
Open

Add Cloud Agent development environment#685
karrui wants to merge 2 commits into
mainfrom
karrui/cloud-agent-environment-b9b0

Conversation

@karrui

@karrui karrui commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

What

Sets up a repository-managed Cloud Agent development environment for the Starter Kit monorepo so agents can install, run, and test the app end to end. Because .cursor/environment.json is committed, it is the highest-precedence environment source and takes effect for agents once this branch is checked out / merged.

Environment config (.cursor/)

  • environment.json — declares install, start, a web-dev terminal, and exposes port 3000.
  • install.sh — pins Node 24 (nvm) + pnpm 11.20.0, creates .env from .env.example with a generated SESSION_SECRET, runs pnpm install --frozen-lockfile, and generates the Prisma client.
  • services.sh — starts native PostgreSQL (54321) and Redis (63791) on the ports .env.example expects (Docker isn't required for the app itself), and best-effort starts a Docker daemon (fuse-overlayfs) so the apps/web testcontainers Vitest suite runs.
  • start.sh — brings up services and syncs the Prisma schema (prisma db push).
  • dev.sh — runs the Next.js dev server (Turborepo watch) as a terminal.

Lockfile fix

  • pnpm-lock.yaml: the apps/web importer pinned @prisma/adapter-pg@7.9.0 while the prisma catalog and package snapshot are 7.9.1, so the lockfile had no entry for 7.9.0. This breaks pnpm install --frozen-lockfile and is currently failing main CI. Aligned the importer to the catalog value already used by packages/db.

Why

Docker isn't available by default in the Cloud Agent VM, so PostgreSQL and Redis run natively on the docker-compose ports, keeping .env.example working unchanged. Docker is still installed and started best-effort so the testcontainers integration tests run.

Validation

All commands run with Node 24.13.0 / pnpm 11.20.0.

Check Result
pnpm lint + pnpm lint:ws Passed (1 pre-existing warning)
pnpm typecheck Passed
pnpm test:ci 55 tests passed (incl. testcontainers)
pnpm build Passed
GET /api/health {"database":"up"}
Install idempotence Passed (frozen install twice)
OTP login (creates User row) Passed end-to-end in browser
Draft environment build SUCCEEDED (bld-20260813-dd5c5251-5376-48fb-86e3-e6a70d9b1578)
Fresh Cloud Agent from that build All checks PASS (toolchain, deps, services+schema, lint, typecheck, tests, build, dev health)

A screen recording of the end-to-end OTP sign-in (email → OTP from server log → authenticated /admin page, persisting a User row) is attached to the Cloud Agent run artifacts.

Open in Web Open in Cursor 

cursoragent and others added 2 commits August 13, 2026 07:30
The apps/web importer pinned @prisma/adapter-pg@7.9.0 while the prisma
catalog and the package snapshot are 7.9.1, leaving the lockfile without
an entry for 7.9.0. This breaks `pnpm install --frozen-lockfile` (and
main CI). Align the importer to the catalog version already used by
packages/db and present in the lockfile.

Co-authored-by: Kar Rui Lau <karrui@users.noreply.github.com>
Adds .cursor/environment.json plus install/start scripts so Cloud Agents
can run the Starter Kit end to end without Docker for the app itself:

- install.sh: pin Node 24 (nvm), create .env with a generated
  SESSION_SECRET, pnpm install --frozen-lockfile, prisma generate.
- services.sh: start native PostgreSQL (54321) and Redis (63791) on the
  ports .env.example expects, and best-effort start Docker (fuse-overlayfs)
  for the testcontainers-based Vitest suite.
- start.sh: bring up services and sync the Prisma schema (prisma db push).
- dev.sh: run the Next.js dev server as a terminal (stream logs).

Co-authored-by: Kar Rui Lau <karrui@users.noreply.github.com>
@vercel

vercel Bot commented Aug 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
starter-kit Ready Ready Preview Aug 13, 2026 7:33am
starter-kit-web Error Error Aug 13, 2026 7:33am

Request Review

@datadog-opengovsg

Copy link
Copy Markdown

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 61.60%

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 0764377 | Docs | Datadog PR Page | Give us feedback!

@karrui
karrui marked this pull request as ready for review August 13, 2026 07:50
Copilot AI lite review requested due to automatic review settings August 13, 2026 07:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a repository-managed Cloud Agent development environment under .cursor/ so automated agents can install dependencies, start required services (PostgreSQL/Redis), sync Prisma schema, and run the web dev server end-to-end. Also aligns the lockfile’s resolved Prisma adapter version with the workspace catalog to restore --frozen-lockfile installs.

Changes:

  • Add .cursor/environment.json plus install/start/dev scripts to provision a Cloud Agent dev environment.
  • Start native PostgreSQL + Redis on the existing docker-compose/.env.example ports and best-effort bring up a Docker daemon for testcontainers.
  • Fix pnpm-lock.yaml to resolve @prisma/adapter-pg to 7.9.1 (catalog value), eliminating a frozen-lockfile mismatch.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pnpm-lock.yaml Aligns resolved Prisma adapter version with the workspace catalog to fix frozen installs.
.cursor/environment.json Declares Cloud Agent install/start commands, a web-dev terminal, and port 3000 exposure.
.cursor/install.sh Installs workspace deps and generates Prisma client; bootstraps .env on first run.
.cursor/start.sh Starts local services and runs Prisma db push for per-boot schema reconciliation.
.cursor/services.sh Brings up native PostgreSQL/Redis and best-effort Docker daemon for testcontainers.
.cursor/dev.sh Runs the long-lived pnpm dev terminal with Turbo UI disabled for cleaner logs.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file
Suppressed comments (1)

.cursor/services.sh:38

  • The Docker daemon section is intended to be best-effort, but with set -e any failing sudo ... (missing sudo, password prompt, permission denied) can terminate the whole services startup. Also, chmod 666 makes the Docker socket world-writable. Consider using non-interactive sudo (-n), making the setup truly non-fatal, and tightening socket permissions while still allowing the current user to access it.
if command -v dockerd >/dev/null 2>&1; then
  if ! sudo docker info >/dev/null 2>&1; then
    echo "[services] Starting Docker daemon (for testcontainers)"
    sudo mkdir -p /etc/docker
    echo '{"storage-driver":"fuse-overlayfs"}' | sudo tee /etc/docker/daemon.json >/dev/null

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .cursor/services.sh
Comment on lines +10 to +15
PG_BIN="/usr/lib/postgresql/16/bin"
STATE_DIR="${HOME}/.local/share/starter-kit"
PGDATA="${STATE_DIR}/pgdata"
PGLOG="${STATE_DIR}/postgres.log"
REDIS_DIR="${STATE_DIR}/redis"
REDIS_LOG="${STATE_DIR}/redis.log"
Comment thread .cursor/install.sh
export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"
# shellcheck disable=SC1091
[ -s "${NVM_DIR}/nvm.sh" ] && . "${NVM_DIR}/nvm.sh"
nvm use >/dev/null 2>&1 || nvm use 24.13.0 >/dev/null 2>&1 || true
Comment thread .cursor/start.sh
export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"
# shellcheck disable=SC1091
[ -s "${NVM_DIR}/nvm.sh" ] && . "${NVM_DIR}/nvm.sh"
nvm use >/dev/null 2>&1 || nvm use 24.13.0 >/dev/null 2>&1 || true
Comment thread .cursor/dev.sh
export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"
# shellcheck disable=SC1091
[ -s "${NVM_DIR}/nvm.sh" ] && . "${NVM_DIR}/nvm.sh"
nvm use >/dev/null 2>&1 || nvm use 24.13.0 >/dev/null 2>&1 || true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants