-
Notifications
You must be signed in to change notification settings - Fork 367
feat(export-import): add comprehensive config export and import system #280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Implement a complete configuration export and import system to enable seamless config migration across devices and platforms. Key Features: - Export configurations to .zip packages with metadata manifest - Import configurations with cross-platform path adaptation - Intelligent sensitive data sanitization (API keys redacted by default) - Three merge strategies: replace, merge, skip-existing - Automatic backup creation before import operations - Support for selective export/import scopes (all, workflows, mcp, settings) - Both Claude Code and Codex environment support Technical Implementation: - Use adm-zip library for better cross-platform zip compatibility - Comprehensive TypeScript type system for export-import operations - Full i18n support (zh-CN and en) across all user-facing messages - Cross-platform path adapter for Windows ↔ Unix conversions - Config merger with conflict detection and resolution - Package validator with version compatibility checks File Changes: - Add src/commands/export.ts and import.ts with CLI integration - Add src/utils/export-import/ module with 9 core utilities - Add src/types/export-import.ts for type definitions - Add comprehensive test suites for export-import functionality - Update i18n translations with new export/import namespaces - Integrate into main menu and CLI setup Breaking Changes: None Migration Guide: Added in .claude/plan/config-export-import.md
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||||||||
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||||||||||||
…ystem Add complete test coverage for the new export-import functionality: - collector.test.ts: Config collection with ZCF filtering (550 lines) - core.test.ts: Core utilities including checksum and zip operations (708 lines) - manifest.test.ts: Manifest validation and metadata handling (420 lines) - merger.test.ts: Intelligent config merging with conflict resolution (580 lines) - path-adapter.test.ts: Cross-platform path adaptation (485 lines) - validator.test.ts: Package validation and security checks (522 lines) Test coverage includes: - Unit tests for all core functions with extensive mocking - Edge case testing for error scenarios and boundary conditions - Cross-platform compatibility tests (Windows/macOS/Linux/Termux) - Security validation for sensitive data handling - Integration scenarios for complete workflows Follows ZCF testing standards with 80% coverage target and comprehensive test organization.
- Added tests for collecting skills, hooks, and prompts in collector.test.ts. - Expanded test cases for collectWorkflows and collectAllConfig functions. - Introduced tests for collectCustomFiles to validate handling of custom paths. - Enhanced getCollectionSummary tests to cover scenarios with only Claude Code or Codex files. - Improved core.test.ts with additional cases for adaptPlatformPaths, calculateChecksum, and file handling. - Added tests for createZipPackage and extractZipPackage to ensure proper zip file handling. - Implemented validation tests in manifest.test.ts for missing file types, invalid sizes, and checksum warnings. - Introduced validateFileIntegrity tests to check file integrity against checksums.
…nd improved validation
User description
#264 Implement a complete configuration export and import system to enable seamless config migration across devices and platforms.
Key Features:
Technical Implementation:
File Changes:
Breaking Changes: None
Migration Guide: Added in .claude/plan/config-export-import.md
Description
Brief description of changes
Type of Change
Testing
Checklist
PR Type
Enhancement, Tests
Description
Implement comprehensive configuration export and import system enabling seamless config migration across devices and platforms
Export functionality: Create
.zippackages with metadata manifest, support selective scopes (all, workflows, mcp, settings), and intelligent sensitive data sanitizationImport functionality: Extract and apply configurations with three merge strategies (replace, merge, skip-existing), automatic backup creation, and rollback on failure
Cross-platform support: Implement path adaptation for Windows ↔ Unix conversions, support both Claude Code and Codex environments
Core utilities: Use
adm-ziplibrary for ZIP operations, implement checksum verification, sensitive data detection/redaction, and conflict resolutionCLI integration: Add
exportandimportcommands with interactive prompts and direct execution modes, integrate into main menuInternationalization: Full i18n support (zh-CN and en) for all user-facing messages across export, import, CLI, and menu
Comprehensive testing: Add test suites for all modules covering validation, file collection, sanitization, manifest management, and command execution
Type safety: Define comprehensive TypeScript types for export/import operations, options, results, and validation
Diagram Walkthrough
File Walkthrough
16 files
import.ts
Import command implementation with interactive promptssrc/commands/import.ts
execution modes
strategy, sensitive data handling, and backup creation
error/warning messages
including rollback availability
merger.ts
Configuration merge strategies and conflict resolutionsrc/utils/export-import/merger.ts
replace,merge, andskip-existingfor configuration merging
with conflict detection
(use-existing, use-incoming, merge, rename)
importer.ts
Main import orchestration and execution logicsrc/utils/export-import/importer.ts
extraction, path adaptation, conflict detection, and configuration
application
core.ts
Core export-import utilities and zip operationssrc/utils/export-import/core.ts
adm-ziptokens
environment variable handling
collector.ts
Configuration file collection and filtering logicsrc/utils/export-import/collector.ts
based on code type and scope
and custom file selection
type
path-adapter.ts
Cross-platform path adaptation for importssrc/utils/export-import/path-adapter.ts
import
warnings
requiring manual review
validator.ts
Package validation and compatibility checkingsrc/utils/export-import/validator.ts
structure, file integrity via checksums
export.ts
Export command implementation with interactive UIsrc/commands/export.ts
inclusion, and output path selection
confirmation
information
cli-setup.ts
CLI integration for export and import commandssrc/cli-setup.ts
exportandimportcommands with CLI frameworkefor export) and positional arguments forimport
commands
examples
index.ts
Export-import module index and exportssrc/utils/export-import/index.ts
manifest, merger, path-adapter, sanitizer, and validator modules
index.ts
I18n namespace registration for export-importsrc/i18n/index.ts
exportandimportnamespaces to i18n configurationmessages
exporter.ts
Core export functionality with file collection and packagingsrc/utils/export-import/exporter.ts
executeExportfunction with progresscallbacks and multi-step export workflow
manifest, and packages into ZIP with verification
getExportSummaryfor preview andvalidateExportOptionsforinput validation
handling and progress reporting
export-import.ts
Type definitions for export-import functionalitysrc/types/export-import.ts
with 273 lines
CodeType,ExportScope,MergeStrategy,ExportOptions,ExportMetadata, andImportOptionsValidationError,ValidationResult),conflict handling, and progress tracking
and operation results
manifest.ts
Manifest creation and validation utilitiessrc/utils/export-import/manifest.ts
and analyzing export package metadata
createManifest,validateManifest, and file integrityvalidation functions
for display
warnings
sanitizer.ts
Sensitive data sanitization utilitiessrc/utils/export-import/sanitizer.ts
and tokens from configurations
detection
sanitized field detection
sanitized data presence
menu.ts
Menu integration for export-import commandssrc/commands/menu.ts
options 'E' and 'I'
waitForKeyPresshelper function for user interaction aftercommand execution
in both Claude Code and Codex menus
9 files
menu.json
Chinese language translations for export-import menusrc/i18n/locales/zh-CN/menu.json
descriptions
export/import functionality
import.json
Chinese translations for import functionalitysrc/i18n/locales/zh-CN/import.json
functionality
merge strategies
summary
import.json
English translations for import functionalitysrc/i18n/locales/en/import.json
merge strategies
summary
cli.json
Chinese CLI help text for export-importsrc/i18n/locales/zh-CN/cli.json
and help text
descriptions, and default behavior labels
functionality
cli.json
English CLI help text for export-importsrc/i18n/locales/en/cli.json
and help text
descriptions, and default behavior labels
functionality
menu.json
English menu translations for export-importsrc/i18n/locales/en/menu.json
functionality
detailed descriptions
export.json
Chinese translations for export functionalitysrc/i18n/locales/zh-CN/export.json
and output path configuration
completion notifications
metadata (description, tags)
export.json
English translations for export functionalitysrc/i18n/locales/en/export.json
and output path configuration
completion notifications
metadata (description, tags)
config-export-import.md
Add comprehensive config export-import feature planning document.claude/plan/config-export-import.md
965 lines of detailed specifications
.zipformat instead oftar.gzfor bettercross-platform compatibility
export implementation, import implementation, and integration
strategy, and documentation requirements
cross-platform path conversion, performance, security, and version
compatibility
6 files
export.test.ts
Export command test suite with interactive and direct modestests/commands/export.test.ts
exportCommandwith 365 lines coveringdirect export, interactive flow, and option normalization
user cancellation scenarios
→ 'claude-code', 'wf' → 'workflows')
translation handling
collector.test.ts
Configuration collector test suite with scope filteringtests/utils/export-import/collector.test.ts
Code and Codex config collection
validates collection summaries
directory while including custom workflows)
manifest.test.ts
Manifest creation and validation test suitetests/utils/export-import/manifest.test.ts
validation, and version comparison
platform/version compatibility checks
versioning
sanitizer.test.ts
Sensitive data sanitizer test suitetests/utils/export-import/sanitizer.test.ts
JSON and TOML content sanitization
batch processing
sanitization effectiveness
placeholders are properly handled
core.test.ts
Core utilities test suite with path and checksum handlingtests/utils/export-import/core.test.ts
calculation, platform detection, and path adaptation
sanitization with deep object traversal
mapping for configuration adaptation
substitution
exporter.test.ts
Exporter module test suitetests/utils/export-import/exporter.test.ts
validation, summary generation, and execution
validateExportOptionswith various option combinations and errorscenarios
getExportSummarywith file counting andexecuteExportwith progress callbacksduring export
2 files
pnpm-lock.yaml
Dependency updates for ZIP functionalitypnpm-lock.yaml
[email protected]dependency for cross-platform ZIP file creation@types/[email protected]type definitions for TypeScript supportpackage.json
Package dependencies for ZIP supportpackage.json
adm-zipto dependencies for ZIP file creation functionality@types/adm-zipto devDependencies for TypeScript type support1 files
pnpm-workspace.yaml
Workspace catalog updates for ZIP dependenciespnpm-workspace.yaml
adm-zip@^0.5.16to tooling catalog@types/adm-zip@^0.5.7to types catalog