Imported from keemzin/openkot (
AGENTS.md). Install upstream withnpx skills add keemzin/openkot. Copyright stays with the author.
AGENTS.md
always utilise sequential-thinking and context7 to test any changes, use chrome-devtools mcp on localhost:5173 never run bun run build let the user run it
never commit on the user's behalf
Development Workflow
Starting the Development Server
The server is started with bun run dev (always running for development purposes):
- Vite dev server:
http://localhost:5173(frontend with hot reload) - Express server:
http://localhost:3006(backend API) - OpenCode CLI: port
3358(AI backend)
Frontend changes (files in src/) reload instantly in the browser - no restart needed!
When to Restart bun run dev
Only restart when:
- Backend changes (
server/index.js, Express routes) - Package changes (installed new npm package with
bun install) - Config changes (
.env,vite.config.ts) - Weird errors (sometimes a fresh restart helps)
Stopping the Development Server
Option 1: Ctrl+C (recommended for the user)
- Press
Ctrl+Cin the terminal wherebun run devis running
Option 2: Stop script
bun run dev:stop
or
powershell -ExecutionPolicy Bypass -File dev-stop.ps1
Pro Tips
- Keep Terminal Visible - Watch for errors in the terminal where
bun run devis running:[0] ✓ built in 123ms [1] [OpenCode] API is ready
Architecture
- SDK operations (sessions, messages, permissions, providers): Use
@opencode-ai/sdkv2 viasrc/lib/opencode.ts, routed through Express proxy at/api. - Express routes (filesystem, git, terminal, MCP config): Handled directly in
server/index.js. - SDK v2 response shape: All responses wrapped in
{ data: ... }— always unwrap withresp?.data ?? resp.
Critical Quirks
- Bun Windows
WriteFailedpanic: MCP config writes inserver/index.jsmust usefs.promises.writeFile(async), never sync writes. - OpenCode CORS: Server spawns OpenCode with
--corsflags (seeserver/index.js). If you see CORS errors, restart the dev server. - Vite polyfills:
vite.config.tsdefinesprocess.env,process.platform,globalfor browser builds — don't remove these or the SDK will fail.
Configuration
- Ports: Set in
.env(PORT=3006,OPENCODE_PORT=3358,VITE_PORT=5173). - Working directory:
WORKING_DIRin.env(default:WORKSPACE/). Can be relative to repo root or absolute. - OpenCode config:
.opencode/opencode.jsonc(copy from.opencode/opencode.jsonc.example). MCP servers, providers, permissions configured here.
TypeScript
- Strict mode enabled with
noUnusedLocalsandnoUnusedParameters— clean up unused vars/params in edited files. - Target: ES2020, module: ESNext, JSX: react-jsx.
File Scope
- Default working directory for AI operations:
WORKSPACE/(or whateverWORKING_DIRpoints to). - Only modify root-level code (
src/,server/,cli/) when explicitly asked.
Architecture Reference
- Architecture deep-dive (file map, data flows, SSE): see
openkot-architecture.md - Keep
openkot-architecture.mdin sync when adding/removing/renaming files or changing data flow