Skip to content

feat: add conversation import — 5-format normalizer pipeline#12

Merged
win4r merged 1 commit intowin4r:mainfrom
AliceLJY:feat/conversation-import
Apr 8, 2026
Merged

feat: add conversation import — 5-format normalizer pipeline#12
win4r merged 1 commit intowin4r:mainfrom
AliceLJY:feat/conversation-import

Conversation

@AliceLJY
Copy link
Copy Markdown
Collaborator

@AliceLJY AliceLJY commented Apr 8, 2026

Summary

  • Multi-format conversation normalization for importing chat history from 5 platforms
  • Auto-detects format from content structure — zero manual config needed
  • Framework-agnostic ingest via callback pattern — not coupled to any specific pipeline

Supported formats

Format Detection Notes
Claude Code JSONL type: "human"/"assistant" .claude/projects/ directory
Claude.ai JSON chat_conversations wrapper Official export format
ChatGPT JSON mapping tree structure conversations.json from data export
Slack JSON ts + text fields Channel export format
Plaintext User:/Human:/Assistant:/AI: prefixes Universal fallback

Changes

File Change
packages/core/src/conversation-importer.ts New — 5 normalizers + format detection + batch ingest
packages/core/src/index.ts Export new functions and types
packages/core/test/conversation-importer.test.mjs 26 tests

Integration example

import { detectFormat, normalizeConversation, ingestNormalizedMessages } from "@anthropic/memory-core";

const content = readFileSync("conversations.json", "utf-8");
const format = detectFormat(content);
const messages = normalizeConversation(content, format);

await ingestNormalizedMessages(messages, "project:myapp", async (text, scope, role) => {
  await pipeline.ingest({ text, scope, category: "events", importance: 0.5, source: "conversation_import" });
  return "stored";
});

Test plan

  • 26 unit tests pass (node --test packages/core/test/conversation-importer.test.mjs)
  • All 5 formats + auto-detection + edge cases covered
  • No changes to existing files except index.ts exports

🤖 Generated with Claude Code

Multi-format conversation normalization for importing chat history
from Claude Code, Claude.ai, ChatGPT, Slack, and plaintext.

- Auto-detects format from content structure
- Claude Code JSONL: parses type/message/content fields
- Claude.ai JSON: handles chat_conversations wrapper + array
- ChatGPT: rebuilds message order from mapping tree via BFS
- Slack: maps bot_id to assistant role, converts ts to ISO
- Plaintext: splits on User:/Human:/Assistant:/AI:/System: prefixes
- Framework-agnostic ingest: accepts callback, not coupled to any pipeline
- 26 tests (node:test + jiti)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@win4r win4r merged commit f2fd860 into win4r:main Apr 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants