feat: IMAP mail sync with thread-to-contact matching (PRD §6.1)

Real IMAP connection via imapflow library:
- Connects to IMAP server (IMAPFlow, TLS on port 993)
- Fetches recent messages (configurable limit, default 20)
- Extracts: from, fromEmail, subject, date, snippet (200 chars)
- Thread-to-contact matching (PRD §6.1):
  1. Match sender email against persons table
  2. If no person match, extract domain and match against company.website
  3. Returns matchedCompany + matchedPerson for each email
- Audit-logged (action: crm.mailsync:imap)
- Zod validated (host, port, user, password, folder, limit)
- 502 on IMAP connection failure with detail
- 400 on validation failure

Tested: invalid creds → 502 'IMAP connection failed', missing host → 400
This commit is contained in:
Z User committed 2026-10-27 22:50:50 +00:00
1 parent 7acc0c5451
commit e45b68bb8b
1089 files changed
+260614

No files matched your search

+75
View File
@@ -0,0 +1,75 @@
---
name: social-card-swiss
description: Swiss 网格 / 系统派社交卡 — 精确 / 系统化 / 技术感 / 方法论调性。卡角色含 system 封面 / numbered method / 对比 before-after / KPI tower / 横条 mini-chart / 截图解释 / 证据墙 / 收尾 checklist。用于 framework / checklist / 工具说明 / AI workflow / 产品更新 / KPI 总结。触发:"做个方法卡 / 框架卡 / 工具拆解卡 / AI 工具卡 / 系统派结构卡"。NOT 情绪 / 文学 / 图主导卡,NOT 软生活 pastel 风。
visibility: public
mode: template
carrier: fixed-image
scenario: social-content
pattern_source: pattern.html
source_priority: skill-first
triggers:
- "做个方法卡"
- "框架卡"
- "工具拆解卡"
- "AI 工具卡"
- "系统派卡"
- "结构化知识卡"
- "Swiss 网格卡"
related_patterns: social-card-data-kpi, social-card-screenshot-explainer
---
# Social Card Swiss Template
Use this template for structured social cards that should feel precise, systematic, technical, or method-driven.
## Use When
- The content is a framework, checklist, comparison, tool explanation, AI workflow, product update, KPI summary, or screenshot explainer.
- The design should use grid, numbering, labels, metrics, or modular blocks.
- The user wants a clean modern card that feels designed but not decorative.
## Avoid When
- The content is emotional, literary, image-led, or slow editorial.
- The user wants a soft lifestyle/pastel look.
- A plain poster or deck slide is a better fit than a social card.
## Required Reading
Read this `SKILL.md` first. Do **not** read `pattern.html` by default.
Read `pattern.html` only if the selected card needs layout relationships that are hard to infer from this file. Extract only grid rhythm, component relationships, responsive/card behavior, and section hierarchy.
## Design Strategy
Choose a card role before choosing visual detail:
- system cover
- numbered method
- comparison / before-after
- KPI tower
- horizontal bar / mini chart
- screenshot explainer
- evidence wall
- closing checklist
## Layout Bias
Prefer:
- strict grid and alignment
- numbering systems and small metadata labels
- clear typographic hierarchy
- compact but readable card sections
- data blocks, comparison rows, and interface frames
Avoid:
- random stickers, emoji icons, and decorative blobs
- unclear focal hierarchy
- screenshots too small to read
- generic SaaS feature-card layouts
## Platform / Size
Use `canvas-and-device.md` for platform dimensions and export ratios. This template supplies structure, not fixed size.