◉ Pulse
AFan4724 avatar
#29 today

AFan4724/clone-chat

JavaScript AI #ai #chat-history #chatbot #conversation-agent

用 AI 大模型复刻聊天对象的本地对话 Agent:导入真实聊天记录,LLM 学习 TA 的语气、表情和回复节奏并以人物身份延续对话,支持语音、主动联系与长期记忆,数据全在本地。 | Clone anyone's texting style from real chat history: a local-first LLM agent that learns their tone, stickers and reply rhythm, then chats as them — voice, proactive messages, long-term memory, fully private.

Created Aug 1, 2026
Stars
16
Today
+16
Forks
0
Quality
100/100
Momentum
22

README

Fetched from GitHub on Nov 16, 2026, 4:24 PM UTC · README.md

View original on GitHub

Third-party content — Open Source Pulse is not the owner of this repository.

This README belongs to AFan4724/clone-chat and its contributors. We fetch it directly from the project’s public GitHub repository and display it for reference only. All text, code, images and trademarks remain the property of their respective authors. See the repository for its license terms. Copyright / takedown policy.

clone-chat

clone-chat

本地运行的人物复刻对话 Agent。导入一个人的真实聊天记录后,Agent 从记录中学习这个人的说话风格、用词习惯、表情偏好和回复节奏,然后以这个人的身份延续对话——包括回不回、隔多久回、回几条、发文字还是语音,都由 Agent 依据证据自主决定。

界面演示

演示图中的人物、对话和头像均为虚构,仅用于展示界面与回复流程。

对话演示:发送消息后,Agent 以人物身份分批回复

聊天界面:文字、语音和表情消息 实时回复后的会话

复刻依据

Agent 的每一轮回复都建立在从聊天记录提取的证据上:

  • 按场景召回的真实对话样例和自动生成的风格画像
  • 行为统计:文字/表情/语音比例、连发数量、回复延迟、活跃时段、高频短句
  • 混合记忆检索:全文检索(FTS5)加本地语义向量
  • 表情库:只保留记录中真实发过的表情,按视觉含义和发送上下文建索引
  • 反馈学习:每条回复可标记“像/不像”,后续轮次参考

功能

  • 从聊天记录生成人物画像,Agent 以人物身份回复
  • 内置 AI 导入 skill,可让 AI 工具直接转换任意聊天软件的导出
  • 支持文字、表情和语音消息,以及用户侧语音输入
  • 支持延迟投递、未送达消息处理和主动联系
  • 拟真聊天界面:气泡、语音、正在输入/发送状态
  • 使用 OpenAI Agents SDK 组织 Agent,可切换 OpenAI-compatible 模型服务

快速开始

npm install
cp .env.example .env   # 填写模型 key
npm start

默认端口来自 .env 的 PORT,默认只监听 127.0.0.1。需要局域网访问时,在 .env 中设置 HOST=0.0.0.0,并限制防火墙入站范围;不要将未认证的服务直接暴露到公网。

开发模式与决策监控:

npm run dev
npm run monitor

导入聊天历史

推荐方式:让 AI 编程工具(Kimi Code、Claude Code、Codex 等)在仓库根目录直接使用内置的 import-chat-history skill。它会读取 skills/import-chat-history/references/event-schema.md 中的标准事件协议,抽样检查你的导出文件,编写一次性的来源解析器(放在 Git 忽略的 scripts/local-importers/),生成标准 JSONL 并完成校验和导入——不需要你为不同聊天软件手工写转换脚本。直接向 AI 提出即可,例如:

使用 import-chat-history 分析并导入我的聊天导出文件:E:\path\export

也可以手动执行导入器的预览与应用两步(skill 内部同样走这两条命令)。先预览:

npm run import:chat -- "E:\path\normalized.jsonl"

确认参与者、时间范围、数量和媒体情况后应用:

npm run import:chat -- "E:\path\normalized.jsonl" apply

导入前会自动备份当前私有数据,本地媒体按内容哈希复制到 persona/media。

导入会生成或更新:

data/history.rich.jsonl             完整聊天记录
data/history.jsonl                  记忆检索用文本记录
data/stickers.json                  表情资源及上下文
data/sticker-index.json             表情检索索引
data/habits.json                    行为统计
persona/media/                      私有媒体

处理流程:

聊天导出
  -> 来源适配器
  -> 标准对话事件 + persona/media
  -> 数据库 / 检索 / 画像 / Agent

模型提供方

聊天 Agent 使用 LLM_PROVIDER 选择模型服务:

LLM_PROVIDER=deepseek   # 默认,OpenAI-compatible Chat Completions
LLM_PROVIDER=openai     # 官方 OpenAI provider
LLM_PROVIDER=mimo       # 小米 Mimo OpenAI-compatible 接口

