diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..307a554 --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +__pycache__/ +*.pyc +.pytest_cache/ +.ruff_cache/ +.env +tenants/*.db +tenants/*.db-wal +tenants/*.db-shm +platform.db +platform.db-wal +platform.db-shm +data/uploads/ +admin/node_modules/ +admin/dist/ +.playwright-mcp/ +.worktrees/ diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..e851915 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,21 @@ +# CLAUDE.md — all-kefu 工作约定 + +## 项目定位 + +本项目 all-kefu 是**统一多租户 AI 客服平台**:一套引擎 + 租户配置包,消除"每客户复制一套代码"的旧模式。项目由 ai-kefu / ai-kefu-jc 两个复制分叉项目合并而来,**jc 为主线**(代码以 ai-kefu-jc 为基础迁移,再做租户化改造)。 + +## 硬约束 + +- **uvicorn 必须以 `--workers 1` 运行**。内存中的 token 缓存、限流状态、配置缓存、每租户 engine 缓存均假设单进程,多 worker 会导致状态割裂。任何启动脚本/部署配置不得改动此项。 +- **Windows 环境**:跑 python / pytest 前设置 `PYTHONUTF8=1`(GBK 控制台遇 emoji / 中文 payload 会直接崩,血泪教训)。 + +## 开发流程 + +- 改动 `seed_profiles` 后必须跑全量 pytest(出厂配置影响面大)。 +- 目前尚无 tests/ 目录时的 pytest 报错属预期,后续任务会补齐。 + +## 文档索引 + +- 设计文档(spec):`docs/superpowers/specs/2026-10-12-unified-kefu-platform-design.md` +- Phase 1 实施计划:`docs/superpowers/plans/2026-10-12-phase1-engine-merge-tenantization.md` +- 部署坑手册:Phase 4 补 `docs/deploy-production.md`(尚未存在) diff --git a/README.md b/README.md new file mode 100644 index 0000000..a6d304d --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# all-kefu + +统一多租户 AI 客服平台:一套引擎 + 租户配置包,消除此前"每客户复制一套代码"的分叉模式。项目由 ai-kefu / ai-kefu-jc 两个复制分叉项目合并而来(jc 为主线),Phase 1 起进行引擎合并与租户化改造。 + +设计文档(spec):[docs/superpowers/specs/2026-10-12-unified-kefu-platform-design.md](docs/superpowers/specs/2026-10-12-unified-kefu-platform-design.md) diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..78c5011 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +asyncio_mode = auto +testpaths = tests diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..ee4ba01 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,2 @@ +pytest +pytest-asyncio diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..d3f0e9d --- /dev/null +++ b/requirements.txt @@ -0,0 +1,14 @@ +fastapi>=0.115.0 +uvicorn[standard]>=0.34.0 +sqlalchemy[asyncio]>=2.0.0 +aiosqlite>=0.20.0 +alembic>=1.14.0 +zhipuai>=2.1.5 +aiosmtplib>=3.0.0 +httpx>=0.27.0 +pydantic>=2.0.0 +pydantic-settings>=2.0.0 +python-dotenv>=1.0.0 +sniffio>=1.3.0 +iptocc>=0.1.0 +phonenumberslite>=9.0