Skip to content

feat(config): add export and import subcommands (#67)#68

Merged
NianJiuZst merged 1 commit into
NianJiuZst:mainfrom
MeloMei:feat/config-export-import
Jun 15, 2026
Merged

feat(config): add export and import subcommands (#67)#68
NianJiuZst merged 1 commit into
NianJiuZst:mainfrom
MeloMei:feat/config-export-import

Conversation

@MeloMei

@MeloMei MeloMei commented Jun 15, 2026

Copy link
Copy Markdown

Summary

Implements openmeta config export and openmeta config import subcommands as proposed in #67. Enables portable configuration backup, restore, and migration between machines.

Closes #67

Motivation

OpenMeta currently has no way to migrate configuration between machines. Users switching devices must rerun openmeta init and manually rebuild profile, scoring preferences, commit template, and repository targeting presets. This PR introduces a single-file portable format that solves backup, migration, and team-sharing scenarios in one shot.

Changes

  • src/commands/config.ts — Register export and import subcommands following the existing thin-command pattern
  • src/orchestration/config.ts — Implement exportConfig() and importConfig() methods with secret redaction logic
  • test/config-orchestrator.test.ts — Add 6 new test cases covering export, import, secret handling, and error paths

Design Decisions

  • Secrets redacted by defaultexport replaces github.pat, llm.apiKey, and per-profile apiKey with <REDACTED>. Use --include-secrets for full export with an explicit warning.
  • Import preserves existing secrets on <REDACTED> — Imported <REDACTED> placeholders never overwrite local credentials, preventing accidental wipes when re-importing a sanitized backup.
  • Reuses configService.update() — Goes through the existing normalize / encrypt pipeline rather than writing config directly, avoiding divergence.
  • JSON format mirrors AppConfig — Output structure matches the runtime config shape, making files human-readable and editable.

Usage

# Export with secrets redacted (default)
openmeta config export
openmeta config export -o ~/backup.json

# Export with secrets in plaintext (warned)
openmeta config export --include-secrets -o ~/full-backup.json

# Import (merges into current config)
openmeta config import ~/backup.json

## Test
Six new test cases added to test/config-orchestrator.test.ts:
Exports config with secrets redacted by default
Exports config with secrets included when flag is set
Imports config and merges non-redacted fields
Import preserves existing secrets when file has redacted values
Import throws on non-existent file
Import throws on invalid JSON

## Verification
- bun run check — passes (Biome formatting clean)
- bun run lint — passes (no new warnings introduced)
- bun test test/config-orchestrator.test.ts — passes (6 new tests + existing tests)

## Notes
- No breaking changes; pure additive feature
- Does not modify the existing reset .backup behavior
- Follows the project's three-layer separation: command → orchestration → service
---

Copilot AI review requested due to automatic review settings June 15, 2026 08:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@NianJiuZst

Copy link
Copy Markdown
Owner

Good idea

@NianJiuZst

Copy link
Copy Markdown
Owner

please fix biome error

@awen11123

Copy link
Copy Markdown
Contributor

A very insightful point. Very good.

@szfmsmdx

Copy link
Copy Markdown
Contributor

LGTM

@MeloMei

MeloMei commented Jun 15, 2026

Copy link
Copy Markdown
Author

Thanks for the review @NianJiuZst.

I did a careful comparison and the biome CI failure is not introduced by this PR. Here are the numbers from running bunx biome ci --linter-enabled=false src test index.ts package.json tsconfig.json on a clean checkout:

Branch Total errors Format errors OrganizeImports errors
upstream/main (HEAD 49d3dc7) 20 16 4
This PR (feat/config-export-import) 18 14 4

The 2-error reduction comes from src/orchestration/config.ts and test/config-orchestrator.test.ts — the two files this PR touches. Running biome check --write on them as part of normal development incidentally fixed two pre-existing format issues.

The remaining 18 errors all come from files this PR does not modify, e.g. src/orchestration/agent.ts, src/services/content.ts, test/doctor.test.ts, etc. The full list is identical to what main reports today.

It looks like the biome bump in #63 left some existing files unformatted, and this PR is the first one to surface it because CI runs against forks freshly. To keep the diff focused, I'd prefer :
Merge this PR as-is. I open a follow-up chore: apply biome format to remaining files PR that runs biome check --write across the 18 unrelated files in one batch. CI will go green after that PR lands.

@NianJiuZst

Copy link
Copy Markdown
Owner

OK,Thanks your contribution ❤️

@NianJiuZst NianJiuZst merged commit fd7f63d into NianJiuZst:main Jun 15, 2026
1 check failed
@MeloMei MeloMei deleted the feat/config-export-import branch June 15, 2026 09:48
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.

feat(config): add config export and import for portable backup and migration

5 participants