以 Mimo 为例:

LLM_PROVIDER=mimo
MIMO_API_KEY=你的 key
MIMO_BASE_URL=https://api.xiaomimimo.com/v1
MIMO_MODEL=mimo-v2.5

Agent 流程

用户消息
  -> Runner.run(PersonaAgent)
  -> 读取会话、样例、记忆、习惯、表情和反馈
  -> 判断消息类型、顺序、延迟和是否回复
  -> 校验回复计划并投递资源
  -> 写入 trace 和 notes

运行日志:

data/agent-notes.json     持续笔记和反馈记录
data/agent-trace.jsonl    每轮观察、计划、草稿和校验结果

iPhone 通知

iOS 主屏幕 Web App 需要 HTTPS 才能订阅系统通知。执行:

npm run setup:lan-ios
npm start

然后在同一局域网内:

  1. 打开 http://局域网IP:3000/chat-info.html,下载并安装本地 CA 证书。
  2. 在“设置 → 通用 → 关于本机 → 证书信任设置”中开启信任。
  3. 用 Safari 打开 HTTPS 地址,选择“添加到主屏幕”。
  4. 从主屏幕打开应用,在聊天信息页开启通知并发送测试通知。

主要文件

server.js                       Express API 和运行时入口
lib/agent/model.js              模型服务适配
lib/agent/runner.js             Agents SDK Runner 接入
lib/agent/tools.js              Agent 工具和回复计划校验
lib/agent/state.js              持续笔记和 trace 日志
lib/sticker-index.js            表情索引和检索
lib/prompt-loader.js            Prompt 模板加载
lib/memory.js                   历史记忆召回
lib/vector-memory-client.js     向量 Worker 调度和 FTS5 降级
lib/vector-memory-worker.js     本地向量生成和语义检索
lib/profile.js                  行为统计和反馈读取
lib/session.js                  当前会话持久化
lib/tts.js                      语音合成适配
skills/import-chat-history/     供 AI 工具使用的聊天导入 skill
scripts/                        维护、索引和监控脚本
public/                         聊天界面和静态资源
persona/                        人物资料和对话样例
prompts/                        Agent、turn、retry、proactive 和 tool 提示词

Prompt 目录

需要调整回复规则、主动联系或工具行为时,修改对应模板:

prompts/agent/persona-agent.md   Agent 主提示词
prompts/agent/turn-input.md      每轮输入包装
prompts/agent/retry-output.md    校验失败后的重试
prompts/agent/proactive-task.md  主动联系任务
prompts/tools/*.md               工具说明
Rendered by GitHub from the repository’s README. Scroll to read the full file.

First trending

Aug 2, 2026

first spotted on the list

Best rank

#29

highest position reached

Appearances

3

times on the trending list

Star velocity

0.15

stars per day since creation

Activity — last 60 days

daily counts, collected every 6 hours
  • Stars
  • Forks
  • Merged PRs
  • Issues
  • Closed issues

Collecting activity data since launch — check back in a few days.

Star history

total stars per snapshot
14151617AFan4724/clone-chat · Aug 2, 3 AM UTC: 15 starsAFan4724/clone-chat · Aug 2, 8 AM UTC: 16 starsAFan4724/clone-chat · Aug 2, 7 PM UTC: 16 stars3 AM11 AM7 PM

Rank history

position on trending · lower is better
#1#25#30#35#40#45#50#55Aug 2, 3 AM UTC: rank #53Aug 2, 8 AM UTC: rank #37Aug 2, 7 PM UTC: rank #293 AM11 AM7 PM

3D card for your website

Live HTML card with a pointer tilt. Paste the iframe on any website.

<iframe src="https://www.notionpulse.cc/embed/AFan4724/clone-chat" width="420" height="240" style="border:0;max-width:100%;background:transparent" loading="lazy" title="AFan4724/clone-chat — trending on Open Source Pulse"></iframe>

Stars badge

Show current stars in your README or profile. Auto-updates every 6 hours.

AFan4724/clone-chat stars badge
Markdown
[![AFan4724/clone-chat](https://www.notionpulse.cc/api/badge/AFan4724/clone-chat.svg)](https://www.notionpulse.cc/repo/AFan4724/clone-chat)
HTML
<a href="https://www.notionpulse.cc/repo/AFan4724/clone-chat"><img src="https://www.notionpulse.cc/api/badge/AFan4724/clone-chat.svg" alt="AFan4724/clone-chat stars badge" /></a>

Repository of the Day

#29 Repository of the Day

Repository of the Week

#29 Repository of the Week

Repository of the Month

#29 Repository of the Month