|
1 | | -# Repository Guidelines |
| 1 | +# AGENTS.md |
2 | 2 |
|
3 | | -## Project Structure & Module Organization |
| 3 | +Canonical playbook for all coding agents working in the Catnip repo. Model-specific quirks live alongside this file (for example `CLAUDE.md`). Always start here, then consult your agent supplement if one exists. |
4 | 4 |
|
5 | | -- `src/`: React + TypeScript SPA. |
6 | | - - `components/` (PascalCase `.tsx`), `routes/` (TanStack Router), `lib/` utilities, `hooks/` (files start with `use-`), `stores/`, `types/`. |
7 | | -- `worker/`: Cloudflare Worker (entry `worker/index.ts`) and scripts in `worker/scripts/`. |
8 | | -- `public/`: static assets; `dist/`: build output. |
9 | | -- `container/`: container build files; `docs/`: documentation; `scripts/`: repo maintenance. |
10 | | -- Path alias: import from `@/*` (configured in `tsconfig`). Example: `import { cn } from "@/lib/utils"`. |
| 5 | +## Project Summary |
11 | 6 |
|
12 | | -## Build, Test, and Development Commands |
| 7 | +Catnip is an agent-friendly development environment composed of: |
13 | 8 |
|
14 | | -- `pnpm dev`: run Vite dev server at `http://localhost:5173`. |
15 | | -- `pnpm dev:cf:vite`: SPA with Cloudflare dev flag for local Worker integration. |
16 | | -- `pnpm dev:cf`: build SPA then run `wrangler dev` (Worker + assets); logs are tee’d to `/tmp/wrangler.log`. |
17 | | -- `pnpm build`: type-check then Vite build to `dist/`. |
18 | | -- `pnpm preview`: serve built assets locally. |
19 | | -- `pnpm typecheck` / `pnpm typecheck:worker`: strict TS checks for app/worker. |
20 | | -- `pnpm lint`: ESLint over repo. |
21 | | -- `pnpm format:changed`: Prettier on staged/changed files. |
22 | | -- Containers: `just build-dev` then `just run-dev` for full-stack containerized dev. |
| 9 | +- **Frontend**: React + TypeScript SPA built with Vite, ShadCN UI, Tailwind CSS, and TanStack Router |
| 10 | +- **Container**: Unified Go binary (`catnip`) providing CLI tools and JSONRPC-powered APIs |
| 11 | +- **Worker**: Cloudflare Worker using Hono for production edge logic |
23 | 12 |
|
24 | | -## Coding Style & Naming Conventions |
| 13 | +## Repository Layout |
25 | 14 |
|
26 | | -- TypeScript strict enabled; prefer explicit types where helpful. |
27 | | -- ESLint rules in `eslint.config.js`; unused vars allowed with leading `_`. |
28 | | -- Components: PascalCase filenames and exports. Hooks: `use-*.ts` in `src/hooks`. |
29 | | -- Imports: prefer `@/*` alias; avoid deep relative chains. |
30 | | -- Formatting: Prettier is available; use `pnpm format:changed` before commits. |
| 15 | +``` |
| 16 | +catnip/ |
| 17 | +├── src/ React app (components, routes, hooks, lib, stores, types) |
| 18 | +├── worker/ Cloudflare Worker entry `worker/index.ts` and scripts |
| 19 | +├── container/ Go application, `just` tasks, and setup files |
| 20 | +├── docs/ Additional documentation |
| 21 | +├── public/ Static assets served by Vite |
| 22 | +├── dist/ Build output (generated) |
| 23 | +└── scripts/ Repository maintenance scripts |
| 24 | +``` |
31 | 25 |
|
32 | | -## Testing Guidelines |
| 26 | +Path aliases are configured so the frontend imports from `@/*` (e.g. `import { cn } from "@/lib/utils"`). |
33 | 27 |
|
34 | | -- No unit test runner is configured yet. Use `pnpm typecheck` and `pnpm lint` as gates. |
35 | | -- For new tests, prefer colocated files named `*.test.ts(x)` under `src/` and keep fast, isolated modules. |
36 | | -- Validate end-to-end flows via `pnpm dev:cf` (Worker) or `pnpm dev` (SPA). |
| 28 | +## Core Commands |
37 | 29 |
|
38 | | -## Commit & Pull Request Guidelines |
| 30 | +- `pnpm dev`: Vite dev server at `http://localhost:5173` |
| 31 | +- `pnpm dev:cf:vite`: SPA dev server with Cloudflare integration flag |
| 32 | +- `pnpm dev:cf`: Build SPA then run `wrangler dev` (worker + assets); logs stream to `/tmp/wrangler.log` |
| 33 | +- `pnpm build`: Type-check then Vite build to `dist/` |
| 34 | +- `pnpm preview`: Serve the built bundle locally |
| 35 | +- `pnpm typecheck` / `pnpm typecheck:worker`: Strict TypeScript validation for app/worker |
| 36 | +- `pnpm lint`: Run ESLint over the repo |
| 37 | +- `pnpm format:changed`: Prettier on staged or changed files |
| 38 | +- `just build-dev` then `just run-dev`: Containerized Go + frontend development flow |
39 | 39 |
|
40 | | -- Commits: short imperative subject with scope prefix when helpful (e.g., `CLI: reannounce host port mappings`, `UI: fix sidebar hostPort`). |
41 | | -- PRs: include summary, linked issues, screenshots/recordings for UI, and notes on dev/testing steps. Update `docs/` when user-facing behavior changes. |
| 40 | +## Coding & Styling Guidelines |
42 | 41 |
|
43 | | -## Security & Configuration Tips |
| 42 | +- TypeScript is strict; add explicit types when it improves clarity |
| 43 | +- Component files are PascalCase `.tsx`; hooks live in `src/hooks` with `use-*.ts` names |
| 44 | +- Prefer `@/*` imports over deep relative chains |
| 45 | +- ESLint allows unused vars only when prefixed with `_` |
| 46 | +- Use Prettier formatting before commits (`pnpm format:changed`) |
| 47 | +- Reuse ShadCN theme tokens; avoid custom styling unless required |
44 | 48 |
|
45 | | -- Secrets: never commit secrets. Use Wrangler secrets (e.g., `wrangler secret put GITHUB_APP_PRIVATE_KEY`). |
46 | | -- Env: local overrides in `.env.local`; deployment vars are set per-environment in `wrangler.jsonc`. |
47 | | -- On workspace creation, the container runs `./setup.sh`—install any dependencies there. |
| 49 | +## Testing Expectations |
| 50 | + |
| 51 | +- No unit test runner is configured yet; rely on `pnpm typecheck` and `pnpm lint` |
| 52 | +- Add colocated tests as `*.test.ts(x)` if needed, kept fast and isolated |
| 53 | +- Validate end-to-end flows via `pnpm dev` or `pnpm dev:cf` |
| 54 | + |
| 55 | +## Development Environment Notes |
| 56 | + |
| 57 | +- Dev servers auto-rebuild frontend and Go code; assume they are running |
| 58 | +- Avoid restarting containers unless explicitly asked—the dev server manages restarts |
| 59 | +- For Go changes, run `just build` inside `container/` to ensure compilation |
| 60 | +- Tooltip components must use `TooltipPrimitive.Provider`, `.Root`, etc. Never mount `TooltipPrimitive` directly |
| 61 | + |
| 62 | +## Security & Configuration |
| 63 | + |
| 64 | +- Never commit secrets; use Wrangler secrets (e.g. `wrangler secret put GITHUB_APP_PRIVATE_KEY`) |
| 65 | +- Local overrides belong in `.env.local`; deployment env vars are defined in `wrangler.jsonc` |
| 66 | +- Workspace initialization runs `./setup.sh`; add dependency installs there when needed |
| 67 | + |
| 68 | +## Working With Agents |
| 69 | + |
| 70 | +- Treat `AGENTS.md` as the source of truth for shared workflows |
| 71 | +- Keep per-agent documents lean—focus on deviations or ergonomics specific to that model and link back here for the baseline instructions |
0 commit comments