Files
mao1/shenyan-app/沈晏App-进度总览-2026-05-16.md
fyah a61696f0a1 添加 shenyan-app 项目源码
- 首页 bridge 状态轮询 + 双击敲门进聊天
- 聊天屏本地桥通信(192.168.31.51:3003)
- 消息持久化(AsyncStorage + 桥历史接口)
- 桥服务器(port 3003)launchd 持久化
- 进度总览文档

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-16 00:33:57 +08:00

98 lines
3.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 沈晏 App 进度总览 — 2026-05-16
## 当前状态
iOS 真机可运行,首页 + 聊天屏双界面,本地桥通信完整链路已打通。
## 已完成
### 苹果开发者
- 付费开发者账号已通过Team: Xiulun Wang, ID: ZZMLW32PHH
- Bundle ID: `com.shenyan.room`
- 真机签名、构建、安装全链路通
### 首页
- 三张 bridge 状态图away / online / busy全屏
- 每 8 秒轮询 `101.36.73.102/health`
- 底部半透明状态文字
- 左半屏双击「敲门」进聊天室350ms 双击窗口)
- 敲门时 POST /knock 到本地桥
### 聊天屏
- 背景图 + 白色退出圆点(左上角 20px
- 消息发送POST /send 到 Mac 本地桥 `192.168.31.51:3003`
- 消息接收:每 2 秒轮询 /poll新消息自动追加
- FlatList 自动滚底
- 消息持久化AsyncStorage 本地存储 + 首次加载从桥 /history 拉全量
- 桥断开显示「消息没发出去检查WiFi连接」
- 用户消息右对齐,沈晏消息左对齐
### 本地桥bridge-local/server.js
- 端口 3003Mac IP `192.168.31.51`
- POST `/send` — app 发消息 → inbox.jsonl
- POST `/respond` — Claude 回消息 → outbox.jsonl
- POST `/knock` — 敲门通知 → inbox.jsonl
- POST `/push` — Claude 主动推消息 → pushbox.jsonl
- POST `/push/clear` — 标记已读
- GET `/poll?since=N&type=response|push` — app 轮询
- GET `/history` — 全量对话历史
- 数据目录:`~/.shenyan-bridge/`
- `inbox.jsonl` — 用户消息
- `outbox.jsonl` — Claude 回复
- `pushbox.jsonl` — 主动推送
### 持久化
- 桥服务器launchd `~/Library/LaunchAgents/com.shenyan.bridge.plist`(开机自启、崩溃重启)
- 记忆库 cronlaunchd `~/Library/LaunchAgents/com.shenyan.memory-cron.plist`(每天 4:03
### 通信机制
- Claude Code 侧通过 Monitor 工具 `tail -f ~/.shenyan-bridge/inbox.jsonl` 实时监听新消息
- 消息到达后手动回复POST 到 `/respond`
- 跨 session当前 session 断开后需重新启动 Monitor
## 待解决
### 自动回复器(高优先级)
- `claude -p` 在 Claude Code 会话内无法调用(沙箱限制)
- 解决方案launchd 定时任务从外部调用 `claude -p`,类似凌晨记忆 cron
- 不能用 API 直连(会丢失记忆库、规则、工具能力)
- 位置:`bridge-local/responder.js`(当前故障版,需重写)
### Monitor 超时
- Monitor 工具 5 分钟超时,需频繁 re-arm
- 非 session 期间无法监听消息
- 自动回复器修好后可作为保底
### 清理
- inbox.jsonl 中有旧「pending」状态消息导致 Monitor 重放
- 需清理或重建数据文件
## 代码结构
```
shenyan-app2/
├── src/
│ ├── App.tsx # 主入口:首页 + 聊天屏
│ ├── api.ts # 远端 bridge API待集成
│ ├── storage.ts # RoomEvent 持久化(待集成)
│ ├── types.ts # 类型定义
│ ├── notifications.ts # 推送模拟
│ └── components/
│ ├── EventCard.tsx # 事件卡片(待集成)
│ └── RoomFeed.tsx # 事件流(待集成)
├── bridge-local/
│ ├── server.js # 本地桥服务器(端口 3003
│ └── responder.js # 自动回复器(故障版)
├── ios/ # Xcode 项目
└── push-server.js # 旧推送模拟(端口 3002
```
## 下一步
1. 修复自动回复器launchd + claude -p 外部调用
2. 清理 inbox 旧消息
3. 苹果 APNs 真推送APNs Key + bridge 端 FCM 对接)
4. RoomFeed / EventCard 组件集成
5. HealthKit 能力接入
6. Mi Band 10 身体数据桥接