Skip to content

Migrating from Config v2 to v3

Config v3 splits backend settings, provider declarations, credentials, permissions, and TUI state across files with separate purposes under the unified XDG / HYA_HOME layout. The session database continues to use SQLite format v2. If Hya finds a legacy config.yaml beside a missing default config.toml, startup fails fast and directs you to run hya-migration run so it cannot silently boot with defaults in place of your existing settings.

The standalone hya-migration binary (shipped alongside bin/hya) performs an atomic offline upgrade from Config v2 (and seamlessly chains v1 → v2 → v3 in a single run when older v1 artifacts are present) with a SHA-256 backup snapshot and byte-exact rollback.

1. Stop Hya and inspect (check & --dry-run)

Stop the backend with hya server stop (using your --db override if applicable) and close TUI clients before migrating. Then run the read-only preflight and dry run:

Terminal window
hya-migration check
hya-migration run --dry-run

Add --json for machine-readable reports. check inspects the resolved XDG / HYA_HOME roots without modifying any file and reports needs_migration alongside per-artifact statuses (db, config, tui, bundles, and v3_files). You can override individual target paths with --config, --auth-dir, --auth-json, --tui-toml, --tui-json, --tui-state, --model-cache-db, --db, --registry, and --bundles-dir.

2. Run the atomic migration (hya-migration run)

Terminal window
hya-migration run
# Or choose an explicit backup directory:
hya-migration run --backup-dir ~/.config/hya/backups/pre-v3

Before writing or removing any file, hya-migration run snapshots every affected source file (recording SHA-256 digests and Unix permission bits) and records newly created targets in <backup-dir>/manifest.json. Each destination is written atomically and validated against Hya’s v3 config, models, permissions, and credential loaders before legacy files are removed. If any apply step fails, hya-migration automatically restores from the backup.

Artifact mapping

Paths below are relative to the resolved Hya roots (HYA_HOME/{config,data,state,cache} or XDG defaults; see Environment Variables & File Paths). Existing destination values take precedence on collisions.

v2 artifact v3 destination and migration behavior
Config config.yaml (schema_version: 2) Converted to config.toml (schema_version = 3, #:schema https://hya.ed-aisys.com/schema/v3/config.json) plus models.toml (schema_version = 1, #:schema https://hya.ed-aisys.com/schema/v3/models.json) for [providers.*]. Routing defaults, roles/categories, agents, mcp, plugins, tools, context, provider_retry, and catalog_scopes remain in config.toml. Legacy config.yaml is removed after verification.
Config config.yaml permission: Converted to the config-root permissions.toml (schema version 1), including the fallback mode and user-wide rule buckets.
Config bundles/<percent-encoded-id>/config.yml Percent-decoded and merged into inline [bundles."<ns>/<name>"] tables in config.toml (with bundle-owned agent pins consolidated). Legacy .yml files and empty percent-encoded directories are removed after verification.
Config auth/<provider>.yaml Merged into data-root auth.json written atomically with Unix mode 0600 (and 0700 on newly created parent directories). Plaintext config-dir auth/*.yaml files are removed after read-back verification.
Config tui.json + tui.toml Declarative user preferences (theme, vim, notifications, permissionMode → permission_mode, keybindings → [keys]) migrate into config-root tui.toml (version = 2, #:schema https://hya.ed-aisys.com/schema/v3/tui.json). Machine state (paneLayout, seenNotices, extensionEnabled, extensionTrusted, extensionSandbox) migrates to state-root tui-state.json. Legacy tui.json is removed after verification. If you set a custom HYA_TUI_CONFIG env override, clear it or point HYA_TUI_STATE at the migrated state file.
Cache model_cache.db (+ -wal/-shm) Backed up and removed; Hya rebuilds model metadata into readable JSON caches (models-registry.json and models-discovered/<provider>.json).
State sessions.db (format v2) Kept in place (upgraded from v1 automatically if still v1). Legacy saved_permission grants are imported into permissions.toml.

Permissions and remembered grants

The migrator puts v2 permission: rules in allow, ask, or deny according to their old decision. For example, a command regex ^git status$ becomes Bash(re:^git status$). A legacy danger mode becomes bypass. Tool and MCP selectors become corresponding tool-name and MCP rules when representable.

Remembered grants from sessions.db go in the global allow list or in [projects."<canonical-path>"].allow, using the recorded Project’s roots. Migration leaves trust undecided for newly imported roots. Review reported skips for legacy rules or grants that cannot be converted safely. Existing permissions.toml settings and trust decisions take precedence, and identical rules are deduplicated.

For example, a user-wide command rule and a remembered Project read could produce the following file.

#:schema https://hya.ed-aisys.com/schema/v3/permissions.json
schema_version = 1
default_mode = "default"
allow = ["Bash(re:^git status$)"]
[projects."/home/alex/src/app"]
allow = ["Read(/home/alex/src/app/README.md)"]

The backup manifest tracks permissions.toml. Rollback restores its original bytes and mode if it existed, or removes the newly created file. See the permissions guide to review rules and record trust after migration.

Example resulting models.toml

#:schema https://hya.ed-aisys.com/schema/v3/models.json
schema_version = 1
[providers.gateway]
kind = "openai"
base_url = "https://gateway.example/v1"
api_key = "{env:GATEWAY_API_KEY}"
models = ["my-model"]

In config.toml, schema_version = 3 and default_model = "gateway/my-model" reference that provider. See the Configuration Reference for the complete schema dictionary.

3. Verify the migrated installation

Terminal window
hya-migration check
hya config paths --json
hya config validate --json
hya config show --effective
hya permissions list --json
hya trust list --json

Confirm hya-migration check reports everything up to date, hya config validate --json returns {"ok":true}, and hya config show --effective matches your expected settings (secrets are redacted automatically). Start Hya and open /model to verify your live catalog.

4. Roll back byte-for-byte (hya-migration rollback)

To restore every original v2 file (including original Unix permissions) and remove every newly created v3 file:

Terminal window
hya-migration rollback --backup <backup-dir>

rollback verifies the SHA-256 digest of every snapshot recorded in manifest.json before modifying any file on disk and refuses to run if any backup file is missing or tampered with.