* update * ✅ test(database): add ThreadModel unit tests Add comprehensive unit tests for ThreadModel covering: - create: thread creation with various parameters - query: fetch all threads for user - queryByTopicId: fetch threads by topic - findById: retrieve thread by id - update: update thread properties - delete: delete single thread - deleteAll: delete all user threads - User isolation tests for security 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * ✅ test(database): add EmbeddingModel unit tests Add comprehensive unit tests for EmbeddingModel covering: - create: create new embedding for a chunk - bulkCreate: batch create embeddings with conflict handling - delete: delete embedding by id - query: fetch all user embeddings - findById: retrieve embedding by id - countUsage: count total embeddings for user - User isolation tests for security 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * ✅ test(database): add OAuthHandoffModel unit tests Add comprehensive unit tests for OAuthHandoffModel covering: - create: create OAuth handoff with conflict handling - fetchAndConsume: fetch and delete credentials with TTL check - cleanupExpired: delete expired records (>5 min old) - exists: check credential existence without consuming - Expiration validation for 5-minute TTL 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * ✅ test(database): add UserModel unit tests Add comprehensive unit tests for UserModel covering: - getUserRegistrationDuration: calculate user registration duration - getUserState: get user state with settings and decryption - getUserSSOProviders: get linked SSO providers - getUserSettings: retrieve user settings - updateUser: update user properties - deleteSetting: delete user settings - updateSetting: create/update user settings (upsert) - updatePreference: merge and update user preferences - updateGuide: update user guide preferences Static methods: - makeSureUserExist: ensure user exists - createUser: create new user with duplicate check - deleteUser: delete user by id - findById: find user by id - findByEmail: find user by email - getUserApiKeys: get decrypted API keys 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * ✅ test(database): add missing DocumentModel tests Add tests for uncovered DocumentModel methods: - create: create new document - delete: delete document by id with user isolation - deleteAll: delete all user documents - query: query all documents with ordering - findById: find document by id with user isolation - update: update document with user isolation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * ✅ test(database): add user isolation tests for AgentModel Add user isolation security tests to ensure users cannot access or modify other users' knowledge base and file associations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * 🐛 fix(database): fix flaky document ordering test Add 50ms delay before update to ensure timestamp difference for ordering test. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
3.4 KiB
CLAUDE.md
This document serves as a shared guideline for all team members when using Claude Code in this repository.
Tech Stack
read @.cursor/rules/project-introduce.mdc
Directory Structure
read @.cursor/rules/project-structure.mdc
Development
Git Workflow
- The current release branch is
nextinstead ofmainuntil v2.0.0 is officially released - use rebase for git pull
- git commit message should prefix with gitmoji
- git branch name format example: tj/feat/feature-name
- use .github/PULL_REQUEST_TEMPLATE.md to generate pull request description
Package Management
This repository adopts a monorepo structure.
- Use
pnpmas the primary package manager for dependency management - Use
bunto run npm scripts - Use
bunxto run executable npm packages
TypeScript Code Style Guide
see @.cursor/rules/typescript.mdc
Testing
- Required Rule: read
@.cursor/rules/testing-guide/testing-guide.mdcbefore writing tests - Command:
- web:
bunx vitest run --silent='passed-only' '[file-path-pattern]' - packages(eg: database):
cd packages/database && bunx vitest run --silent='passed-only' '[file-path-pattern]'
- web:
Important:
- wrap the file path in single quotes to avoid shell expansion
- Never run
bun run testetc to run tests, this will run all tests and cost about 10mins - If trying to fix the same test twice, but still failed, stop and ask for help.
Typecheck
- use
bun run type-checkto check type errors.
i18n
- Keys: Add to
src/locales/default/namespace.ts - Dev: Translate
locales/zh-CN/namespace.jsonandlocales/en-US/namespace.jsonlocales file only for dev preview - DON'T run
pnpm i18n, let CI auto handle it
Linear Issue Management
When working with Linear issues:
- Retrieve issue details before starting work using
mcp__linear-server__get_issue - Check for sub-issues: If the issue has sub-issues, retrieve and review ALL sub-issues using
mcp__linear-server__list_issueswithparentIdfilter before starting work - Update issue status when completing tasks using
mcp__linear-server__update_issue - MUST add completion comment using
mcp__linear-server__create_comment
Completion Comment (REQUIRED)
Every time you complete an issue, you MUST add a comment summarizing the work done. This is critical for:
- Team visibility and knowledge sharing
- Code review context
- Future reference and debugging
IMPORTANT: Per-Issue Completion Rule
When working on multiple issues (e.g., parent issue with sub-issues), you MUST update status and add comment for EACH issue IMMEDIATELY after completing it. Do NOT wait until all issues are done to update them in batch.
Workflow for EACH individual issue:
- Complete the implementation for this specific issue
- Run type check:
bun run type-check - Run related tests if applicable
- IMMEDIATELY update issue status to "Done":
mcp__linear-server__update_issue - IMMEDIATELY add completion comment:
mcp__linear-server__create_comment - Only then move on to the next issue
❌ Wrong approach:
- Complete Issue A → Complete Issue B → Complete Issue C → Update all statuses → Add all comments
✅ Correct approach:
- Complete Issue A → Update A status → Add A comment → Complete Issue B → Update B status → Add B comment → ...
Rules Index
Some useful project rules are listed in @.cursor/rules/rules-index.mdc