4206b93614
Copilot Setup Steps / copilot-setup-steps (push) Failing after 17s
- Created playwright.config.ts for test configuration - Added .last-run.json to store test run status - Implemented landing.test.ts with tests for navbar visibility and navigation - Removed unused server proxy configuration from vite.config.ts
6.7 KiB
6.7 KiB
AGENTS.md – Repository Quick‑Start Guide
Purpose: Give OpenCode agents the exact commands and conventions they need to work safely and efficiently in the AITrader codebase. Only include items that are easy to miss without explicit guidance.
Project structure
app/routes/– React Router 7 file-based routes (landing.tsxis the index/home page)app/components/– Shared React componentsapp/routes.ts– Route definitions (usesindexandroutehelpers from@react-router/dev/routes)app/root.tsx– Root layout with global HTML shell, Links, Meta, Scriptsapp/app.css– Global styles (Tailwind is configured via Vite)tests/– Playwright E2E testsvitest.config.ts/vitest.setup.ts– Unit test config (Vitest)vite.config.ts– Vite config with Tailwind and React Router pluginsreact-router.config.ts– React Router framework configtsconfig.json– TypeScript config (ES modules:"type": "module")
Core npm scripts (run from the repository root)
npm run dev– Starts the dev server with HMR via react-router dev. Served athttp://localhost:5173.npm run build– Produces a production build using react-router build. Output lives in./buildwithclient/andserver/.npm start– Serves the production bundle withreact-router-serve ./build/server/index.js. Requires a priornpm run build.npm run typecheck– Runs react-router typegen thentsc. Must be run before committing TypeScript changes.npm run test:e2e– Runs Playwright E2E tests (server starts automatically viaplaywright.config.ts).
Development workflow
- Install deps –
npm install(first time only). - Start dev –
npm run dev. Changes are hot-reloaded; no manual restart. - Iterate – Edit files under
app/(routes, components, loaders, actions). - Validate – Run
npm run typecheckregularly; it catches missing typegen steps. - E2E tests –
npm run test:e2e(Playwright handles server startup). - Build & serve –
npm run build && npm start.
Routing (React Router 7)
index()routes render into the parent<Outlet />at the parent's path.route(segment, file)creates an explicit path segment.- The landing page is
index("routes/landing.tsx")— it is the default page at/. - Do not use multiple
index()routes at the same nesting level — only one is allowed per level. - All route files export
meta()for<title>and<meta>tags, and a default export component.
TypeScript nuances
- The
typecheckscript runs react-router typegen first; agents must not skip this step because generated types are required for successful compilation. - The project uses ES modules (
"type": "module"). Import paths should include file extensions (.js,.ts) where Node requires them. - Route types are generated — use
import type { Route } from "./+types/<route-name>"for type-safe loaders/actions.
TailwindCSS
- Configured via Vite (
@tailwindcss/vite). No extra build steps needed; the dev server and production build automatically process Tailwind classes. - Use arbitrary values and
classNamecomposition freely.
Playwright E2E testing
- Config:
playwright.config.tsin the repo root. - The web server starts automatically (
npm run devon port 5173) before tests run. - Tests live in
tests/directory. - Generate the report with:
npm run test:e2e -- --reporter=html(output intest-results/). - To run tests in headed mode for debugging, set
headless: "false"inplaywright.config.tsor pass--headed. - To debug a single test:
npx playwright test tests/<file-name>.spec.ts.
Playwright MCP Server
An MCP (Model Context Protocol) server provides Playwright browser automation to AI assistants.
- Start MCP server:
npm run mcp:dev(runs via stdio, connects to AI clients) - Build MCP server:
npm run mcp:build(compiles tomcp-server/dist/)
Available tools:
navigate- Navigate to a URL and get page titlegetPageContent- Get text content from a pageclick- Click an element by CSS selectorfillForm- Fill a form input
Alpaca API Setup
- Copy
.env.exampleto.envand fill in your Alpaca credentials:ALPACA_API_KEY– Your Alpaca API keyALPACA_SECRET_KEY– Your Alpaca secret keyALPACA_BASE_URL– API endpoint (default: paper trading URL)
- The
.envfile is gitignored – never commit credentials. - Account data is fetched from
/api/alpaca/accountand displayed on the landing page.
Design Guidelines
Layout & Structure:
- All routes use gradient background:
<div className="min-h-screen bg-gradient-to-br from-gray-50 to-blue-50"> - Use
<Navbar />component at the top of every page (sticky, with backdrop blur) - Content container:
<div className="mx-auto max-w-7xl px-6 sm:px-8 lg:px-8">
Navbar:
- Use the shared
Navbarcomponent fromapp/components/Navbar.tsx - Logo: blue-600 rounded square with white "A", text "AITrader" in gray-900 with hover effect
- Links have underline animation on hover
Color Palette:
- Background:
bg-gradient-to-br from-gray-50 to-blue-50for pages,bg-whitefor cards - Text:
text-gray-900for headings,text-gray-600for secondary - Accent colors for account values:
text-green-600(Cash),text-blue-600(Buying Power),text-purple-600(Portfolio Value) - Error:
text-red-600for error messages
Components:
- Cards:
bg-white rounded-xl shadow-lg p-6 border border-gray-200 - Buttons:
bg-blue-600 text-white px-6 py-2.5 rounded-lg font-medium hover:bg-blue-700 transition-colors - Inputs:
border border-gray-300 rounded-lg px-4 py-2.5 focus:ring-2 focus:ring-blue-500
Typography:
- Page headings:
text-4xl font-bold text-gray-900 - Section headings:
text-xl font-bold text-gray-900 - Card titles:
text-xl font-bold text-gray-900
Common pitfalls agents might miss
- Running the server without a build –
npm startwill fail ifnpm run buildhasn't been executed first. - Skipping typegen – Directly running
tscwithout the precedingreact-router typegenresults in missing type definitions. - Multiple index routes at same level – React Router 7 only allows one
index()per nesting level. Useroute()for additional paths. - Port assumptions – Dev server runs on
5173; production server (Docker) defaults to3000unless overridden. - Route file naming – Route files must match the pattern
app/routes/<name>.tsxand the corresponding type file atapp/routes/+types/<name>.tsif types are needed. - Import paths – Use
react-routerfor framework imports (Link,Outlet), not@remix-run/react.
Keep this file up‑to‑date as scripts or tooling evolve.