refactor: Restructure monorepo to apps/server/ and apps/web/ layout

Move src/ → apps/server/ and packages/web/ → apps/web/ to adopt
standard monorepo conventions (apps/ for runnable apps, packages/
for reusable libraries). Update all config files, shared package
imports, test fixtures, and documentation to reflect new paths.

Key fixes:
- Update workspace config to ["apps/*", "packages/*"]
- Update tsconfig.json rootDir/include for apps/server/
- Add apps/web/** to vitest exclude list
- Update drizzle.config.ts schema path
- Fix ensure-schema.ts migration path detection (3 levels up in dev,
  2 levels up in dist)
- Fix tests/integration/cli-server.test.ts import paths
- Update packages/shared imports to apps/server/ paths
- Update all docs/ files with new paths
This commit is contained in:
Lukas May
2026-03-03 11:22:53 +01:00
parent 8c38d958ce
commit 34578d39c6
535 changed files with 75452 additions and 687 deletions

View File

@@ -8,26 +8,26 @@ Multi-agent workspace for orchestrating multiple AI coding agents working in par
| Module | Docs | Path |
|--------|------|------|
| Agent (lifecycle, providers, accounts) | [docs/agent.md](docs/agent.md) | `src/agent/` |
| Database (schema, repositories) | [docs/database.md](docs/database.md) | `src/db/` |
| Server & API (tRPC procedures) | [docs/server-api.md](docs/server-api.md) | `src/server/`, `src/trpc/`, `src/coordination/` |
| Frontend (React UI) | [docs/frontend.md](docs/frontend.md) | `packages/web/` |
| CLI & Config | [docs/cli-config.md](docs/cli-config.md) | `src/cli/`, `src/config/` |
| Dispatch & Events | [docs/dispatch-events.md](docs/dispatch-events.md) | `src/dispatch/`, `src/events/` |
| Git, Process, Logging | [docs/git-process-logging.md](docs/git-process-logging.md) | `src/git/`, `src/process/`, `src/logger/`, `src/logging/` |
| Preview (Docker deployments) | [docs/preview.md](docs/preview.md) | `src/preview/` |
| Testing | [docs/testing.md](docs/testing.md) | `src/test/` |
| Agent (lifecycle, providers, accounts) | [docs/agent.md](docs/agent.md) | `apps/server/agent/` |
| Database (schema, repositories) | [docs/database.md](docs/database.md) | `apps/server/db/` |
| Server & API (tRPC procedures) | [docs/server-api.md](docs/server-api.md) | `apps/server/server/`, `apps/server/trpc/`, `apps/server/coordination/` |
| Frontend (React UI) | [docs/frontend.md](docs/frontend.md) | `apps/web/` |
| CLI & Config | [docs/cli-config.md](docs/cli-config.md) | `apps/server/cli/`, `apps/server/config/` |
| Dispatch & Events | [docs/dispatch-events.md](docs/dispatch-events.md) | `apps/server/dispatch/`, `apps/server/events/` |
| Git, Process, Logging | [docs/git-process-logging.md](docs/git-process-logging.md) | `apps/server/git/`, `apps/server/process/`, `apps/server/logger/`, `apps/server/logging/` |
| Preview (Docker deployments) | [docs/preview.md](docs/preview.md) | `apps/server/preview/` |
| Testing | [docs/testing.md](docs/testing.md) | `apps/server/test/` |
| Database Migrations | [docs/database-migrations.md](docs/database-migrations.md) | `drizzle/` |
| Logging Guide | [docs/logging.md](docs/logging.md) | `src/logger/` |
| Logging Guide | [docs/logging.md](docs/logging.md) | `apps/server/logger/` |
Pre-implementation design docs are archived in `docs/archive/`.
## Key Rules
- **Database**: Never use raw SQL for schema initialization. Use `drizzle-kit generate` and the migration system. See [docs/database-migrations.md](docs/database-migrations.md).
- **Logging**: Use `createModuleLogger()` from `src/logger/index.ts`. Keep `console.log` for CLI user-facing output only.
- **Hexagonal architecture**: Repository ports in `src/db/repositories/*.ts`, Drizzle adapters in `src/db/repositories/drizzle/*.ts`. All re-exported from `src/db/index.ts`.
- **tRPC context**: Optional repos accessed via `require*Repository()` helpers in `src/trpc/routers/_helpers.ts`.
- **Logging**: Use `createModuleLogger()` from `apps/server/logger/index.ts`. Keep `console.log` for CLI user-facing output only.
- **Hexagonal architecture**: Repository ports in `apps/server/db/repositories/*.ts`, Drizzle adapters in `apps/server/db/repositories/drizzle/*.ts`. All re-exported from `apps/server/db/index.ts`.
- **tRPC context**: Optional repos accessed via `require*Repository()` helpers in `apps/server/trpc/routers/_helpers.ts`.
## UI Patterns
@@ -39,18 +39,18 @@ Pre-implementation design docs are archived in `docs/archive/`.
npm run build && npm link
```
Run after any change to server-side code (`src/**`).
Run after any change to server-side code (`apps/server/**`).
## Testing
```sh
npm test # Unit + E2E tests (no API cost)
CW_CASSETTE_RECORD=1 npm test -- <test-file> # Record new cassettes locally
REAL_CLAUDE_TESTS=1 npm test -- src/test/integration/real-providers/ --test-timeout=300000 # Real provider tests (~$0.50)
REAL_CLAUDE_TESTS=1 npm test -- apps/server/test/integration/real-providers/ --test-timeout=300000 # Real provider tests (~$0.50)
# Record full-flow cassettes (one-time, costs ~$25 in API credits):
CW_CASSETTE_RECORD=1 npm test -- src/test/integration/full-flow/full-flow-cassette.test.ts --test-timeout=3600000
# Commit the generated src/test/cassettes/<hash>.json files afterward.
CW_CASSETTE_RECORD=1 npm test -- apps/server/test/integration/full-flow/full-flow-cassette.test.ts --test-timeout=3600000
# Commit the generated apps/server/test/cassettes/<hash>.json files afterward.
# Subsequent runs replay from cassettes at no cost: npm test
```

View File

@@ -8,6 +8,7 @@
import { migrate } from 'drizzle-orm/better-sqlite3/migrator';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { existsSync } from 'node:fs';
import type { DrizzleDatabase } from './index.js';
import { createModuleLogger } from '../logger/index.js';
@@ -19,7 +20,10 @@ const log = createModuleLogger('db');
*/
function getMigrationsPath(): string {
const currentDir = dirname(fileURLToPath(import.meta.url));
// From src/db/ or dist/db/, go up two levels to package root, then into drizzle/
// In dev (tsx): apps/server/db/ — need 3 levels up to workspace root
// In dist (tsc): dist/db/ — need 2 levels up to workspace root
const upThree = join(currentDir, '..', '..', '..', 'drizzle');
if (existsSync(upThree)) return upThree;
return join(currentDir, '..', '..', 'drizzle');
}

Some files were not shown because too many files have changed in this diff Show More