iMessage & Signal Analyzer
Analyze iMessage (macOS) and Signal conversations to produce relationship reports.
Prerequisites
macOS (iMessage)
iMessage data is stored locally on macOS. Depending on your security settings, you may need to grant Full Disk Access:
Option 1: Run the script directly with Python (no special permissions needed if you have read access to ~/Library/Messages/chat.db)
Option 2: If you get a permission error, grant Full Disk Access:
- - Open System Settings → Privacy & Security → Full Disk Access
- Click + and add Python or your terminal app
Linux / Windows (Signal only)
- - iMessage is not available on Linux/Windows
- Signal analysis works via exported JSON
Signal (All Platforms)
- - Install signal-cli:
brew install signal-cli (macOS) or see https://github.com/AsamK/signal-cli - Link your device:
signal-cli link and scan QR code - Export messages: INLINECODE3
Usage
iMessage Analysis
CODEBLOCK0
Examples:
CODEBLOCK1
Signal Analysis
First, export your Signal data (one-time):
CODEBLOCK2
Then analyze:
CODEBLOCK3
Examples:
CODEBLOCK4
Finding a Contact's Number
iMessage
If you have a name but not a number:
DB=$(ls ~/Library/Application\ Support/AddressBook/Sources/*/AddressBook-v22.abcddb 2>/dev/null | head -1)
sqlite3 "$DB" "SELECT ZFIRSTNAME, ZLASTNAME FROM ZABCDRECORD WHERE ZFIRSTNAME LIKE '%Name%';"
If AddressBook returns no results, ask the user for the number.
Signal
Signal exports include phone numbers in the JSON. Search by name or number.
Key Data Caveats
iMessage
- - Your sent messages may only exist from the current device's setup date — older sent messages are lost when switching devices. This skews initiation stats.
- Binary messages (attributedBody) are partially decoded — some formatting artifacts like
+@ prefixes may appear in samples; these are normal. - Multiple handles: One contact may have 2–3 duplicate handles (iMessage + SMS + RCS). The script aggregates them automatically.
Signal
- - Export required: You must export Signal data first using INLINECODE5
- Media: Exported JSON contains message text; media (images, files) is not included
- Reactions: Emoji reactions are included as separate message entries
Analysis Output
The script produces:
- - Total message count (you vs. them)
- Date range
- Messages per year with volume bar
- Conversation initiation breakdown (new convo = gap > 4 hours)
- Notable silences (>30 days)
- Sample messages by year
- Most recent 10 messages
Interpreting Results
After running the script, synthesize findings conversationally:
- - Volume patterns: When was the friendship most active? Any notable surges or drops?
- Initiation skew: Who reaches out first? (Note: your sent messages may be missing from old periods)
- Gaps: Were long silences mutual drift or explainable (device switch, platform change, life event)?
- Tone/content: What do the sample messages reveal about the relationship's energy?
- Context from user: Always ask the user to fill in context gaps
Present the analysis conversationally, not just as raw numbers. Offer a genuine take on the relationship dynamic.
iMessage 与 Signal 分析器
分析 iMessage(macOS)和 Signal 对话,生成关系报告。
前提条件
macOS(iMessage)
iMessage 数据本地存储在 macOS 上。根据您的安全设置,您可能需要授予完全磁盘访问权限:
选项 1: 直接使用 Python 运行脚本(如果您对 ~/Library/Messages/chat.db 具有读取权限,则无需特殊权限)
选项 2: 如果遇到权限错误,请授予完全磁盘访问权限:
- - 打开 系统设置 → 隐私与安全性 → 完全磁盘访问权限
- 点击 + 并添加 Python 或您的终端应用
Linux / Windows(仅限 Signal)
- - iMessage 在 Linux/Windows 上不可用
- Signal 分析通过导出的 JSON 进行
Signal(所有平台)
- - 安装 signal-cli:brew install signal-cli(macOS)或参见 https://github.com/AsamK/signal-cli
- 关联您的设备:signal-cli link 并扫描二维码
- 导出消息:signal-cli export --output ~/signal_export.json
使用方法
iMessage 分析
bash
python3 skills/message-analyzer/scripts/analyze.py imessage <电话号码或句柄>
示例:
bash
python3 skills/message-analyzer/scripts/analyze.py imessage +15551234567
python3 skills/message-analyzer/scripts/analyze.py imessage +15551234567 --limit 500
Signal 分析
首先,导出您的 Signal 数据(一次性操作):
bash
signal-cli export --output ~/signal_export.json
然后进行分析:
bash
python3 skills/message-analyzer/scripts/analyze.py signal ~/signal_export.json <电话号码或姓名>
示例:
bash
python3 skills/message-analyzer/scripts/analyze.py signal ~/signal_export.json +15551234567
python3 skills/message-analyzer/scripts/analyze.py signal ~/signal_export.json +15559876543
查找联系人的号码
iMessage
如果您只有姓名而没有号码:
bash
DB=$(ls ~/Library/Application\ Support/AddressBook/Sources/*/AddressBook-v22.abcddb 2>/dev/null | head -1)
sqlite3 $DB SELECT ZFIRSTNAME, ZLASTNAME FROM ZABCDRECORD WHERE ZFIRSTNAME LIKE %姓名%;
如果通讯录没有返回结果,请向用户询问号码。
Signal
Signal 导出的 JSON 中包含电话号码。可按姓名或号码搜索。
关键数据注意事项
iMessage
- - 您发送的消息 可能仅存在于当前设备的设置日期之后——切换设备时,较早的已发送消息会丢失。这会影响发起统计数据的准确性。
- 二进制消息(attributedBody)会被部分解码——样本中可能出现一些格式标记(如 +@ 前缀);这属于正常现象。
- 多个句柄:一个联系人可能有 2–3 个重复句柄(iMessage + SMS + RCS)。脚本会自动合并它们。
Signal
- - 需要导出:您必须首先使用 signal-cli export 导出 Signal 数据
- 媒体:导出的 JSON 包含消息文本;媒体(图片、文件)不包含在内
- 反应:表情反应会作为单独的消息条目包含在内
分析输出
脚本会生成:
- - 总消息数(您 vs. 对方)
- 日期范围
- 每年消息数及数量柱状图
- 对话发起情况分析(新对话 = 间隔超过 4 小时)
- 显著沉默期(超过 30 天)
- 按年份的消息样本
- 最近 10 条消息
结果解读
运行脚本后,以对话方式综合发现:
- - 数量模式:友谊最活跃的时期是什么时候?是否有显著的增长或下降?
- 发起倾向:谁更常主动联系?(注意:您较早时期的已发送消息可能缺失)
- 间隔期:长时间的沉默是双方自然疏远,还是可以解释的原因(设备更换、平台变更、生活事件)?
- 语气/内容:样本消息揭示了关系的哪些能量特征?
- 用户背景:始终请用户补充背景信息
以对话方式呈现分析结果,而非仅提供原始数据。对关系动态提出真实的见解。