| Dimension | Shared | Only in A | Only in B | Overlap |
|---|---|---|---|---|
| Sections | 0 | 12 | 6 | 0% |
| Commands | 0 | 19 | 0 | 0% |
| Section tags | 1 | 13 | 0 | 7% |
What each file covers
Sections
0 shared · 12 only in A · 6 only in B- − Project Coded Agent Guide
- − Tech Stack (by surface)
- − Structure & Responsibilities
- − Key Path Index (what lives where)
- − Commands (pnpm with filters)
- − Dependency Management Rule
- − Styling & Conventions
- − Testing Practices
- − TypeScript / Tooling
- − Refactoring & Comments
- − PR / Workflow Tips
- − Docker + SQL Conventions
- + Cross-Layer Events & Protocol Design
- + 1. Before You Add or Change an Event
- + 2. Event Naming & Payloads
- + 3. End-to-End Wiring Checklist
- + 4. Backwards Compatibility & Refactors
- + 5. Errors, Timeouts & Idempotency
Commands
0 shared · 19 only in A · 0 only in B- − eslint.config.ts
- − pnpm-workspace.yaml
- − docker/
- − pnpm -F @tg-search/server dev
- − pnpm run web:dev
- − pnpm run server:dev
- − pnpm run start
- − pnpm run build
- − pnpm run server:build
- − pnpm run test:run
- − pnpm run test:coverage
- − pnpm run lint
- − pnpm run lint:fix
- − pnpm run typecheck
- − pnpm run db:generate
- − pnpm install
- − pnpm install -F <target> <dependency>
- − vitest
- − docker-compose.yml
Section tags
1 shared · 13 only in A · 0 only in B- − setup
- − build
- − test
- − lint-format
- − architecture
- − types
- − testing-strategy
- − git-pr
- − database
- − ui
- − monorepo
- − agent-behaviour
- − docs
- code-style
Line diff
groupultra/telegram-search · AGENTS.md
@@ −1 @@
1# Project Coded Agent Guide
2
3Concise but detailed reference for contributors working in the `groupultra/telegram-search` monorepo. Improve code when you touch it; avoid one-off patterns.
4
5## Tech Stack (by surface)
6
7- **Server (`apps/server`)**: Node.js, TypeScript, Drizzle ORM, Postgres/pgvector, WebSocket + REST, dotenvx.
8- **Web (`apps/web`)**: Vue 3 + Vite, Pinia.
9- **Core/shared (`packages/*`)**: common types, client SDK, schema, core services, bot.
10- **Tooling**: pnpm workspaces, Vitest, ESLint, TypeScript 5.9, tsdown, Drizzle Kit.
11
12## Structure & Responsibilities
13
14- **Apps**
15 - `apps/server`: backend service (runtime entry in `apps/server/src/`).
16 - `apps/web`: web UI (source in `apps/web/src/`).
17- **Packages**
18 - `packages/`: shared libraries and domain logic used by apps.
19- **Root tooling**
20 - Linting: `eslint.config.ts`.
21 - DB tooling: `drizzle/`, `drizzle.config.ts`.
22 - Workspace: `pnpm-workspace.yaml`.
23
24## Key Path Index (what lives where)
25
26- `apps/server/src`: API, WebSocket, and session services.
27- `apps/web/src`: Vue UI and client-side logic.
28- `packages/core`: core domain/services.
29- `packages/schema`: shared types + DB schema.
30- `packages/client`: client SDKs for integration.
31- `docker/`: compose files + init scripts for local/dev.
32- `.env.example`: baseline env config.
33
34## Commands (pnpm with filters)
35
36> Use pnpm workspace filters to scope tasks, e.g. `pnpm -F @tg-search/server dev`.
37
38- **Dev (web only)**: `pnpm run web:dev`
39- **Dev (server only)**: `pnpm run server:dev`
40- **Dev (web + server)**: `pnpm run start`
41- **Build web**: `pnpm run build`
42- **Build server**: `pnpm run server:build`
43- **Run tests**: `pnpm run test:run`
44- **Coverage**: `pnpm run test:coverage`
45- **Lint**: `pnpm run lint` / `pnpm run lint:fix`
46- **Typecheck**: `pnpm run typecheck`
47- **DB generate**: `pnpm run db:generate`
48
49## Dependency Management Rule
50
51- Do not edit `package.json` directly to add/remove deps. Use `pnpm install` so lockfile and manifest stay in sync.
52- For workspace deps: `pnpm install -F <target> <dependency>` (add `-D` for dev deps).
53- Tooling like `typescript`, `vite`, `vitest`, `tsdown`, `@types/node` belongs at the workspace root (`-w`).
54
55## Styling & Conventions
56
57- Favor clear module boundaries; shared logic goes in `packages/`.
58- Keep runtime entrypoints lean; move heavy logic into services/modules.
59- Prefer functional patterns for testability; use DI where helpful. Avoid classes unless required by APIs.
60- Use Valibot for schema validation; keep schemas close to their consumers.
61- Use Eventa (`@moeru/eventa`) for structured IPC/RPC contracts where needed.
62- File names: `kebab-case`.
63- Do not add backward-compatibility guards. If extended support is required, write refactor docs and complete the change in a separate, well-scoped effort.
64- If the refactor scope is small, do a progressive refactor step by step.
65- When modifying code, look for small, safe refactors to reduce duplication or improve clarity.
66- If you need a workaround, add a `// NOTICE:` comment explaining why, the root cause, and any relevant context.
67
68## Testing Practices
69
70- Use Vitest for unit/integration tests.
71- Mock external services and Postgres where practical; keep tests deterministic.
72- When fixing a bug, add a Vitest test that documents the previous failure mode and include a short `//` comment about the cause.
73- For DB interactions, prefer migration-driven integration tests with env guards.
74
75## TypeScript / Tooling
76
77- Stay strict with types; avoid `any` unless absolutely necessary.
78- Prefer small, composable modules; keep exports minimal and intentional.
79
80## Refactoring & Comments
81
82- Prefer progressive, incremental refactors that keep behavior stable.
83- Keep existing comments with the code when moving/refactoring. If a comment becomes obsolete, replace it with a brief note about why it was removed.
84- Use markers consistently: `// TODO:`, `// REVIEW:`, `// NOTICE:`.
85- Add concise comments for complex logic, algorithms, OS-interaction, and shared utilities. Avoid obvious comments.
86
87## PR / Workflow Tips
88
89- Keep changes scoped; use workspace filters for commands.
90- Summarize changes, how tested (commands), and follow-ups.
91- Improve legacy when you touch it; avoid one-off patterns.
92- Maintain structured `README.md` documentation for each `packages/` and `apps/` entry.
93- Always run `pnpm run typecheck` and `pnpm run lint:fix` after finishing a task.
94- Use Conventional Commits (e.g., `feat(server): add session refresh`).
95
96## Docker + SQL Conventions
97
98- Use `docker-compose.yml` as the compose filename.
99- Do not write SQL migration files manually. Always use `drizzle-kit generate` to create migrations, which will be placed in `**/sql/` with descriptive, kebab-case names.
100- Avoid Postgres enums to keep migrations and imports flexible.
101
groupultra/telegram-search · .cursor/rules/events.mdc
@@ +1 @@
1---
2globs: packages/core/src/event-handlers/**, packages/core/src/services/**, packages/client/src/event-handlers/**, packages/client/src/adapters/**, apps/server/src/**
3---
4## Cross-Layer Events & Protocol Design
5
6- **Scope**: Any change that adds/renames/removes events flowing between:
7 - Vue/Pinia (apps/web)
8 - `packages/client`
9 - `apps/server` WebSocket layer
10 - `packages/core` event handlers & services
11
12### 1. Before You Add or Change an Event
13
14- Answer, in your head or in an RFC:
15 - **Where is the bottleneck?** (UX latency? DB load? Telegram API limits?)
16 - **What is the minimal new behavior?** (One sentence, domain language.)
17 - **What is the data flow?** (Component → store → client adapter → WS/core → DB → back.)
18 - **How does this handle failure?**
19 - Core error?
20 - Network loss?
21 - Partial success (e.g. some messages processed)?
22
23### 2. Event Naming & Payloads
24
25- Naming:
26 - Use `<domain>:<action>` or `<domain>:<action>:<subaction>`.
27 - Avoid generic verbs like `update`, `done`; always include the domain (`message`, `storage`, `auth`, etc.).
28- Payloads:
29 - Prefer **IDs + small shapes** over dumping full DB rows or Telegram objects.
30 - Do not leak raw internal schemas as event payloads unless they are explicitly part of the public model.
31 - Include enough context to render the UI without requiring a second roundtrip when reasonable.
32
33### 3. End-to-End Wiring Checklist
34
35When adding a new event, ensure all of the following are updated **in one change**:
36
37- **Types & contracts**:
38 - `@tg-search/core` `ToCoreEvent` / `FromCoreEvent`.
39 - `@tg-search/server/types` WS mappings (`WsEventToServer`, `WsEventToClient`).
40 - Client event handler maps in `packages/client`.
41- **Handlers**:
42 - Core event handler under `packages/core/src/event-handlers`.
43 - Service function(s) in `packages/core/src/services`.
44 - Client-side handler that maps `FromCoreEvent` into Pinia state.
45- **UI**:
46 - Minimal component/store changes to actually use the new event.
47
48### 4. Backwards Compatibility & Refactors
49
50- Prefer **adding** new events over changing semantics of existing ones.
51- If an event must change:
52 - Keep the old event name working for at least one release where possible.
53 - Introduce a new event name for the new behavior and migrate callers gradually.
54- For refactors across layers (e.g. renaming a domain or action):
55 - Do a **mechanical rename** across types, handlers, and callers in one PR.
56 - Avoid long-lived “mixed” states where some code uses old names and some uses new ones.
57
58### 5. Errors, Timeouts & Idempotency
59
60- Treat every event as potentially:
61 - Lost (network issues).
62 - Duplicated (retries).
63 - Delayed (backpressure).
64- Design handlers to be **idempotent** where possible:
65 - Re-applying the same event should not corrupt state.
66 - Use message IDs and versioning to detect duplicates.
67- Error semantics:
68 - Core should emit structured error events with codes and key context, not just strings.
69 - Client should surface user-friendly messages and, where safe, allow retry.
70
71
@@ −1 +1 @@
1−# Project Coded Agent Guide
1+---
2+globs: packages/core/src/event-handlers/**, packages/core/src/services/**, packages/client/src/event-handlers/**, packages/client/src/adapters/**, apps/server/src/**
3+---
4+## Cross-Layer Events & Protocol Design
25
3−Concise but detailed reference for contributors working in the `groupultra/telegram-search` monorepo. Improve code when you touch it; avoid one-off patterns.
6+- **Scope**: Any change that adds/renames/removes events flowing between:
7+ - Vue/Pinia (apps/web)
8+ - `packages/client`
9+ - `apps/server` WebSocket layer
10+ - `packages/core` event handlers & services
411
5−## Tech Stack (by surface)
12+### 1. Before You Add or Change an Event
613
7−- **Server (`apps/server`)**: Node.js, TypeScript, Drizzle ORM, Postgres/pgvector, WebSocket + REST, dotenvx.
8−- **Web (`apps/web`)**: Vue 3 + Vite, Pinia.
9−- **Core/shared (`packages/*`)**: common types, client SDK, schema, core services, bot.
10−- **Tooling**: pnpm workspaces, Vitest, ESLint, TypeScript 5.9, tsdown, Drizzle Kit.
14+- Answer, in your head or in an RFC:
15+ - **Where is the bottleneck?** (UX latency? DB load? Telegram API limits?)
16+ - **What is the minimal new behavior?** (One sentence, domain language.)
17+ - **What is the data flow?** (Component → store → client adapter → WS/core → DB → back.)
18+ - **How does this handle failure?**
19+ - Core error?
20+ - Network loss?
21+ - Partial success (e.g. some messages processed)?
1122
12−## Structure & Responsibilities
23+### 2. Event Naming & Payloads
1324
14−- **Apps**
15− - `apps/server`: backend service (runtime entry in `apps/server/src/`).
16− - `apps/web`: web UI (source in `apps/web/src/`).
17−- **Packages**
18− - `packages/`: shared libraries and domain logic used by apps.
19−- **Root tooling**
20− - Linting: `eslint.config.ts`.
21− - DB tooling: `drizzle/`, `drizzle.config.ts`.
22− - Workspace: `pnpm-workspace.yaml`.
25+- Naming:
26+ - Use `<domain>:<action>` or `<domain>:<action>:<subaction>`.
27+ - Avoid generic verbs like `update`, `done`; always include the domain (`message`, `storage`, `auth`, etc.).
28+- Payloads:
29+ - Prefer **IDs + small shapes** over dumping full DB rows or Telegram objects.
30+ - Do not leak raw internal schemas as event payloads unless they are explicitly part of the public model.
31+ - Include enough context to render the UI without requiring a second roundtrip when reasonable.
2332
24−## Key Path Index (what lives where)
33+### 3. End-to-End Wiring Checklist
2534
26−- `apps/server/src`: API, WebSocket, and session services.
27−- `apps/web/src`: Vue UI and client-side logic.
28−- `packages/core`: core domain/services.
29−- `packages/schema`: shared types + DB schema.
30−- `packages/client`: client SDKs for integration.
31−- `docker/`: compose files + init scripts for local/dev.
32−- `.env.example`: baseline env config.
35+When adding a new event, ensure all of the following are updated **in one change**:
3336
34−## Commands (pnpm with filters)
37+- **Types & contracts**:
38+ - `@tg-search/core` `ToCoreEvent` / `FromCoreEvent`.
39+ - `@tg-search/server/types` WS mappings (`WsEventToServer`, `WsEventToClient`).
40+ - Client event handler maps in `packages/client`.
41+- **Handlers**:
42+ - Core event handler under `packages/core/src/event-handlers`.
43+ - Service function(s) in `packages/core/src/services`.
44+ - Client-side handler that maps `FromCoreEvent` into Pinia state.
45+- **UI**:
46+ - Minimal component/store changes to actually use the new event.
3547
36−> Use pnpm workspace filters to scope tasks, e.g. `pnpm -F @tg-search/server dev`.
48+### 4. Backwards Compatibility & Refactors
3749
38−- **Dev (web only)**: `pnpm run web:dev`
39−- **Dev (server only)**: `pnpm run server:dev`
40−- **Dev (web + server)**: `pnpm run start`
41−- **Build web**: `pnpm run build`
42−- **Build server**: `pnpm run server:build`
43−- **Run tests**: `pnpm run test:run`
44−- **Coverage**: `pnpm run test:coverage`
45−- **Lint**: `pnpm run lint` / `pnpm run lint:fix`
46−- **Typecheck**: `pnpm run typecheck`
47−- **DB generate**: `pnpm run db:generate`
50+- Prefer **adding** new events over changing semantics of existing ones.
51+- If an event must change:
52+ - Keep the old event name working for at least one release where possible.
53+ - Introduce a new event name for the new behavior and migrate callers gradually.
54+- For refactors across layers (e.g. renaming a domain or action):
55+ - Do a **mechanical rename** across types, handlers, and callers in one PR.
56+ - Avoid long-lived “mixed” states where some code uses old names and some uses new ones.
4857
49−## Dependency Management Rule
58+### 5. Errors, Timeouts & Idempotency
5059
51−- Do not edit `package.json` directly to add/remove deps. Use `pnpm install` so lockfile and manifest stay in sync.
52−- For workspace deps: `pnpm install -F <target> <dependency>` (add `-D` for dev deps).
53−- Tooling like `typescript`, `vite`, `vitest`, `tsdown`, `@types/node` belongs at the workspace root (`-w`).
60+- Treat every event as potentially:
61+ - Lost (network issues).
62+ - Duplicated (retries).
63+ - Delayed (backpressure).
64+- Design handlers to be **idempotent** where possible:
65+ - Re-applying the same event should not corrupt state.
66+ - Use message IDs and versioning to detect duplicates.
67+- Error semantics:
68+ - Core should emit structured error events with codes and key context, not just strings.
69+ - Client should surface user-friendly messages and, where safe, allow retry.
5470
55−## Styling & Conventions
56−
57−- Favor clear module boundaries; shared logic goes in `packages/`.
58−- Keep runtime entrypoints lean; move heavy logic into services/modules.
59−- Prefer functional patterns for testability; use DI where helpful. Avoid classes unless required by APIs.
60−- Use Valibot for schema validation; keep schemas close to their consumers.
61−- Use Eventa (`@moeru/eventa`) for structured IPC/RPC contracts where needed.
62−- File names: `kebab-case`.
63−- Do not add backward-compatibility guards. If extended support is required, write refactor docs and complete the change in a separate, well-scoped effort.
64−- If the refactor scope is small, do a progressive refactor step by step.
65−- When modifying code, look for small, safe refactors to reduce duplication or improve clarity.
66−- If you need a workaround, add a `// NOTICE:` comment explaining why, the root cause, and any relevant context.
67−
68−## Testing Practices
69−
70−- Use Vitest for unit/integration tests.
71−- Mock external services and Postgres where practical; keep tests deterministic.
72−- When fixing a bug, add a Vitest test that documents the previous failure mode and include a short `//` comment about the cause.
73−- For DB interactions, prefer migration-driven integration tests with env guards.
74−
75−## TypeScript / Tooling
76−
77−- Stay strict with types; avoid `any` unless absolutely necessary.
78−- Prefer small, composable modules; keep exports minimal and intentional.
79−
80−## Refactoring & Comments
81−
82−- Prefer progressive, incremental refactors that keep behavior stable.
83−- Keep existing comments with the code when moving/refactoring. If a comment becomes obsolete, replace it with a brief note about why it was removed.
84−- Use markers consistently: `// TODO:`, `// REVIEW:`, `// NOTICE:`.
85−- Add concise comments for complex logic, algorithms, OS-interaction, and shared utilities. Avoid obvious comments.
86−
87−## PR / Workflow Tips
88−
89−- Keep changes scoped; use workspace filters for commands.
90−- Summarize changes, how tested (commands), and follow-ups.
91−- Improve legacy when you touch it; avoid one-off patterns.
92−- Maintain structured `README.md` documentation for each `packages/` and `apps/` entry.
93−- Always run `pnpm run typecheck` and `pnpm run lint:fix` after finishing a task.
94−- Use Conventional Commits (e.g., `feat(server): add session refresh`).
95−
96−## Docker + SQL Conventions
97−
98−- Use `docker-compose.yml` as the compose filename.
99−- Do not write SQL migration files manually. Always use `drizzle-kit generate` to create migrations, which will be placed in `**/sql/` with descriptive, kebab-case names.
100−- Avoid Postgres enums to keep migrations and imports flexible.
10171
