This is an AI agent project. The main feature is tree sessions: every turn is a tree node, users can fork at any node, and every path in the tree is a separate context for the LLM API.
react + vite + shadcn + tanstack-query + tanstack-router. Please use shadcn components.
axum server + postgresql + sqlx. In initial development, do not create more than one migration. If you need to update the schema, you should:
- Tell me you'll update the schema, so I can disconnect other connections to db.
sqlx database drop -yto delete existing db.sqlx database createto create a new db.sqlx migrate runto run the new migration.
Before every commit, run both frontend and backend checks. Do not commit if any step fails.
Frontend (fork-chat-frontend):
pnpm formatpnpm lintpnpm typecheckpnpm test
Backend (fork-chat-backend):
cargo fmt --all --checkcargo clippy --all-targets --all-features -- -D warningscargo nextest run(orcargo testif nextest is unavailable)
Write detailed test cases after feature implementation or bug fix if possible.
This project is currently in early development stage, so breaking changes are encouraged if they're better.
This project documents technical highlights and challenges in docs/case-studies/. As an AI agent, you MUST follow these rules:
-
New challenges/highlights: When you encounter or implement a non-trivial technical solution (e.g. a tricky architecture decision, a clever workaround, a complex data model), proactively invoke the
case-studyskill to summarize it into a new file underdocs/case-studies/. Do this after the feature or fix is complete, not before. -
Update existing case studies: When you modify code that is already covered by a case study in
docs/case-studies/, you MUST also update the corresponding case study document to keep it in sync. Checkdocs/case-studies/before committing to see if any existing docs reference the area you changed.
In short: new hard problem → write a case study; changed an already-documented area → update its case study.
- Do NOT only write documentation comments on function signatures.
- You MUST add inline comments inside function bodies.
For any non-trivial logic, you MUST explain:
- why the logic exists (not just what it does)
- edge cases being handled
- invariants or assumptions
- tricky control flow or branching
- non-obvious performance considerations
You MUST add inline comments for:
- complex conditionals (if/else with business logic)
- loops with non-obvious behavior
- state mutations
- error handling branches
- concurrency / async logic
- parsing / transformation logic
- Prefer short comments above the code block they explain
- Focus on "why", not just "what"
- Avoid obvious comments like
// increment i