This commit is contained in:
Yaojia Wang
2026-03-30 15:09:26 +02:00
parent 407b455f19
commit cadfa01e3b
6 changed files with 2416 additions and 16 deletions

View File

@@ -44,7 +44,7 @@ AI 客服行动层框架。粘贴你的 API获得一个能执行真实操作
| 阶段 | 周期 | 内容 | 状态 | 详情 | | 阶段 | 周期 | 内容 | 状态 | 详情 |
|------|------|------|------|------| |------|------|------|------|------|
| Phase 1 | 第 1-3 周 | 核心框架 | 未开始 | [[Smart Support/Phase 1 - 核心框架]] | | Phase 1 | 第 1-3 周 | 核心框架 | COMPLETED (2026-03-30) | [[Smart Support/Phase 1 - 核心框架]] |
| Phase 2 | 第 3-4 周 | 多 Agent + 安全 | 未开始 | [[Smart Support/Phase 2 - 多 Agent + 安全]] | | Phase 2 | 第 3-4 周 | 多 Agent + 安全 | 未开始 | [[Smart Support/Phase 2 - 多 Agent + 安全]] |
| Phase 3 | 第 4-6 周 | OpenAPI 自动发现 | 未开始 | [[Smart Support/Phase 3 - OpenAPI 自动发现]] | | Phase 3 | 第 4-6 周 | OpenAPI 自动发现 | 未开始 | [[Smart Support/Phase 3 - OpenAPI 自动发现]] |
| Phase 4 | 第 6-7 周 | 分析 + 回放 | 未开始 | [[Smart Support/Phase 4 - 分析 + 回放]] | | Phase 4 | 第 6-7 周 | 分析 + 回放 | 未开始 | [[Smart Support/Phase 4 - 分析 + 回放]] |
@@ -60,6 +60,12 @@ AI 客服行动层框架。粘贴你的 API获得一个能执行真实操作
- 分支:`main` - 分支:`main`
- 本地路径:`/Users/yiukai/Documents/git/smart-support` - 本地路径:`/Users/yiukai/Documents/git/smart-support`
## 完整文档(已同步)
- [[Smart Support/Architecture]] - 系统架构文档12 章,含 ADR、数据库设计、API 协议)
- [[Smart Support/Development Plan]] - 详细开发计划6 Phase任务清单 + 检查点 + 风险)
- [[Smart Support/Phase 1 Dev Log]] - Phase 1 开发日志88% 覆盖率82 个单元测试)
## 计划文档 ## 计划文档
项目根目录下: 项目根目录下:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,95 @@
---
created: "2026-03-30"
type: log
project: "[[Smart Support]]"
source: "docs/phases/phase-1-dev-log.md"
---
# Phase 1: Core Framework -- Development Log
> Status: COMPLETED
> Phase branch: `phase-1/core-framework`
> Date started: 2026-03-30
> Date completed: 2026-03-30
> Related plan section: [Phase 1 in DEVELOPMENT-PLAN](../DEVELOPMENT-PLAN.md#phase-1-核心框架-第-1-3-周)
## What Was Built
- FastAPI WebSocket backend with `/ws` endpoint for real-time chat
- LangGraph Supervisor (via `langgraph-supervisor`) connecting 3 agents
- YAML-based Agent Registry with Pydantic validation
- 3 Mock Agents: order_lookup (read), order_actions (write + interrupt), fallback
- PostgresSaver checkpoint persistence via `langgraph-checkpoint-postgres`
- Session TTL management with 30-minute sliding window and interrupt extension
- LLM provider abstraction (Anthropic/OpenAI/Google) with prompt caching support
- Token usage tracking callback handler
- React Chat UI with streaming display, interrupt confirmation, and agent action viewer
- Docker Compose configuration (PostgreSQL 16 + backend)
## Code Structure
### New files
Backend (`backend/app/`):
- `config.py` -- pydantic-settings centralized configuration
- `db.py` -- Async PostgreSQL pool + AsyncPostgresSaver setup
- `llm.py` -- LLM provider factory (ChatAnthropic/ChatOpenAI/ChatGoogleGenerativeAI)
- `callbacks.py` -- Token usage + cost tracking callback handler
- `registry.py` -- YAML agent registry with validation + immutable config models
- `session_manager.py` -- Session TTL with sliding window + interrupt extension
- `graph.py` -- LangGraph Supervisor construction from registry
- `ws_handler.py` -- WebSocket message dispatch + streaming logic
- `main.py` -- FastAPI app entry with lifespan + WebSocket endpoint
- `agents/__init__.py` -- Tool name-to-function bridge
- `agents/order_lookup.py` -- Mock order status/tracking tools
- `agents/order_actions.py` -- Mock cancel_order with interrupt()
- `agents/fallback.py` -- Fallback response tool
Frontend (`frontend/src/`):
- `types.ts` -- WebSocket message protocol TypeScript types
- `hooks/useWebSocket.ts` -- WebSocket connection + reconnect + message dispatch
- `components/ChatMessages.tsx` -- Streaming message display
- `components/ChatInput.tsx` -- Message input
- `components/InterruptPrompt.tsx` -- Approve/reject interrupt UI
- `components/AgentAction.tsx` -- Tool call inline display
- `pages/ChatPage.tsx` -- Main chat page composing all components
Infrastructure:
- `backend/pyproject.toml` -- Dependencies + pytest + ruff config
- `backend/agents.yaml` -- Agent registry YAML config
- `backend/Dockerfile` -- Backend container
- `docker-compose.yml` -- PostgreSQL 16 + backend services
- `.gitignore` -- Updated for Python + Node artifacts
Tests (`backend/tests/unit/`):
- `test_config.py` -- Settings validation tests
- `test_registry.py` -- 17 tests for registry loading/validation
- `test_agents.py` -- 10 tests for tool functions + tool bridge
- `test_llm.py` -- 3 tests for LLM provider factory
- `test_callbacks.py` -- 9 tests for token usage tracking
- `test_session_manager.py` -- 9 tests for session TTL logic
- `test_graph.py` -- 4 tests for supervisor construction
- `test_db.py` -- 5 tests for database setup
- `test_ws_handler.py` -- 12 tests for WebSocket message handling
- `test_main.py` -- 5 tests for app configuration
## Test Coverage
- Unit test count: 82
- Integration test count: 0 (requires running PostgreSQL)
- E2E test count: 0 (manual verification in plan)
- Overall coverage: 88%
## Deviations from Plan
- Used `astream(stream_mode="messages")` instead of `astream_events()` per langgraph best practices
- Separated WebSocket handler logic into `ws_handler.py` for testability (not in original plan)
- Session manager uses in-memory storage instead of DB-backed (sufficient for Phase 1 single-instance)
## Known Issues / Tech Debt
- Session manager not DB-backed (loses state on restart) -- acceptable for Phase 1 single-instance
- WebSocket reconnect does not re-send pending interrupt state from server
- No rate limiting on WebSocket endpoint (Phase 2)
- No authentication (Phase 2)
- `main.py` coverage at 47% -- lifespan function not unit-testable without full DB

View File

@@ -65,12 +65,12 @@ npm search jwt verify
**四种预设工作流**: **四种预设工作流**:
| 工作流 | Agent 链 | | 工作流 | Agent 链 |
|--------|---------| | -------- | ------------------------------------------------------- |
| feature | planner → tdd-guide → code-reviewer → security-reviewer | | feature | planner → tdd-guide → code-reviewer → security-reviewer |
| bugfix | planner → tdd-guide → code-reviewer | | bugfix | planner → tdd-guide → code-reviewer |
| refactor | architect → code-reviewer → tdd-guide | | refactor | architect → code-reviewer → tdd-guide |
| security | security-reviewer → code-reviewer → architect | | security | security-reviewer → code-reviewer → architect |
**自定义链**: `/orchestrate custom "architect,tdd-guide,code-reviewer" "Redesign caching layer"` **自定义链**: `/orchestrate custom "architect,tdd-guide,code-reviewer" "Redesign caching layer"`
@@ -122,13 +122,13 @@ npm search jwt verify
**核心洞察**: Hook 触发率 100%确定性Skill/提示词触发率仅 50-80%(概率性)。因此关键质量控制应通过 Hook 实现,而非依赖提示词。 **核心洞察**: Hook 触发率 100%确定性Skill/提示词触发率仅 50-80%(概率性)。因此关键质量控制应通过 Hook 实现,而非依赖提示词。
| Hook 类型 | 触发时机 | 用途举例 | | Hook 类型 | 触发时机 | 用途举例 |
|-----------|---------|---------| | ------------ | ------ | ----------------- |
| PreToolUse | 工具执行前 | 开发服务器自启、安全监控 | | PreToolUse | 工具执行前 | 开发服务器自启、安全监控 |
| PostToolUse | 工具执行后 | 自动格式化、类型检查 | | PostToolUse | 工具执行后 | 自动格式化、类型检查 |
| PreCompact | 上下文压缩前 | 保存会话状态到 MEMORY.md | | PreCompact | 上下文压缩前 | 保存会话状态到 MEMORY.md |
| SessionStart | 新会话开始 | 加载上次上下文、检测包管理器 | | SessionStart | 新会话开始 | 加载上次上下文、检测包管理器 |
| Stop | 每次响应后 | 检查 debug 语句、持久化指标 | | Stop | 每次响应后 | 检查 debug 语句、持久化指标 |
**例子 — hooks.json 配置**: **例子 — hooks.json 配置**:

View File

@@ -13,8 +13,8 @@ tags:
# OpenClash 配置备份 # OpenClash 配置备份
> 路由器:`192.168.68.63` (iStoreOS, EasePi Pro) > 路由器:`192.168.68.63` (iStoreOS, EasePi Pro)
> 最后更新2026-03-19 > 最后更新2026-03-29
> 用途:仅国内视频/音乐走代理回国,其余全部直连 > 用途:仅国内视频/音乐走代理回国,其余全部直连(小红书已改为直连)
--- ---