⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
docs(agents): revamp project guidance (#1564)
Tin Sever255870f9a21b
diff --git a/AGENTS.md b/AGENTS.mdnew file mode 100644index 000000000..4d333462f--- /dev/null+++ b/AGENTS.md@@ -0,0 +1,99 @@+# Kaneo agent guide++Kaneo is a fast, deliberately simple, self-hosted project-management platform. The Hono API owns domain behavior and authorization, the React app consumes its typed client, PostgreSQL stores durable state, and events plus WebSockets keep clients current. Redis is optional and coordinates realtime delivery across multiple API instances.++This is an operating guide, not a README. These rules are good defaults; explicit developer and user instructions take precedence.++## Principles++- Simplicity is a product requirement. Build the smallest model that makes correct behavior obvious.+- Features should solve a real problem without making routine work heavier.+- Protect performance, especially on task-heavy boards and realtime views.+- Keep self-hosting straightforward and single-instance deployments first-class. Do not make Redis or another managed service mandatory without an explicit product decision.+- Support both bundled same-origin deployments and separately hosted API and web deployments.+- Protect user data, workspace boundaries, and authorization checks.+- Read the relevant implementation before changing it. Follow an established local pattern when it fits, but do not preserve accidental complexity merely because it exists.+- Stay focused. Do not mix requested work with speculative features, broad refactors, or unrelated cleanup.++## Architecture++- `apps/api` — Hono API, Better Auth, controllers, database access, events, integrations, MCP HTTP routes, and WebSockets.+- `apps/web` — React/Vite UI, TanStack Router and Query, fetchers, hooks, and realtime cache updates.+- `apps/docs` — product and API documentation content; `apps/site` — public Next.js site and documentation host.+- `packages/libs` — shared typed Hono client and URL helpers.+- `packages/permissions` — canonical permission vocabulary and built-in roles.+- `packages/mcp` — published stdio MCP package.+- `charts/kaneo` — Helm deployment surface.+- `tests/api` contains API unit tests; `tests/api-integration` contains PostgreSQL-backed integration tests.++## Boundaries that must hold++- The API is the authority for authentication and authorization. Hiding an action in the UI is not an authorization check.+- Workspace-scoped operations must use the existing `@kaneo/permissions` vocabulary and API middleware.+- Do not expose secrets, credentials, internal fields, or private workspace data through responses, logs, events, WebSockets, or MCP tools.+- Public API behavior must retain accurate Valibot validation and OpenAPI metadata.+- Mutations that affect realtime state must consider event publication, WebSocket delivery, and client cache invalidation.+- Database changes must work for existing installations, not only empty development databases.+- User-facing web copy must use static i18n keys. `i18n/en-US.json` is the source of truth.++## Follow a change through++Before calling a behavior change complete, decide which surfaces apply:++- API route, validator, controller, authorization, error behavior, and OpenAPI description.+- Typed client, web fetcher, query or mutation hook, cache invalidation, and UI states.+- Events, project- or user-scoped WebSockets, and optional Redis fan-out.+- Permission definitions, API enforcement, and UI capability checks.+- MCP, API keys, webhooks, and relevant external integrations.+- Schema, relations, generated migration, indexes, cascades, and existing data.+- Translations, accessibility, user documentation, Docker, and Helm.+- Reverse states: create/delete, assign/unassign, enable/disable, connect/disconnect, and a visible current state.++Not every change touches every surface. Make the decision deliberately rather than expanding scope automatically.++## Project conventions++- Keep API handlers thin and domain behavior in controllers or focused utilities.+- Validate API inputs with Valibot unless an existing integration requires another library. Use `HTTPException` for expected HTTP failures.+- Use `requireWorkspacePermission` rather than duplicating role checks.+- Use `publishEvent()` when a mutation drives activity, notifications, integrations, or realtime updates.+- Keep web requests in `apps/web/src/fetchers/` and server state in TanStack Query hooks.+- Use the client from `@kaneo/libs`; do not create a parallel untyped request layer.+- Define database schema in `apps/api/src/database/schema.ts` and relations in `apps/api/src/database/relations.ts`.+- Generate migrations with `pnpm --filter @kaneo/api db:generate`, inspect the SQL, and include it with the schema change.+- Prefer inferred TypeScript types and `type` over `interface` unless extension or declaration merging is required.+- Comments should explain constraints or surprising decisions, not narrate code.++## Safety and tooling++- Use pnpm 10.32.1 and Node.js 20.19 or newer. Server environment variables come from the root `.env`; local Vite-only overrides belong in `apps/web/.env.local`. See `ENVIRONMENT_SETUP.md`.+- Never use production databases, storage, or credentials for development or tests.+- Preserve unrelated work in a dirty worktree. Do not delete data or generated files unless the task requires it and the target is verified.+- Track processes you start and stop only those processes; never kill by broad name or path patterns.+- The root and package `lint` scripts run Biome with `--write` and can modify unrelated files. Prefer targeted checks while iterating and inspect formatter changes.+- Do not commit, push, or open a pull request unless explicitly requested.++## Verification++Use the smallest proof that covers the changed behavior, then broaden it when the blast radius requires it.++- Utility or UI logic: focused unit/component tests and the affected package typecheck.+- API behavior: focused API tests; use integration tests when routing, authentication, authorization, or PostgreSQL behavior matters.+- Database changes: relevant integration tests and migration inspection.+- Cross-package contracts: typecheck or build all affected consumers.+- Realtime changes: verify the event-to-WebSocket-to-cache path and consider both in-memory and Redis delivery.+- Deployment changes: validate the affected Docker, Helm, or startup path.+- User-visible flows: use a real browser pass when requested or when it is the only meaningful proof.++Run repository-wide checks when a change crosses packages broadly, before a requested commit or pull request, or when explicitly asked. Report what ran and what did not.++## Glossary++- **instance**: one deployed Kaneo installation.+- **workspace**: the top-level collaboration and authorization boundary.+- **project**: a task container inside a workspace.+- **role**: a workspace-scoped set of permission statements.+- **activity**: durable, user-visible history.+- **event**: an internal notification used by activity, integrations, notifications, or realtime updates.++Update this guide only for recurring, observed failure modes. Put narrow workflows in skills or dedicated documentation.diff --git a/CLAUDE.md b/CLAUDE.mdindex faa10d036..170e725bd 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -1,299 +1,5 @@-# CLAUDE.md+# Kaneo project instructions-This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.+Canonical guidance: [AGENTS.md](./AGENTS.md)-## Project Overview--Kaneo is a self-hosted project management platform built with simplicity and performance as core principles. The codebase is organized as a **pnpm monorepo** with TurboRepo.--**Key Philosophy**: Features exist to solve real problems, not to impress. Avoid over-engineering - keep solutions simple and focused. Don't add features, refactoring, or improvements beyond what was asked.--## Development Commands--### Getting Started-```bash-# Install dependencies (uses pnpm)-pnpm install--# Start all development servers (API + web)-pnpm dev--# Lint and auto-fix code (Biome)-pnpm lint--# Typecheck all packages (tsc, enforced in CI)-pnpm typecheck--# Build all packages-pnpm build-```--### API-Specific Commands-```bash-# Run API in development mode-pnpm --filter @kaneo/api dev--# Build API-pnpm --filter @kaneo/api build--# Generate database migrations (after schema changes)-pnpm --filter @kaneo/api db:generate--# Run database migrations (auto-runs on API startup)-pnpm --filter @kaneo/api db:migrate--# Open Drizzle Studio (database GUI)-pnpm --filter @kaneo/api db:studio--# Lint API code-pnpm --filter @kaneo/api lint-```--### Web-Specific Commands-```bash-# Run web app in development mode-pnpm --filter @kaneo/web dev--# Build web app for production-pnpm --filter @kaneo/web build--# Preview production build-pnpm --filter @kaneo/web preview--# Lint web code-pnpm --filter @kaneo/web lint-```--## Architecture Overview--### Monorepo Structure-```-kaneo/-├── apps/-│ ├── api/ # Backend API (Hono/Node.js/PostgreSQL)-│ ├── web/ # Frontend app (React/Vite/TanStack)-│ └── docs/ # Documentation site (Next.js)-├── packages/-│ ├── email/ # Email utilities-│ ├── libs/ # Shared libraries-│ └── typescript-config/ # TypeScript configurations-└── charts/ # Kubernetes Helm charts-```--### Technology Stack--**Backend (API)**-- Framework: Hono (lightweight web framework)-- Database: PostgreSQL with Drizzle ORM-- Authentication: Better Auth-- Validation: Valibot (Zod is also present, used by Better Auth and some schemas)-- API Documentation: OpenAPI (hono-openapi)-- IDs: CUID2 (via @paralleldrive/cuid2)--**Frontend (Web)**-- Framework: React 19+-- Routing: TanStack Router (file-based)-- Data Fetching: TanStack Query (React Query)-- Build Tool: Vite-- Styling: Tailwind CSS v4-- State Management: Zustand-- UI Components: Radix UI primitives--### Key Architectural Patterns--**Backend API Structure**-- Routes organized by feature in `apps/api/src/{feature}/`-- Controller pattern: business logic extracted to `{feature}/controllers/`-- All routes use OpenAPI decorators (`describeRoute`)-- All inputs validated with Valibot schemas-- Migrations auto-run on API startup--**Frontend Structure**-- File-based routing in `apps/web/src/routes/`-- Query hooks in `apps/web/src/hooks/queries/`-- Mutation hooks in `apps/web/src/hooks/mutations/`-- API fetchers in `apps/web/src/fetchers/{feature}/`-- Components in `apps/web/src/components/`--**Database Schema Conventions**-- All tables use CUID2 for primary keys (`createId()`)-- Every table has `createdAt` and `updatedAt` timestamps-- Foreign keys always specify cascade behavior (`onDelete`, `onUpdate`)-- Indexes on frequently queried columns (especially foreign keys)-- Schema defined in `apps/api/src/database/schema.ts`-- Relations defined in `apps/api/src/database/relations.ts`--**Authentication Flow**-- Better Auth handles authentication-- User context available in Hono via `c.get("userId")`, `c.get("user")`, `c.get("session")`-- API keys supported via Bearer token-- Frontend uses Better Auth client from `@/lib/auth-client`--**Event System**-- Events published for activity tracking-- Use `publishEvent()` from `apps/api/src/events/`-- Events tracked for features like status changes, assignments, etc.--## Code Style--### Formatting (Biome)-- **Indentation**: Spaces for JavaScript/TypeScript/TSX (tabs for other file types)-- **Quotes**: Double quotes-- **Semicolons**: Required-- **Ignored files**: CSS and `package.json` files are excluded from Biome linting/formatting-- Run `pnpm lint` to auto-fix--### TypeScript Conventions-- Prefer `type` over `interface` (only use interface when extending/merging)-- Prefer type inference when obvious-- File naming: PascalCase for components, kebab-case for utilities/hooks-- Hooks use `use` prefix: `use-task.ts`--### Import Organization-1. External packages-2. Internal packages (`@/` aliases)-3. Relative imports-Biome auto-organizes imports.--### Git Commits-Use Conventional Commits:-- `feat:` - New features-- `fix:` - Bug fixes-- `docs:` - Documentation-- `refactor:` - Code refactoring-- `chore:` - Maintenance tasks--Husky enforces commit message format via commitlint.--### Pre-commit Hooks-The pre-commit hook (`.husky/pre-commit`) runs two checks:-1. `biome ci .` for linting and formatting validation-2. `pnpm run build` for a full monorepo build--Commits will be slow due to the build step. Ensure code compiles before committing.--## Environment Configuration--**Single `.env` file** in project root shared by all apps.--Required variables:-- `KANEO_CLIENT_URL` - Web app URL (e.g., http://localhost:5173)-- `KANEO_API_URL` - API URL (e.g., http://localhost:1337)-- `AUTH_SECRET` - JWT secret (min 32 chars)-- `DATABASE_URL` - PostgreSQL connection string-- `POSTGRES_DB`, `POSTGRES_USER`, `POSTGRES_PASSWORD`--Optional:-- `CORS_ORIGINS` - Comma-separated allowed origins (empty = allow all in dev)-- `VITE_API_URL` - API URL for web dev (defaults to http://localhost:1337)-- `REDIS_URL` - Redis connection string for multi-instance WebSocket broadcasts via Pub/Sub (omit for single-instance in-memory mode)-- SSO providers (GitHub, Google, Discord, Custom OAuth/OIDC)-- SMTP configuration--See `ENVIRONMENT_SETUP.md` for detailed configuration and troubleshooting.--## Development Workflow--### When Making Changes--1. **Read before modifying**: Never propose changes to code you haven't read-2. **Use existing patterns**: Follow the established controller/fetcher/hook patterns-3. **Avoid over-engineering**: Don't add features beyond what's requested-4. **Type safety**: Let TypeScript guide you - all APIs are fully typed-5. **Validate inputs**: Always use Valibot schemas for API inputs-6. **Error handling**: Backend uses HTTPException, frontend uses toast notifications--### Database Changes--1. Modify schema in `apps/api/src/database/schema.ts`-2. Generate migration: `pnpm --filter @kaneo/api db:generate`-3. Migration auto-runs on next API startup-4. Always use CUID2 for IDs, include timestamps, specify cascade behavior--### Adding API Endpoints--1. Create controller in `apps/api/src/{feature}/controllers/`-2. Add route in `apps/api/src/{feature}/index.ts`-3. Use `describeRoute` for OpenAPI docs-4. Use `validator` with Valibot schema-5. Keep route handler thin - business logic in controller--### Adding Frontend Features--1. Create fetcher in `apps/web/src/fetchers/{feature}/`-2. Create query/mutation hook in `apps/web/src/hooks/`-3. Use TanStack Query for caching-4. Handle loading/error states properly-5. Use toast notifications (sonner) for user feedback--## Important Notes--- **Package Manager**: This project uses **pnpm** (pinned to `10.32.1` via `packageManager` field), not npm or yarn. Requires Node `>=18`-- **Migrations**: Auto-run on API startup, stored in `apps/api/drizzle/`-- **Development Ports**: API runs on 1337, web runs on 5173-- **Hot Reload**: Both API and web have watch mode via `pnpm dev`-- **CORS**: Configured in API index.ts, controlled by `CORS_ORIGINS` env var-- **Testing**: Run `pnpm test` at the repo root (Turbo runs `test` in packages that define it: API unit tests, web unit/component tests, shared packages). API integration tests: `pnpm test:integration` (requires PostgreSQL; env is set in `tests/api-integration/setup.ts`; CI uses `.github/workflows/ci.yml`). Vitest configs: `apps/api/vitest.config.ts` (unit), `apps/api/vitest.integration.config.ts` (integration), `apps/web/vitest.config.ts` (web). Integration tests live under `tests/api-integration/`; API unit tests under `tests/api/`.-- **Security**: Never commit secrets, always validate inputs, sanitize outputs--## Common Patterns--### Backend Route Example-```typescript-// apps/api/src/{feature}/index.ts-import { Hono } from "hono";-import { describeRoute, validator } from "hono-openapi";-import * as v from "valibot";-import getItem from "./controllers/get-item";--const feature = new Hono<{ Variables: { userId: string } }>()- .get("/:id",- describeRoute({- operationId: "getItem",- tags: ["Feature"],- description: "Get item by ID"- }),- validator("param", v.object({ id: v.string() })),- async (c) => {- const { id } = c.req.valid("param");- const item = await getItem(id);- return c.json(item);- }- );-```--### Frontend Query Hook Example-```typescript-// apps/web/src/hooks/queries/{feature}/use-item.ts-import { useQuery } from "@tanstack/react-query";-import { getItem } from "@/fetchers/{feature}/get-item";--export function useItem(itemId: string) {- return useQuery({- queryKey: ["item", itemId],- queryFn: () => getItem(itemId),- });-}-```--### Database Schema Example-```typescript-// apps/api/src/database/schema.ts-export const exampleTable = pgTable("example", {- id: text("id").$defaultFn(() => createId()).primaryKey(),- projectId: text("project_id")- .notNull()- .references(() => projectTable.id, {- onDelete: "cascade",- onUpdate: "cascade",- }),- title: text("title").notNull(),- createdAt: timestamp("created_at", { mode: "date" }).defaultNow().notNull(),- updatedAt: timestamp("updated_at", { mode: "date" })- .defaultNow()- .$onUpdate(() => new Date())- .notNull(),-}, (table) => [- index("example_projectId_idx").on(table.projectId),-]);-```diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex fa15ad81a..6313e1e13 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -26,7 +26,7 @@ We want everyone to feel welcome here. Please be respectful and follow our [Code### What You'll Need-- **Node.js** (18 or newer)+- **Node.js** (20.19 or newer)- **pnpm** (we use this instead of npm/yarn)- **Git**- **Docker** (optional, for testing full deployments)@@ -45,7 +45,7 @@ pnpm install```3. **Set up environment variables**:- Create `.env` files for both the API and web apps. See [ENVIRONMENT_SETUP.md](ENVIRONMENT_SETUP.md) for detailed instructions on all required environment variables.+ Create a `.env` file in the repository root for server configuration. The web app includes localhost development defaults; put local Vite overrides such as `VITE_API_URL` in `apps/web/.env.local`. See [ENVIRONMENT_SETUP.md](ENVIRONMENT_SETUP.md) for the required variables and examples.4. **Start everything up**:```bash@@ -185,10 +185,17 @@ t("projects:greeting", { name: userName });kaneo/├── apps/│ ├── api/ # Backend API (Node.js/Hono)-│ ├── docs/ # Documentation site (Next.js)+│ ├── docs/ # Product and API documentation content+│ ├── site/ # Public website and documentation host (Next.js)│ └── web/ # Frontend app (React/Vite)-├── packages/ # Shared code and configs-└── charts/ # Kubernetes Helm charts+├── packages/+│ ├── email/ # Shared email utilities and templates+│ ├── libs/ # Typed API client and shared runtime helpers+│ ├── mcp/ # Published stdio MCP package+│ ├── permissions/ # Shared permission vocabulary and built-in roles+│ └── ... # Import tooling and shared TypeScript configuration+├── tests/ # API unit and integration tests+└── charts/ # Kubernetes Helm chart```## Need Help?