Imported from grand2-products/echolore (
AGENTS.md). Install upstream withnpx skills add grand2-products/echolore. Copyright stays with the author.
AGENTS.md
Project
- Repository:
echolore - Purpose: AI-powered knowledge & meeting platform (self-hostable)
- Main domains:
- Google SSO and email/password access with email-based identity reconciliation
- Notion-style Wiki
- Meetings with LiveKit
- AI agent (LangChain) for meeting transcript summarization and Wiki integration
Monorepo Structure
apps/web: Next.js frontendapps/api: Hono APIpackages/shared: shared contracts/typespackages/ui: shared UI packagescripts/: install, update, and dev helper scriptsplan/: planning and architecture documentsdocs/: operational notes and runbooks
Runtime Architecture
- Web: Next.js
- API: Hono + Kysely
- Database: PostgreSQL
- Realtime: LiveKit
- Cache/broker: Valkey
- Auth: Auth.js (JWT) for browser Google SSO and password login, plus API-issued access/refresh tokens for mobile Google token exchange
- AI: LangChain + Google Cloud Speech APIs
- File storage: pluggable StorageProvider (Local / S3 / GCS), configured via admin settings
- Infra baseline: any Linux VPS + Docker Compose
- Container registry: GHCR (ghcr.io)
Release Policy
- Release path is tag-based: push a
v*.*.*tag to triggerPublish Release. - Main workflows:
CI: lint, typecheck, build, testPublish Release: image build/push to GHCR, GitHub Release creation
- Runtime deploy uses prebuilt images via
docker-compose.production.yml. - End users install and update via
scripts/install.shandscripts/update.sh. - Versioning: semver tags (
v0.1.0), Docker tags (v0.1.0,0.1,latest).
Branch Policy
mainis the release branch.- Feature branches → PR → merge to
main.
Compose Policy
docker-compose.yml: development base composedocker-compose.dev.yml: local development overridedocker-compose.production.yml: end-user production composedocker-compose.bootstrap-check.yml: isolated validation compose- Production images use
${ECHOLORE_VERSION:-latest}for version pinning.
Naming Conventions
- Environment-specific names should end with
_DEVor_PRODfor GitHub Secrets. - Runtime env vars should stay uppercase snake case.
- Shared DTO and contract types should use explicit suffixes such as
Dto,Request,Response. - Workflow names should reflect responsibility directly:
CIApp Release
- Plan and status documents should prefer explicit names over temporary notes.
Auth and Authorization Principles
- API identity must be server-authoritative.
- Do not accept actor identity such as
authorId,creatorId, oruploaderIdfrom clients for business writes. - Authorization is enforced in API routes for wiki, meetings, files, and users.
- Frontend auth state is sourced from real session user via Auth.js session.
Security-Sensitive Paths
apps/api/src/lib/auth.tsapps/api/src/lib/authjs-config.tsapps/api/src/lib/local-auth.tsapps/api/src/lib/password-auth-guard.tsapps/api/src/lib/internal-auth.tsapps/api/src/routes/auth.tsapps/api/src/routes/admin.tsapps/api/src/routes/wiki.tsapps/api/src/routes/meetings.tsapps/api/src/routes/files.tsapps/api/src/routes/users.tsapps/api/src/routes/livekit.tsapps/api/src/routes/internal-room-ai.tsapps/api/src/routes/github-webhook.tsapps/api/src/routes/admin/admin-github-settings.tsapps/api/src/routes/admin/admin-github-repos.tsapps/api/src/services/github/github-api-client.tsapps/api/src/services/github/github-webhook-handler.tsapps/api/src/services/github/github-sync-service.tsapps/api/src/services/admin/github-settings-service.ts.github/workflows/docker-compose.yml- Changes in these areas should be reviewed for trust boundary, privilege scope, and rollback impact.
API Contract Rules
- Shared API contracts live in
packages/shared. - Treat
packages/sharedas the source of truth for DTOs and request/response shapes. - When changing API payloads, update API and web in the same change.
- Avoid duplicating contract types inside
apps/apiorapps/webunless they are strictly local UI/helper types. - For business-write APIs, do not reintroduce client-owned actor fields into shared contracts.
Testing Rules
pnpm typecheckis the minimum required verification for code changes.pnpm testis expected to become a release gate; add tests instead of weakening the gate.- Any auth/authz change should add or update a regression test.
- Any contract change should be verified on both API and web sides.
- If tests do not exist for a touched critical path, note the gap explicitly and prefer adding the smallest useful test.
Database Rules
- Database schema is defined in
apps/api/src/db/schema.ts. - Schema changes require updating
apps/api/src/db/schema/database.ts(Kysely type interface) and adding a new SQL migration inapps/api/src/db/migrations/. - Use
pnpm db:migrateto apply migrations. - When changing schema for shared business entities, review API contracts and authorization impact together.
- Multi-step writes that must stay consistent should prefer DB transactions.
Frontend Rules
- Frontend code lives in
apps/web. - Prefer shared contracts and the centralized client in
apps/web/lib/api.ts. - Avoid ad hoc
fetchcalls when the API client already covers the endpoint. - Session-aware UI should converge on real session user data, not mock identity.
- When changing protected screens, verify unauthorized and error states as well as success states.
Security Rules
- Business write APIs must derive actor identity from authenticated session context.
- Admin-only behavior must be enforced on the server, not only hidden in UI.
- Secrets belong in GitHub Secrets or runtime env injection, never committed files.
- Break-glass host operations are exceptions and should not replace workflow-based release behavior.
- Changes to auth, authz, release, or infra should be reviewed with rollback and trust-boundary impact in mind.
- Deploy hosts should use SSH key authentication with minimal privileges.
Code Review Focus
- Prioritize:
- authn/authz regressions
- privilege escalation risk
- client/server contract drift
- release-flow breakage
- data consistency issues in multi-step writes
- For workflow or infra changes, review trigger conditions, branch targeting, secrets usage, and rollback path.
- For API changes, review both input ownership and resource authorization, not only type correctness.
Infra Change Rules
- Do not rely on manual host mutation as the durable fix.
- If release/runtime behavior changes, update these together:
.github/workflows/scripts/release/docker-compose.ymlDEPLOYMENT.mddocs/ops-runbook.mdAGENTS.md
Documentation Sync Rules
AGENTS.mdstores stable rules, conventions, and operating assumptions.plan/stores only temporary plans, open decisions, incomplete work, acceptance criteria, and execution backlog.docs/stores implemented behavior, operational procedures, and implementation notes.- If a change affects team defaults or repository-wide behavior, update
AGENTS.mdin the same change. - Do not use
plan/for implemented system overviews, implemented feature descriptions, current-state summaries, or durable operational explanations. - When a planned item is implemented, move the durable description out of
plan/and intodocs/in the same change when the behavior is now real and stable. - If a
plan/*.mdfile no longer contains meaningful incomplete work or open decisions, delete it instead of keeping a historical summary. - If a
plan/*.mdfile still has active work, shrink it to the remaining gaps, decisions, and acceptance checks only. - Do not add or keep sections such as
Current State Summary,Implemented Behavior, or similar implemented-reality mirrors inplan/; that material belongs indocs/. - Keep
plan/lighter over time by removing or shrinking sections that only describe already-implemented behavior. - Maintain the repository so that:
plan/is primarily future-facingdocs/is primarily a map of implemented reality
Decision Logging
- Durable architecture or release decisions should be reflected in:
AGENTS.mdfor stable repository rulesdocs/for implemented behavior and operational proceduresplan/for remaining work and open decisions only
- Do not leave important operational decisions only in ad hoc chat, PR text, or temporary handover notes.
- If a previous default changes, update the old source of truth in the same change rather than adding a contradictory note elsewhere.
Ownership Areas
apps/api: backend behavior, authz enforcement, DB accessapps/web: UI behavior and session-driven frontend integrationpackages/shared: API contract ownership boundary.github/workflows/andscripts/: release and infrastructure control planeplan/anddocs/: repository operating knowledge
Definition Of Done
- A change is not done only because code was added.
- Minimum done criteria:
- contracts, API, and web stay aligned
- required docs are updated when behavior changed
- obsolete or duplicated
plan/content is removed or reduced to remaining work only pnpm typecheckpasses- tests are added or the remaining gap is explicitly called out
- release or infra changes preserve the GitHub Actions only policy
- For security-sensitive changes, done also means the trust boundary and authorization behavior were re-checked.
Developer Commands
- Install dependencies:
pnpm install - Full typecheck:
pnpm typecheck - Lint:
pnpm lint - Build:
pnpm build - Test:
pnpm test - Local compose up:
pnpm docker:dev - Local compose down:
pnpm docker:down - DB generate:
pnpm db:generate - DB migrate:
pnpm db:migrate
Source of Truth
AGENTS.md: stable repository rules and conventionsdocs/: implemented behavior,仕様、operational procedures — 仕様の正本plan/: remaining work and open decisions only
Working Rules
- Prefer updating
AGENTS.mdonly for stable project rules and conventions. - Put volatile task lists and one-off handover notes in
plan/ordocs/, not here. - When implemented behavior changes, update
AGENTS.mdand relevantdocs/together. - When branch/release behavior changes, update both
AGENTS.mdand workflow files in.github/workflows/. - If implementation is complete and the explanation is durable, put it in
docs/, notplan/. - Before merging documentation-heavy changes, check whether any
plan/*.mdfile became implementation history and should be deleted or trimmed.