From bf8f271840b12e84e3bb325dc24121b80fdfa356 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 9 Sep 2026 20:19:55 +0800 Subject: [PATCH] feat(redis): Update Redis configuration and enhance compatibility with Docker - Changed Redis port mapping in `docker-compose.yml` from `6379:6379` to `6380:6379` to avoid conflicts with Windows Redis. - Updated `.env.example` to reflect the new Redis URL (`redis://127.0.0.1:6380/0`), ensuring proper configuration for Docker users. - Enhanced Redis client initialization in `database.py` and `redis_gateway.py` to utilize a new `_redis_kwargs` function for improved compatibility with Windows Redis 3.x and Docker Redis 7. - Added a new PowerShell script `start-redis.ps1` to facilitate starting Redis in Docker, providing a seamless setup experience for developers. This update significantly improves the Redis integration, ensuring a smoother development process and better compatibility across environments. --- .env.example | 4 +-- AGENTS.md | 2 +- app/config/database.py | 17 +++++++----- app/service/risk/redis_gateway.py | 4 ++- docker-compose.yml | 2 +- docs/memory/FLOW.md | 20 +++++++++----- docs/memory/FRAMEWORK.md | 6 ++--- docs/memory/MEMORY.md | 27 ++++++++++++------- docs/memory/TODO.md | 6 +++-- scripts/dev/start-redis.ps1 | 44 +++++++++++++++++++++++++++++++ 10 files changed, 99 insertions(+), 33 deletions(-) create mode 100644 scripts/dev/start-redis.ps1 diff --git a/.env.example b/.env.example index c297032..3088dda 100644 --- a/.env.example +++ b/.env.example @@ -9,8 +9,8 @@ MYSQL_CORE_DATABASE=jinrong_core MYSQL_USER=root MYSQL_PASSWORD= -# Redis -REDIS_URL=redis://127.0.0.1:6379/0 +# Redis(Docker:docker compose up -d redis · 宿主机 6380 → 容器 6379 · 避开 Windows Redis 3.x 占 6379) +REDIS_URL=redis://127.0.0.1:6380/0 # Neo4j NEO4J_URI=bolt://localhost:7687 diff --git a/AGENTS.md b/AGENTS.md index a8cf79a..b5a1b5c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -38,6 +38,6 @@ app/repository/core_ro.py # Core 只读 + check_suitability(R-02) scripts/core/reset.ps1 # 本地灌 Core 模拟库 ``` -**当前分支:** `merger` · **测试基线:** `python -m pytest` → 730 passed, 0 skipped +**当前分支:** `merger` · **测试基线:** `python -m pytest` → 730 passed · **Redis:** Docker `6380` · **前端:** `cd web && npm run build/test` 技术选型硬阀门见 MEMORY 第 3、7 节。Cursor 以 `.cursor/rules/project-memory.mdc` 为准。 diff --git a/app/config/database.py b/app/config/database.py index 28eb00f..24f6cbf 100644 --- a/app/config/database.py +++ b/app/config/database.py @@ -28,12 +28,17 @@ def get_core_engine() -> Engine: return create_engine(_mysql_url(settings.mysql_core_database), pool_pre_ping=True) +def _redis_kwargs() -> dict: + """RESP2:兼容 Windows Redis 3.x(无 HELLO);Redis 7 Docker 同样可用。""" + return { + "decode_responses": True, + "protocol": 2, + "socket_timeout": 5, + "socket_connect_timeout": 3, + } + + @lru_cache def get_redis_client() -> redis.Redis: """Redis 单例客户端(客服线 VisitorMemory / ProfileHotCache 用)。""" - return redis.from_url( - settings.redis_url, - decode_responses=True, - socket_timeout=5, - socket_connect_timeout=3, - ) + return redis.from_url(settings.redis_url, **_redis_kwargs()) diff --git a/app/service/risk/redis_gateway.py b/app/service/risk/redis_gateway.py index 3315ef6..e55e1ae 100644 --- a/app/service/risk/redis_gateway.py +++ b/app/service/risk/redis_gateway.py @@ -26,7 +26,9 @@ class RedisGateway: if self._client is None: import redis - self._client = redis.Redis.from_url(self._url, decode_responses=True) + from app.config.database import _redis_kwargs + + self._client = redis.Redis.from_url(self._url, **_redis_kwargs()) return self._client def publish(self, channel: str, payload: dict[str, Any]) -> None: diff --git a/docker-compose.yml b/docker-compose.yml index 516cb24..5ca309a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: image: redis:7-alpine container_name: jinrong-redis ports: - - "6379:6379" + - "6380:6379" volumes: - jinrong_redis_data:/data restart: unless-stopped diff --git a/docs/memory/FLOW.md b/docs/memory/FLOW.md index bfb9a81..e0aaa40 100644 --- a/docs/memory/FLOW.md +++ b/docs/memory/FLOW.md @@ -8,7 +8,7 @@ ## 0. 本地 bootstrap(新环境 / 新 Agent) ```text -前置:MySQL 8、Redis、Neo4j Desktop、Ollama(bge-m3) 已安装并启动 +前置:MySQL 8、**Docker Desktop(Redis + 可选 Neo4j compose)**、Ollama(bge-m3) 已安装并启动 ① 配置 cp .env.example .env @@ -28,12 +28,18 @@ ⑤ 同步 python scripts/sync/sync_advisor_rel.py → customer_advisor_rel - python scripts/sync/sync_neo4j.py → 关系图 + python scripts/sync/sync_neo4j.py → 关系图(需 compose neo4j 或 Desktop) + +⑤b Redis(推荐 Docker) + docker compose up -d redis + # 或 .\scripts\dev\start-redis.ps1 + # .env: REDIS_URL=redis://127.0.0.1:6380/0 (避开本机 Windows Redis 占 6379) ⑥ 验证 uvicorn app.main:app --reload GET http://127.0.0.1:8000/health → {"status":"ok"} - python -m pytest → 530 passed 0 skipped(改路由必同步 test_all_routers_mounted) + cd web && npm run dev → 5173 代理 8000 + python -m pytest → 730 passed 0 skipped RBAC 联调账号:scripts/dev/rbac-seed-reference.md ``` @@ -48,13 +54,13 @@ RBAC 联调账号:scripts/dev/rbac-seed-reference.md Client → Gateway(JWT/RBAC) → api/chat → agent_service(LangGraph) → Tools → 存储 → 响应 + audit_log ``` -当前:**风控全链路 + Wave 0 共用底座 + 代销平台 API v0.1 + AL-09 合并接线已完成(2026-09-08,`merger` 分支)**——B1~B9b 事件线 · C1~C6 对话/追加需求(FR-8/9/10)· 前端接入 B/C(sessions/stream)· T-03/T-04/T-21 · JWT 统一 + auth_adapter 接缝。**测试基线:`python -m pytest` → 530 passed 0 skipped**(含 `test_module_boundary` 宿主 D 类文件排除规则)。 +当前:**风控全链路 + Wave 0 共用底座 + 代销平台 v0.1 + AL-09 + 客服 S2 + 前端 P0 主链路(2026-09-09,`merger`)**。**测试基线:`python -m pytest` → 730 passed** · **`web/` 19 Vitest 绿**。 -**下一步(统筹 P1):** 前端 `web/` P0 真接(见 TODO · `docs/superpowers/specs/2026-09-09-frontend-p0-design.md` §6)· 接口契约 v0.1 发群 · 客户/代理人/分析 Agent 并行。 +**下一步(统筹 P1):** analytics 问数页 · 接口契约发群 · customer Chat SSE(后端 stream 未接 customer_service)。 -**本机已就位状态(2026-09-08 · 已完成上述 ①~⑤,无需重做):** `.env` 已配置(学习项目;DEEPSEEK_API_KEY 空时 chat 走降级回复;JWT 未配项时走默认 `JWT_DEV_SECRET`,**启动 warning 属预期**);`jinrong_core` + `jinrong_agent` 已灌库(33 客户/14 产品/矩阵 25 行/风评 33 / AML 8 条 / 归属 33 行);`python -m pytest` **530 绿 0 skipped**(集成测试真连本机 MySQL;Windows 中文乱码跑 `python scripts/dev/fix_utf8_seed.py`);Redis `redis://127.0.0.1:6379/0` 在跑。**演示/走查后按《演示SOP-风控模块.md》§2 重灌**(`reset.ps1` + `prepare_risk_demo.sql` 两步必跑)。 +**本机已就位状态(2026-09-09):** `.env` 含 `REDIS_URL=redis://127.0.0.1:6380/0`(Docker Redis 7);pytest **730 绿**;前端 Chat/平台页已真接。**演示/走查后按《演示SOP-风控模块.md》§2 重灌**。 -**本机已知坑:** `mysql.exe` 不在 PATH(位于 `C:\Program Files\MySQL\MySQL Server 8.0\bin`);`reset.ps1` 的交互式 `-p` 在自动化执行时会卡死——脚本化重灌用 `MYSQL_PWD` 环境变量传密码(交互执行不受影响,不把密码写进仓库脚本);**`redis` 与 `python-jose[cryptography]` 包均出现过 requirements 有而环境漏装(B9a 补装 redis、Wave 0 补装 jose,2026-09-07),重装环境后先 `python -c "import jose, redis"` 自检**。 +**本机已知坑:** `mysql.exe` 不在 PATH;`reset.ps1` 自动化用 `MYSQL_PWD`;**6379 常被 Windows Redis 3.x 占用** → 项目 Docker 映射 **6380**;Milvus 中文路径需英文 `MILVUS_URI`;重装环境后 `python -c "import jose, redis"` 自检。 ------ diff --git a/docs/memory/FRAMEWORK.md b/docs/memory/FRAMEWORK.md index 7b1bb3a..e08df22 100644 --- a/docs/memory/FRAMEWORK.md +++ b/docs/memory/FRAMEWORK.md @@ -14,12 +14,12 @@ | 后端语言/框架 | Python 3.13.14 + FastAPI | 系统 Python | | Agent 编排 | **LangGraph** 1.2.x + langchain-core / langchain-openai 1.6.0 | DeepSeek API;StateGraph + Tool 节点 | | 关系库 | MySQL 8.0.46 | **双库**:`jinrong_agent` + `jinrong_core` | -| 缓存 | Redis 8.10.1 | :6379 | +| 缓存 | Redis 7(Docker `redis:7-alpine`) | 宿主机 **6380**→容器 6379 · `.env REDIS_URL=redis://127.0.0.1:6380/0` · `scripts/dev/start-redis.ps1` | | 图库 | Neo4j 5.26.19 Enterprise | Desktop;`sync_neo4j.py` 灌图 | | 向量库 | Milvus Lite + pymilvus 3.0.1 | 本地 `./data/milvus.db`;1024 维 | | Embedding | Ollama bge-m3 | 本地,不出内网 | | LLM 生成 | DeepSeek API | 对话/推理 | -| 前端 | React 19 + Vite 8 + **AntD 6** + **Tailwind CSS v4** + TS strict | **`web/` 四角色 Dashboard 已真接平台读 API**(`hooks`+`api`+`components/ui|dashboard|layout`);Chat/SSE/market 待接;见 `docs/frontend/FRONTEND-HANDOFF.md` | +| 前端 | React 19 + Vite 8 + **AntD 6** + **Tailwind CSS v4** + TS strict | **`web/` P0 主链路已真接**(ChatPanel · 四 Agent 对话 · 平台只读 · 行情 · 风控台账);见 `docs/frontend/FRONTEND-HANDOFF.md` | | 对象存储 | 本地目录 `data/kb/` | 不用 MinIO | | 部署 | Windows 原生 | Docker 仅答辩备选 | @@ -43,7 +43,7 @@ | 共用底座 | 会话、审计、输入防护 | MySQL 11 表 + Redis | **已接入(2026-09-07)**:会话(T-06 session_repository + memory_service 窗口)、审计中间件(T-02 http_access + input_guard_log 双写)、agent_tool_call Tool 留痕(T-04)、输入防护(T-03 input_guard:注入词表纯函数检测 + oversize + Redis 固定窗口限流,chat 链路 限流→注入/超长→归属) | | 对话编排 | LangGraph StateGraph + DeepSeek | langgraph/langchain-openai | **已实现(T-07 骨架 + T-04 Tool 节点 + C1 风控四 Tool + C2 risk 分支,2026-09-07)**:tool(分组关键词意图→Tool,customer/advisor/risk)→llm→guard(免责声明);analyst 分支与 LLM intent 待后续 | | 同步脚本 | 归属、Neo4j | Core → agent / 图库 | **sync_*.py 已实现** | -| 前端 Demo(`web/`) | 四角色工作台、平台读 UI、Chat SSE | FastAPI v0.1 + chat B/C | **脚手架(2026-09-09)**:登录/Layout/路由/占位;**待接** ChatPanel、customer/risk SSE、alerts、market、analytics | +| 前端 Demo(`web/`) | 四角色工作台、平台读 UI、Chat | FastAPI v0.1 + chat B/C | **P0 主链路已接(2026-09-09)**:ChatPanel/SSE · 游客试聊 · customer 同步 Chat · 档案/持仓/流水/行情/风控台账+处置;analytics 问数待接 | ------ diff --git a/docs/memory/MEMORY.md b/docs/memory/MEMORY.md index a857acc..ba648a9 100644 --- a/docs/memory/MEMORY.md +++ b/docs/memory/MEMORY.md @@ -9,7 +9,7 @@ **项目是什么:** 金融四 Agent(客户财富 / 代理人 / 数据分析 / 风控)共用数据层与合规底座;**不**互调 LLM,跨 Agent 走 L1/L2/L3 画像与预警表。 -**当前进度:** 需求与表设计已定 · **风控模块 B1~B9b + C4~C6 + chat B/C + AL-09 合并** · **代销平台 API v0.1 已落地** · **客服 Agent S2 接缝收尾**(visitor 试聊 + customer 并行分流 · Wave 1~5 测试绿 · CS-C-11 迁移已执行) · **730 passed 0 skipped** · **`web/` 静奢智能 UI 已落地** · **`npm run build/test/lint` 绿(14 例 Vitest)**。**下一步:ChatPanel/SSE · 前端 customer Chat。** +**当前进度:** 需求与表设计已定 · **风控 B1~B9b + C4~C6 + chat B/C + AL-09 合并** · **代销平台 API v0.1** · **客服 Agent S2 收尾**(visitor + customer 分流 · fin_* KB · Wave 1~5 绿 · CS-C-11 迁移) · **730 passed** · **`web/` 前端 P0 主链路已真接**(ChatPanel · 游客试聊 · 四 Agent 对话 · 平台只读页 · 行情 · 风控台账处置) · **`npm run build/test/lint` 绿(19 例 Vitest)** · **Redis:Docker `jinrong-redis` @ 127.0.0.1:6380**。下一步:analytics 问数页 · 接口契约发群 · customer Chat SSE(后端未接 stream)。 **工作分支:** 团队开发在 **`merger`**(已 merge 风控模块);历史开发分支 `risk-control-agent` 交付冻结。旧文档中「待 AL-09 合并」口径已过时。 @@ -37,9 +37,11 @@ | `app/repository/core_ro.py` | **已实现** | Core 只读 SELECT(含风控扩展 sum_trades_on_date / list_trades_range / list_active_customers);**阶段一吸收 main:check_suitability(C×R 矩阵判定,CURDATE() 改 Python 端 `_is_expired`)/ list_products_for_customer / list_holdings 合并(limit=500+新列)/ list_trades / get_customer_l0 扩列版** | | `app/repository/risk_repository.py` | **已实现** | risk_alert / risk_suitability_log / L3 / risk_aml_list / audit_log / input_guard_log 读写 | | `app/utils/` | **基本就绪** | trace(trace_id+request_id 双 contextvar)/ desensitize / db(引擎工厂)/ response(统一错误体+4xx/500 handler)/ exceptions(含 ApiError)已实现;logger 占位 | -| `app/config/settings.py` | **已实现** | 双库 + risk_* 阈值 + JWT 配置(jwt_public_key_path/jwt_dev_secret/jwt_issuer/jwt_audience) | +| `app/config/database.py` | **已实现** | MySQL 双引擎 + **Redis 单例**(`REDIS_URL` · **RESP2 `protocol=2`** 兼容 Docker Redis 7 / 旧 Windows Redis 3) | +| `app/config/settings.py` | **已实现** | 双库 + risk_* 阈值 + JWT + **customer/visitor/profile** 字段 + `kb_root_dir` | +| `app/service/customer_service.py` `visitor_service.py` | **已实现(S2)** | 客服 14 节点 · 游客 9 节点 LangGraph;RAG 走 **fin_* 三库**;Redis 记忆 **fail-open** | | `scripts/core/*.sql` + `reset.ps1` | **已实现** | Core 模拟库 DDL + 种子 | -| `scripts/agent/` `scripts/demo/` `scripts/dev/` | **已实现** | AML 名单种子 + 风控演示数据 + `fix_utf8_seed.py`/`run_sql_file.py`(Windows UTF-8 灌库)+ issue_dev_token | +| `scripts/agent/` `scripts/demo/` `scripts/dev/` | **已实现** | AML 种子 + 演示数据 + `run_sql_file.py` + **`start-redis.ps1`**(Docker Redis 优先)+ issue_dev_token | | `scripts/sync/*.py` | **已实现** | 归属同步 + Neo4j 全图 | | `tests/` | **已实现** | 37+ 测试模块 **730 用例 0 skipped**(含客服 Wave 1~5;sqlite + 真 MySQL 集成;`test_module_boundary` 宿主 D 类排除)。改路由必同步 `tests/test_main.py::test_all_routers_mounted` | | `docs/需求拆解/` | 已定 | 场景 P0、矩阵、合规原文 | @@ -52,7 +54,7 @@ | `docs/项目框架设计/接口契约-代销平台API-v0.2-行情扩展草案.md` | **草案(2026-09-09)** | `nav-snapshot` · `sync_market_nav` · 前端产品行情 Phase B | | `docs/项目框架设计/表设计/` | 已定 | Agent 共用 11 表 + agent 专用 SQL | | `docs/项目框架设计/Core模拟底座/` | 已定 | 无真实 Core 时的 L0 方案 | -| `web/` | **静奢智能 UI(2026-09-09)** | React 19 + Vite 8 + **AntD 6** + **Tailwind CSS v4**(`@tailwindcss/vite`)+ HashRouter;`components/ui`/`dashboard`/`layout` 分层 · 四角色首页真调 `customers/products/advisors/risk` · **未接** ChatPanel/SSE、共享 `/app/market`、risk 处置 UI;交接 **`docs/frontend/FRONTEND-HANDOFF.md`** | +| `web/` | **静奢智能 UI + P0 真接(2026-09-09)** | `ChatPanel`/`useChatPanel` · **customer 同步 Chat** · **risk/advisor/analyst SSE** · 登录页 **VisitorChatWidget** · 档案/持仓/流水/行情/风控台账+处置 · `web/src/api/chat.ts` · 交接 **`docs/frontend/FRONTEND-HANDOFF.md`** | **本地 bootstrap(首次):** 完整步骤与前置说明见 `FLOW.md` §0(权威),速览: @@ -65,12 +67,15 @@ 5. mysql … < scripts/agent/seed-aml-list.sql # AML 名单(Windows 乱码:`python scripts/dev/fix_utf8_seed.py`) (风控演示:scripts/demo/prepare_risk_demo.sql,reset 后重跑) 6. python scripts/sync/sync_advisor_rel.py && python scripts/sync/sync_neo4j.py -7. uvicorn app.main:app --reload → GET /health;`docker compose up -d redis`(限流/会话窗口);python -m pytest(**730 绿**,系统 Python 3.13.14) +7. `docker compose up -d redis`(或 `.\scripts\dev\start-redis.ps1`)→ **REDIS_URL=redis://127.0.0.1:6380/0**(Docker Redis 7;避开本机 Windows Redis 占 6379) +8. uvicorn app.main:app --reload → GET /health;`cd web && npm run dev`(5173 代理 8000);python -m pytest(**730 绿**) ``` **AL-09 合并后架构(一句话):** 宿主 `gateway/` + 模块 `deps.py` **双栈并存**;对外登录/token **统一**;chat/risk 均走模块鉴权;接缝 S2 用 `auth_adapter`。 -**下一步(见 TODO):** 前端 ChatPanel/SSE(customer/risk/advisor)· 共享 `/app/market` · risk 台账处置 UI · 接口契约发群 · Agent 合并改调 platform Service。 +**下一步(见 TODO):** analytics 问数页 · 接口契约发群 · customer Chat 流式(后端 `/stream` 未接 customer_service)· simulate 交易 UI(不做)。 + +**Redis(2026-09-09):** 推荐 **Docker** `jinrong-redis`(`redis:7-alpine`)· 宿主机 **6380** → 容器 6379 · `.env` `REDIS_URL=redis://127.0.0.1:6380/0` · 客户端 **RESP2**(`database.py` / `redis_gateway.py`)。 **前端启动(`web/`):** `npm install` → `npm run dev`(`5173`,`/api` 代理 `8000`)· 验收四 demo 账号见 **`docs/frontend/FRONTEND-HANDOFF.md` §8** · 改 UI 后跑 `npm run build && npm run test && npm run lint`。 @@ -93,8 +98,8 @@ ## 1. 项目简介 - **名称:** JinRong 金融四 Agent 智能管家 -- **当前阶段:** **代销平台 API v0.1 + AL-09 合并 + `web/` P0 脚手架(2026-09-09)**——530 测试绿;前端业务页与 Agent SSE **待接** -- **当前优先级:** 前端 P0 真接 API/SSE(统筹)/ 接口契约发群 / Agent 队友并行(合并期改调 platform canonical API) +- **当前阶段:** **代销平台 v0.1 + AL-09 + 客服 S2 + 前端 P0 主链路真接(2026-09-09)**——730 pytest 绿 · 19 Vitest 绿 +- **当前优先级:** analytics 问数 · 接口契约发群 · customer SSE(后端)· simulate UI(显式不做) ------ @@ -157,7 +162,9 @@ Core 模拟:scripts/core/reset.ps1 · 文档 docs/项目框架设计/Core模 种子:scripts/agent/seed-aml-list.sql(AML 名单)· scripts/demo/prepare_risk_demo.sql(reset 后重跑) 依赖:requirements.txt(LangGraph + langchain-core/openai + FastAPI + SQLAlchemy) 启动:uvicorn app.main:app --reload → GET /health -测试:python -m pytest(**730 绿**;集成测试需本机 MySQL + `risk_aml_list` + `prepare_risk_demo.sql`) +Redis:`docker compose up -d redis` · `REDIS_URL=redis://127.0.0.1:6380/0` · `scripts/dev/start-redis.ps1` +测试:python -m pytest(**730 绿**;集成需本机 MySQL + `risk_aml_list` + `prepare_risk_demo.sql`) +前端:cd web && npm run dev · npm run build/test/lint(**19** Vitest) 运维/演示脚本:scripts/demo/subscribe_alerts.py(订阅推送演示)· rebuild_alerts.py TRD-xxx(引擎异常补偿重放) JWT 联调:python scripts/dev/issue_dev_token.py --sub STAFF-30001 --roles risk_officer(+ Authorization: Bearer + X-Agent-Type) 配置:.env(见 .env.example) @@ -205,6 +212,6 @@ RBAC 联调账号:scripts/dev/rbac-seed-reference.md 2. 改动属于 api / service / tool / repository 哪一层? 3. 是否需 customer_id 归属与 JWT RBAC? 4. Core 是模拟库只读还是 agent 库读写? -5. 如何验证?(`python -m pytest` 全量(当前 **730 绿**)· `docker compose up -d redis` · uvicorn + /health · 平台 `/api/customers/*` · `tests/test_module_boundary.py` 全绿) +5. 如何验证?(`python -m pytest` **730 绿** · `docker compose up -d redis` + `.env` **6380** · uvicorn + `/health` · `web/` build/test · 平台 `/api/customers/*` · 登录页游客试聊 · 客户助手 Chat) 大任务:FRAMEWORK/FLOW 与实现状态不符时先更新 memory 再编码(用户确认跳过除外)。 diff --git a/docs/memory/TODO.md b/docs/memory/TODO.md index 0b21af0..439eeae 100644 --- a/docs/memory/TODO.md +++ b/docs/memory/TODO.md @@ -5,14 +5,16 @@ ## 进行中 -**AL-09 合并接线已完成(2026-09-08,`merger` 分支)**:JWT 统一 · 模块 chat/agent/memory 恢复 · auth_adapter 接线 · trace 中间件修复(应用异常 re-raise)· **530 passed 0 skipped** ✓ +**前端 P0 主链路真接(2026-09-09)**:ChatPanel · 游客/客户/风控/顾问/分析 Chat · 平台只读页 · 行情 · 风控台账处置 · **730 passed** · **19 Vitest** ✓ + +**Redis Docker(2026-09-09)**:`jinrong-redis` @ **6380** · `.env REDIS_URL` 已对齐 · `scripts/dev/start-redis.ps1` ✓ ## 待办(统筹 · P1 推荐顺序) - [x] **代销平台 API v0.1 实现**(2026-09-08):`customers/products/advisors/staff/compliance` + `service/platform/` + `PLATFORM_RESPONSE_DESENSITIZE` · **530 passed 0 skipped** - [x] **`web/` P0 脚手架 init**(2026-09-09):Vite+AntD+HashRouter · 登录真接 · AppLayout · 四角色路由 · 占位页 · 见 `web/README.md` · 设计 `docs/superpowers/specs/2026-09-09-frontend-p0-design.md` - [ ] **接口契约发群**(login + 平台读 API + simulate/trade;强调重复功能以平台路径为准) -- [ ] **前端 P0 真接**(见下方「前端 web/ · P0 待接」子清单;顺序见 frontend spec §6) +- [ ] **前端 P0 真接**(主链路已完成;余 analytics 问数 · 契约发群 · simulate 说明) - [ ] 同步 `MEMORY/REQUIREMENTS/FRAMEWORK` 与各 Agent 负责人联调节奏 ### 前端 `web/` · P0 待接(后端已就绪) diff --git a/scripts/dev/start-redis.ps1 b/scripts/dev/start-redis.ps1 new file mode 100644 index 0000000..c99931a --- /dev/null +++ b/scripts/dev/start-redis.ps1 @@ -0,0 +1,44 @@ +#Requires -Version 5.1 +<# +.SYNOPSIS + 启动本机 Redis(Docker 优先,与 docker-compose.yml 一致)。 +.EXAMPLE + .\scripts\dev\start-redis.ps1 +.NOTES + 连接串:.env REDIS_URL=redis://127.0.0.1:6380/0(Docker 映射,避开本机 Windows Redis 占 6379) +#> +$ErrorActionPreference = "Stop" +$Root = Split-Path (Split-Path $PSScriptRoot -Parent) -Parent +Set-Location $Root + +function Test-DockerRedis { + try { + $p = docker exec jinrong-redis redis-cli ping 2>$null + return $p -match "PONG" + } catch { + return $false + } +} + +if (-not (Get-Command docker -ErrorAction SilentlyContinue)) { + Write-Host "未找到 docker 命令,请先启动 Docker Desktop。" -ForegroundColor Red + exit 1 +} + +$winRedis = Get-Service -Name "Redis" -ErrorAction SilentlyContinue +if ($winRedis -and $winRedis.Status -eq "Running") { + Write-Host "提示:本机 Windows Redis 仍占 6379;项目已改用 Docker 6380 → 见 .env REDIS_URL" -ForegroundColor DarkYellow +} + +Write-Host "启动 Docker Redis (jinrong-redis @ 127.0.0.1:6380)..." -ForegroundColor Cyan +docker compose up -d redis +Start-Sleep -Seconds 2 + +if (Test-DockerRedis) { + docker compose ps redis + Write-Host "Docker Redis 就绪 (redis:7-alpine @ 127.0.0.1:6380)" -ForegroundColor Green + exit 0 +} + +Write-Host "Docker Redis 未响应。请检查 Docker Desktop 是否运行:docker compose logs redis" -ForegroundColor Red +exit 1