$ show nicepkg/ctxport
CtxPort is a browser extension and companion documentation website that lets users copy AI conversations (from ChatGPT, Claude, Gemini, DeepSeek, Grok, Doubao, GitHub) as structured Markdown Context Bundles. It solves 'context rot' by enabling portable, lossless migration of conversations between AI tools without uploading data to third parties. The architecture is a modern monorepo using pnpm workspaces and Turborepo, with separate packages for schema validation (Zod), markdown serialization, plugin-based extraction, and shared UI components. The browser extension (Manifest V3, WXT, React 19, Tailwind CSS 4) injects copy buttons and sidebar list icons into supported platforms, while the documentation website (Next.js + Nextra) provides multilingual (en/zh) user guides and feature descriptions. All processing is client-side; no data is uploaded. The codebase demonstrates strong engineering practices including a plugin system for extensibility, a strategy pattern for content flatteners, clean separation of concerns, and comprehensive CI/CD pipelines. Some fragility exists in DOM selectors and platform APIs, but the architecture is well-structured for adaptation.
The LLM identified 5 files worth highlighting for reuse:
Central registry for platform-specific plugins. Implements a clean plugin discovery and lifecycle management system: plugins register themselves with URL patterns, extract/fetchById methods, and optional injectors. The registry also derives host permissions statically, enabling minimal declaration for new platforms. This pattern could be extracted into any project that needs to support multiple external services with varying DOM/API extraction logic.
Generic chat UI injector using MutationObserver. Designed as a factory that accepts a config (container selector, button position, theme, etc.) and returns an injector with start/cleanup lifecycle. Handles SPA navigation, shadow DOM vs. native DOM injection, and debounced observation. Reusable across any web app that needs to inject contextual UI elements into dynamic pages (e.g., chat interfaces, ticket systems, CRUD apps).
Defines a Flattener interface and registry for converting heterogeneous chat message sub-components (text, code, thoughts, tool responses, multimodal content) into a unified Markdown string. Each flattener implements a strategy for a specific content type. The registry selects the appropriate flattener at runtime. This pattern is independent of ChatGPT and could be reused for any system that needs to normalize diverse structured content into a single output format.
Universal data model for AI conversation exports. Defines ContentBundle, ContentNode, Participant, and related types with Zod schemas for runtime validation. Includes metadata like platform, source URL, timestamps, token count. This schema is the contract between extraction plugins and markdown serializers, and could be adopted by any tool that needs a standardized representation of chat conversations for portability.
Lightweight internationalization framework with TypeScript-first design. Provides a core function to build a typed i18n instance from locale objects, a React context provider, and useI18n hook. Supports runtime locale switching, nested keys, and compile-time safety via type inference from locales. Could be extracted as a standalone i18n library for React projects, requiring minimal adaptation.