CLI Architecture Refactoring & UX Normalization (WIP v0.7.2)#44
Merged
LittleCoinCoin merged 164 commits intoCrackingShells:devfrom Feb 4, 2026
Merged
CLI Architecture Refactoring & UX Normalization (WIP v0.7.2)#44LittleCoinCoin merged 164 commits intoCrackingShells:devfrom
LittleCoinCoin merged 164 commits intoCrackingShells:devfrom
Conversation
This pulls the most recent org's wide coding instructions.
Establish hatch/cli/ directory with package initialization as the foundation for handler-based CLI architecture refactoring. Deliverables: - hatch/cli/__init__.py: Package init with main() export - hatch/cli/__main__.py: Module entry point for python -m hatch.cli Both files delegate to cli_hatch.main() for backward compatibility. Full entry point migration planned for Task M1.7.
Add cli_test_utils.py with helper functions to simplify test setup for CLI handlers during the refactoring process. Utilities provided: - create_mcp_configure_args(): Build Namespace for configure handler - create_mock_env_manager(): Mock HatchEnvironmentManager - create_mock_mcp_manager(): Mock MCPHostConfigurationManager These reduce boilerplate and ensure consistent test patterns across the CLI test suite as handlers are extracted to new modules.
Create hatch/cli/cli_utils.py with consolidated utility functions: - EXIT_SUCCESS, EXIT_ERROR constants for consistent return values - get_hatch_version() from importlib.metadata - request_confirmation() for user interaction - parse_env_vars(), parse_header(), parse_input() for CLI parsing - parse_host_list() consolidated (resolved duplication, returns List[str]) - get_package_mcp_server_config() for MCP package configuration Update cli_hatch.py to import from cli_utils and remove original definitions. Update cli/__init__.py exports. This consolidation reduces cli_hatch.py by ~150 LOC and resolves the parse_host_list duplication (was at lines 47 and 1032).
Update test imports and mock paths for extracted utilities: test_cli_version.py: - Import get_hatch_version from hatch.cli.cli_utils - Update mock path hatch.cli_hatch.version -> hatch.cli.cli_utils.version test_mcp_cli_package_management.py: - Import utilities from hatch.cli.cli_utils - Update mock path for MCPHostRegistry - Update parse_host_list tests for List[str] return type (was List[MCPHostType]) - Update mock path for Path.exists to hatch.cli.cli_utils.Path.exists
test(cli): update test_mcp_cli_package_management mock paths for new architecture test(cli): update test_mcp_cli_discovery_listing mock paths for new architecture test(cli): update test_mcp_cli_direct_management for new architecture - Update import paths from hatch.cli_hatch to hatch.cli modules - Fix handler calls to use args: Namespace signature instead of individual parameters - Add env_manager attribute to test Namespace objects where required - Fix attribute names (host_name vs host) for remove host handlers - Update mock paths to new module locations - All 21 tests now passing test(cli): update test_mcp_cli_backup_management for new architecture M1.8.1: Update backup management tests for handler-based architecture Changes: - Update mock paths from hatch.cli_hatch to hatch.cli.cli_mcp - Update argument parsing tests to use assert_called_once() - Patch MCPHostConfigBackupManager at source module level - Patch request_confirmation at hatch.cli.cli_utils - Import MCPHostConfigBackupManager at module level for patching All 14 backup management tests now pass. test(cli): update remaining test files for handler-based architecture M1.8.1: Complete test updates for new CLI architecture Files updated: - tests/cli_test_utils.py: Enhanced helper functions for Namespace creation - tests/test_mcp_cli_host_config_integration.py: Updated mock paths and Namespace calls - tests/test_mcp_cli_partial_updates.py: Updated for new handler signatures - tests/test_mcp_cli_all_host_specific_args.py: Updated mock paths - tests/regression/test_mcp_kiro_cli_integration.py: Updated for cli_mcp module All 310 CLI tests now pass.
M1.8.3: Add comprehensive docstrings to all CLI modules Updated docstrings in: - hatch/cli/__init__.py: Architecture overview and entry points - hatch/cli/__main__.py: Command structure and routing details - hatch/cli/cli_utils.py: Constants and function documentation - hatch/cli/cli_mcp.py: Supported hosts and command groups - hatch/cli/cli_env.py: Environment management commands - hatch/cli/cli_package.py: Package workflow documentation - hatch/cli/cli_system.py: Package creation and validation - hatch/cli_hatch.py: Migration notes and exported symbols All docstrings include examples and handler signature documentation.
Update documentation references after CLI refactoring from monolithic cli_hatch.py to handler-based architecture in hatch/cli/ package. Updated files: - docs/articles/api/cli.md: Expand API docs for new CLI package structure - docs/articles/users/CLIReference.md: Update intro reference - docs/articles/devs/implementation_guides/mcp_host_configuration_extension.md: Fix CLI integration guidance - docs/articles/devs/architecture/mcp_host_configuration.md: Update CLI references - docs/resources/diagrams/architecture.puml: Update CLI layer to show modular structure Added deprecation analysis report documenting all changes.
Add DeprecationWarning when importing from hatch.cli_hatch module. Update hatch/__init__.py to import main from hatch.cli instead of the deprecated cli_hatch shim to avoid triggering warnings internally. Changes: - hatch/cli_hatch.py: Add deprecation warning (removal planned for v0.9.0) - hatch/__init__.py: Import main from hatch.cli - docs/articles/api/index.md: Update example imports
Update tutorial 04-04 with correct command syntax for viewing environment deployments and host configurations. Changes: - Replace non-existent commands with hatch env list hosts/servers - Update verification commands to use hatch mcp show hosts/servers - Add filtering examples with regex patterns Fixes command syntax errors identified in R16 v1 section 5.3. All commands verified against implementation (R17).
Update tutorial 04-05 checkpoint with correct verification commands. Changes: - Replace old command syntax with current commands - Update practical diagnostics with env list hosts/servers - Update environment issues section with env show command Fixes 3 command syntax errors identified in R16 v1 section 5.4. All outputs verified against R17.
Update MCP Host Configuration guide with current command syntax. Changes: - Add "Viewing Host Configurations" section with list/show commands - Document table views vs detailed views - Add filtering examples with regex patterns Addresses command documentation gaps identified in R16 v1 section 4. All commands verified against implementation (R17).
Update environment commands in CLI Reference with current implementation. Changes: - Update hatch env list output format (verified from cli_env.py:217-247) - Add hatch env list hosts documentation - Add hatch env list servers documentation - Add hatch env show documentation with detailed output format All outputs verified against implementation (R17 sections 3.1-3.4).
Update MCP commands in CLI Reference with current implementation. Changes: - Update hatch mcp discover hosts output - Add hatch mcp list hosts documentation - Add hatch mcp list servers documentation - Add hatch mcp show hosts documentation - Add hatch mcp show servers documentation All outputs verified against implementation (R17 sections 4.1-4.5). Addresses new commands per R10 specification.
Mark hatch package list as deprecated and update filter documentation. Changes: - Add deprecation warning to package list command - Document migration path to env list and env show - Add example output showing deprecation warning Deprecation verified from cli_package.py:109-150 (R17 section 5.1). Filter behavior documented per R16 v1 section 3.12.
Update hatch env list output format in tutorial 01-02. Changes: - Update output to match current implementation - Remove incorrect Python Environment Manager section - Add key details explaining output format Output verified against cli_env.py:217-247 (R17 section 3.1).
Update tutorial 01-03 with correct output formats and add env show example. Changes: - Update hatch env list output after package installation - Add hatch env show example for detailed package view - Replace deprecated package list command Outputs verified against R17 sections 3.1 and 3.4.
Add quick reference section to Getting Started guide. Changes: - Add "Quick Reference: Viewing Commands" section - Organize commands by category (Environment, MCP, Discovery) - Include brief descriptions for each command - Add filtering examples with regex patterns Addresses R16 v1 section 6.1 enhancement.
Remove broken link to non-existent test_architecture.md file. Changes: - Remove reference to test_architecture.md that doesn't exist - Keep test architecture table intact Fixes mkdocs build error in strict mode.
Update tutorial to match current CLI implementation: - Replace old multi-line format with table format (Name/Python/Packages) - Remove non-existent Python Environment Manager section - Add output examples for mutation commands (env use, env remove) - Correct Step 4 description to accurately reflect list command behavior - Add guidance to use 'hatch env show' for detailed information Fixes critical documentation accuracy issue where tutorial showed completely different output than actual implementation, causing user confusion. Related: audit report 20-tutorial_environments_audit_v0.md
Update validation success output example to match actual ResultReporter format with [SUCCESS] header and [VALIDATED] consequence line. Fixes output format discrepancy identified in audit report 22-tutorial_author_package_audit_v0.md.
Critical fixes: - Remove invalid 'hatch package sync' without package name - Fix 'hatch mcp backup list' to use positional argument - Fix 'hatch mcp backup restore' to use --backup-file flag Minor fixes: - Update discover hosts output to show table format - Update package add output to show ResultReporter format - Update mcp sync output to show consequence types Fixes command syntax errors and output format discrepancies identified in audit report 24-tutorial_mcp_host_config_audit_v0.md.
- Add cli_architecture.md documenting modular CLI design - Add adding_cli_commands.md with step-by-step implementation guide - Update architecture index to link CLI architecture - Update implementation guides index to link CLI commands guide - Add CLI components section to component_architecture.md All content based on actual codebase analysis (no assumptions). Addresses critical gaps identified in gap analysis report 26.
- Create docs/articles/api/cli/ directory with individual module docs - Add index.md (overview), main.md, utils.md, env.md, package.md, mcp.md, system.md - Update mkdocs.yml navigation with CLI Package section - Update API index with detailed module organization - Remove old monolithic cli.md file - Update references to cli_hatch.py in developer and user docs - Add CLI Architecture and Adding CLI Commands to mkdocs navigation Reflects CLI refactoring from monolithic to modular structure. All API docs use mkdocstrings for auto-generation from docstrings.
- Add return type annotation to generate_metadata_json() in template_generator.py - Add return type annotation to main() in cli/__main__.py - Add comment to print-site plugin position in mkdocs.yml Resolves griffe warnings during documentation build. Note: print-site plugin warning is a false positive - plugin is correctly positioned last.
Remove `cli.md`
cracking-shells-semantic-release bot
pushed a commit
that referenced
this pull request
Feb 4, 2026
## 0.8.0-dev.1 (2026-02-04) * Merge pull request #44 from LittleCoinCoin/dev ([1157922](1157922)), closes [#44](#44) * chore: update entry point to hatch.cli module ([cf81671](cf81671)) * chore: update submodule `cracking-shells-playbook` ([222b357](222b357)) * chore(deps): add pytest to dev dependencies ([2761afe](2761afe)) * chore(docs): remove deprecated CLI api doc ([12a22c0](12a22c0)) * chore(docs): remove deprecated MCP documentation files ([5ca09a3](5ca09a3)) * chore(tests): remove deprecated MCP test files ([29a5ec5](29a5ec5)) * fix(backup): support different config filenames in backup listing ([06eb53a](06eb53a)), closes [#2](#2) * fix(docs): add missing return type annotations for mkdocs build ([da78682](da78682)) * docs: fix broken link in MCP host configuration architecture ([e9f89f1](e9f89f1)) * docs(api): restructure CLI API documentation to modular architecture ([318d212](318d212)) * docs(cli-ref): mark package list as deprecated and update filters ([06f5b75](06f5b75)) * docs(cli-ref): update environment commands section ([749d992](749d992)) * docs(cli-ref): update MCP commands section with new list/show commands ([1c812fd](1c812fd)) * docs(cli): add module docstrings for refactored CLI ([8d7de20](8d7de20)) * docs(cli): update documentation for handler-based architecture ([f95c5d0](f95c5d0)) * docs(devs): add CLI architecture and implementation guide ([a3152e1](a3152e1)) * docs(guide): add quick reference for viewing commands ([5bf5d01](5bf5d01)) * docs(guide): add viewing host configurations section ([6c381d1](6c381d1)) * docs(mcp-host-config): deprecate legacy architecture doc ([d8618a5](d8618a5)) * docs(mcp-host-config): deprecate legacy extension guide ([f172a51](f172a51)) * docs(mcp-host-config): write new architecture documentation ([ff05ad5](ff05ad5)) * docs(mcp-host-config): write new extension guide ([7821062](7821062)) * docs(mcp-reporting): document metadata field exclusion behavior ([5ccb7f9](5ccb7f9)) * docs(tutorial): fix command syntax in environment sync tutorial ([b2f40bf](b2f40bf)) * docs(tutorial): fix verification commands in checkpoint tutorial ([59b2485](59b2485)) * docs(tutorial): update env list output in create environment tutorial ([443607c](443607c)) * docs(tutorial): update package installation tutorial outputs ([588bab3](588bab3)) * docs(tutorials): fix command syntax in 04-mcp-host-configuration ([2ac1058](2ac1058)) * docs(tutorials): fix outdated env list output format in 02-environments ([d38ae24](d38ae24)) * docs(tutorials): fix validation output in 03-author-package ([776d40f](776d40f)) * refactor(cli): add deprecation warning to cli_hatch shim ([f9adf0a](f9adf0a)) * refactor(cli): create cli package structure ([bc80e29](bc80e29)) * refactor(cli): deprecate `mcp discover servers` and `package list` ([9ce5be0](9ce5be0)) * refactor(cli): extract argument parsing and implement clean routing ([efeae24](efeae24)) * refactor(cli): extract environment handlers to cli_env ([d00959f](d00959f)) * refactor(cli): extract handle_mcp_configure to cli_mcp ([9b9bc4d](9b9bc4d)) * refactor(cli): extract handle_mcp_sync to cli_mcp ([f69be90](f69be90)) * refactor(cli): extract MCP backup handlers to cli_mcp ([ca65e2b](ca65e2b)) * refactor(cli): extract MCP discovery handlers to cli_mcp ([887b96e](887b96e)) * refactor(cli): extract MCP list handlers to cli_mcp ([e518e90](e518e90)) * refactor(cli): extract MCP remove handlers to cli_mcp ([4e84be7](4e84be7)) * refactor(cli): extract package handlers to cli_package ([ebecb1e](ebecb1e)) * refactor(cli): extract shared utilities to cli_utils ([0b0dc92](0b0dc92)) * refactor(cli): extract system handlers to cli_system ([2f7d715](2f7d715)) * refactor(cli): integrate backup path into ResultReporter ([fd9a1f4](fd9a1f4)) * refactor(cli): integrate sync statistics into ResultReporter ([cc5a8b2](cc5a8b2)) * refactor(cli): normalize cli_utils warning messages ([6e9b983](6e9b983)) * refactor(cli): normalize MCP warning messages ([b72c6a4](b72c6a4)) * refactor(cli): normalize operation cancelled messages ([ab0b611](ab0b611)) * refactor(cli): normalize package warning messages ([c7463b3](c7463b3)) * refactor(cli): remove --pattern from mcp list servers ([b8baef9](b8baef9)) * refactor(cli): remove legacy mcp show <host> command ([fd2c290](fd2c290)) * refactor(cli): rewrite mcp list hosts for host-centric design ([ac88a84](ac88a84)) * refactor(cli): rewrite mcp list servers for host-centric design ([c2de727](c2de727)) * refactor(cli): simplify CLI to use unified MCPServerConfig with adapters ([d97b99e](d97b99e)) * refactor(cli): simplify env list to show package count only ([3045718](3045718)) * refactor(cli): update env execution errors to use report_error ([8021ba2](8021ba2)) * refactor(cli): update env validation error to use ValidationError ([101eba7](101eba7)) * refactor(cli): update MCP exception handlers to use report_error ([edec31d](edec31d)) * refactor(cli): update MCP validation errors to use ValidationError ([20b165a](20b165a)) * refactor(cli): update package errors to use report_error ([4d0ab73](4d0ab73)) * refactor(cli): update system errors to use report_error ([b205032](b205032)) * refactor(cli): use HatchArgumentParser for all parsers ([4b750fa](4b750fa)) * refactor(cli): use ResultReporter in env create/remove handlers ([d0991ba](d0991ba)) * refactor(cli): use ResultReporter in env python handlers ([df14f66](df14f66)) * refactor(cli): use ResultReporter in handle_env_python_add_hatch_mcp ([0ec6b6a](0ec6b6a)) * refactor(cli): use ResultReporter in handle_env_use ([b7536fb](b7536fb)) * refactor(cli): use ResultReporter in handle_mcp_configure ([5f3c60c](5f3c60c)) * refactor(cli): use ResultReporter in handle_mcp_sync ([9d52d24](9d52d24)) * refactor(cli): use ResultReporter in handle_package_add ([49585fa](49585fa)) * refactor(cli): use ResultReporter in handle_package_remove ([58ffdf1](58ffdf1)) * refactor(cli): use ResultReporter in handle_package_sync ([987b9d1](987b9d1)) * refactor(cli): use ResultReporter in MCP backup handlers ([9ec9e7b](9ec9e7b)) * refactor(cli): use ResultReporter in MCP remove handlers ([e727324](e727324)) * refactor(cli): use ResultReporter in system handlers ([df64898](df64898)) * refactor(cli): use TableFormatter in handle_env_list ([0f18682](0f18682)) * refactor(cli): use TableFormatter in handle_mcp_backup_list ([17dd96a](17dd96a)) * refactor(cli): use TableFormatter in handle_mcp_discover_hosts ([6bef0fa](6bef0fa)) * refactor(cli): use TableFormatter in handle_mcp_list_hosts ([3b465bb](3b465bb)) * refactor(cli): use TableFormatter in handle_mcp_list_servers ([3145e47](3145e47)) * refactor(mcp-host-config): unified MCPServerConfig ([ca0e51c](ca0e51c)) * refactor(mcp-host-config): update module exports ([5371a43](5371a43)) * refactor(mcp-host-config): wire all strategies to use adapters ([528e5f5](528e5f5)) * refactor(mcp): deprecate display_report in favor of ResultReporter ([3880ea3](3880ea3)) * refactor(models): remove legacy host-specific models from models.py ([ff92280](ff92280)) * feat(adapters): create AdapterRegistry for host-adapter mapping ([a8e3dfb](a8e3dfb)) * feat(adapters): create BaseAdapter abstract class ([4d9833c](4d9833c)) * feat(adapters): create host-specific adapters ([7b725c8](7b725c8)) * feat(cli): add --dry-run to env and package commands ([4a0f3e5](4a0f3e5)) * feat(cli): add --dry-run to env use, package add, create commands ([79da44c](79da44c)) * feat(cli): add --host and --pattern flags to mcp list servers ([29f86aa](29f86aa)) * feat(cli): add --json flag to list commands ([73f62ed](73f62ed)) * feat(cli): add --pattern filter to env list ([6deff84](6deff84)) * feat(cli): add Color, ConsequenceType, Consequence, ResultReporter ([10cdb71](10cdb71)) * feat(cli): add confirmation prompt to env remove ([b1156e7](b1156e7)) * feat(cli): add confirmation prompt to package remove ([38d9051](38d9051)) * feat(cli): add ConversionReport to ResultReporter bridge ([4ea999e](4ea999e)) * feat(cli): add format_info utility ([b1f33d4](b1f33d4)) * feat(cli): add format_validation_error utility ([f28b841](f28b841)) * feat(cli): add format_warning utility ([28ec610](28ec610)) * feat(cli): add hatch env show command ([2bc96bc](2bc96bc)) * feat(cli): add hatch mcp show command ([9ab53bc](9ab53bc)) * feat(cli): add HatchArgumentParser with formatted errors ([1fb7006](1fb7006)) * feat(cli): add highlight utility for entity names ([c25631a](c25631a)) * feat(cli): add parser for env list hosts command ([a218dea](a218dea)) * feat(cli): add parser for env list servers command ([851c866](851c866)) * feat(cli): add parser for mcp show hosts command ([f7abe61](f7abe61)) * feat(cli): add report_error method to ResultReporter ([e0f89e1](e0f89e1)) * feat(cli): add report_partial_success method to ResultReporter ([1ce4fd9](1ce4fd9)) * feat(cli): add TableFormatter for aligned table output ([658f48a](658f48a)) * feat(cli): add true color terminal detection ([aa76bfc](aa76bfc)) * feat(cli): add unicode terminal detection ([91d7c30](91d7c30)) * feat(cli): add ValidationError exception class ([af63b46](af63b46)) * feat(cli): implement env list hosts command ([bebe6ab](bebe6ab)) * feat(cli): implement env list servers command ([0c7a744](0c7a744)) * feat(cli): implement HCL color palette with true color support ([d70b4f2](d70b4f2)) * feat(cli): implement mcp show hosts command ([2c716bb](2c716bb)) * feat(cli): implement mcp show servers command ([e6df7b4](e6df7b4)) * feat(cli): update mcp list hosts JSON output ([a6f5994](a6f5994)) * feat(cli): update mcp list hosts parser with --server flag ([c298d52](c298d52)) * feat(mcp-host-config): add field support constants ([1e81a24](1e81a24)) * feat(mcp-host-config): add transport detection to MCPServerConfig ([c4eabd2](c4eabd2)) * feat(mcp-host-config): implement LMStudioAdapter ([0662b14](0662b14)) * feat(mcp-reporting): metadata fields exclusion from cli reports ([41db3da](41db3da)) * test(cli): add ConversionReport fixtures for reporter tests ([eeccff6](eeccff6)) * test(cli): add failing integration test for MCP handler ([acf7c94](acf7c94)) * test(cli): add failing test for host-centric mcp list servers ([0fcb8fd](0fcb8fd)) * test(cli): add failing tests for ConversionReport integration ([8e6efc0](8e6efc0)) * test(cli): add failing tests for env list hosts ([454b0e4](454b0e4)) * test(cli): add failing tests for env list servers ([7250387](7250387)) * test(cli): add failing tests for host-centric mcp list hosts ([3ec0617](3ec0617)) * test(cli): add failing tests for mcp show hosts ([8c8f3e9](8c8f3e9)) * test(cli): add failing tests for mcp show servers ([fac85fe](fac85fe)) * test(cli): add failing tests for TableFormatter ([90f3953](90f3953)) * test(cli): add test directory structure for CLI reporter ([7044b47](7044b47)) * test(cli): add test utilities for handler testing ([55322c7](55322c7)) * test(cli): add tests for Color enum and color enable/disable logic ([f854324](f854324)) * test(cli): add tests for Consequence dataclass and ResultReporter ([127575d](127575d)) * test(cli): add tests for ConsequenceType enum ([a3f0204](a3f0204)) * test(cli): add tests for error reporting methods ([2561532](2561532)) * test(cli): add tests for HatchArgumentParser ([8b192e5](8b192e5)) * test(cli): add tests for ValidationError and utilities ([a2a5c29](a2a5c29)) * test(cli): add true color detection tests ([79f6faa](79f6faa)) * test(cli): update backup tests for cli_mcp module ([8174bef](8174bef)) * test(cli): update color tests for HCL palette ([a19780c](a19780c)) * test(cli): update direct_management tests for cli_mcp module ([16f8520](16f8520)) * test(cli): update discovery tests for cli_mcp module ([de75cf0](de75cf0)) * test(cli): update for new cli architecture ([64cf74e](64cf74e)) * test(cli): update host config integration tests for cli_mcp module ([ea5c6b6](ea5c6b6)) * test(cli): update host_specific_args tests for cli_mcp module ([8f477f6](8f477f6)) * test(cli): update list tests for cli_mcp module ([e21ecc0](e21ecc0)) * test(cli): update mcp list servers tests for --pattern removal ([9bb5fe5](9bb5fe5)) * test(cli): update partial_updates tests for cli_mcp module ([4484e67](4484e67)) * test(cli): update remaining MCP tests for cli_mcp module ([a655775](a655775)) * test(cli): update sync_functionality tests for cli_mcp module ([eeb2d6d](eeb2d6d)) * test(cli): update tests for cli_utils module ([7d72f76](7d72f76)) * test(cli): update tests for mcp show removal ([a0e730b](a0e730b)) * test(deprecate): rename 28 legacy MCP tests to .bak for rebuild ([e7f9c50](e7f9c50)) * test(mcp-host-config): add adapter registry unit tests ([bc8f455](bc8f455)) * test(mcp-host-config): add integration tests for adapter serialization ([6910120](6910120)) * test(mcp-host-config): add regression tests for field filtering ([d6ce817](d6ce817)) * test(mcp-host-config): add unit tests ([c1a0fa4](c1a0fa4)) * test(mcp-host-config): create three-tier test directory structure ([d78681b](d78681b)) * test(mcp-host-config): update integration tests for adapter architecture ([acd7871](acd7871)) ### BREAKING CHANGE * Remove all legacy host-specific configuration models that are now replaced by the unified adapter architecture. Removed models: - MCPServerConfigBase (abstract base class) - MCPServerConfigGemini - MCPServerConfigVSCode - MCPServerConfigCursor - MCPServerConfigClaude - MCPServerConfigKiro - MCPServerConfigCodex - MCPServerConfigOmni - HOST_MODEL_REGISTRY The unified MCPServerConfig model plus host-specific adapters now handle all MCP server configuration. See: - hatch/mcp_host_config/adapters/ for host adapters This is part of Milestone 3.1: Legacy Removal in the adapter architecture refactoring. Tests will need to be updated in subsequent commits.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces a comprehensive refactoring of the Hatch CLI system, delivering three major improvements: a modular backend architecture, a unified user experience with consistent output formatting, and complete documentation alignment with the new implementation.
🏗️ Architecture Backend Refactoring
Modular CLI Architecture
Transformation: Monolithic
cli_hatch.py(2,994 LOC) → Modular package structureThe CLI has been restructured from a single 3,000-line file into a structured package:
Benefits:
Unified Adapter Architecture (MCP Host Configuration)
Transformation: Inheritance-based host models → Adapter-based unified model
Replaced the legacy inheritance hierarchy with a modern adapter pattern:
Before:
from_omni()conversion methods scattered across modelsAfter:
MCPServerConfigunified model with all fieldsBaseAdapterprotocol with 3 core methods:validate(),serialize(),get_supported_fields()AdapterRegistryfor host-adapter mappingImpact:
🎨 User-Facing UX Normalization
Unified Output Rendering System
Core Infrastructure:
ResultReporterclass handles ALL CLI output for consistencyKey Features:
[CREATE]), past tense for results ([CREATED])Standardized Command Outputs
List Commands (Tabular Format)
All list commands now use
TableFormatterfor consistent, aligned output:Features:
--json)--patternfor env/server,--hostfor host filtering)Show Commands (Hierarchical Format)
New detailed view commands with hierarchical structure:
Features:
Mutation Commands (Preview → Confirm → Result)
Consistent flow for all mutation operations:
Error & Warning Formatting
Unified error handling across all commands:
ValidationErrorexception class for structured validation errorsHatchArgumentParserwith formatted error messagesformat_validation_error(),format_warning(),format_info()utilities[ERROR],[WARNING],[INFO]prefixes with semantic colorsCoverage: 77 error/warning/info instances normalized across 4 CLI modules
New Commands & Features
New Commands:
hatch env show <name>- Detailed environment view with hierarchical structurehatch env list hosts- List environment/host/server deploymentshatch env list servers- List environment servers with deployment statushatch mcp show hosts [<host>]- Detailed host configuration viewhatch mcp show servers [<server>]- Detailed server view across hostsNew Flags:
--dry-run- Preview changes without execution (env use, env create, package add commands)--json- Machine-readable JSON output (all list commands)--pattern- Regex filtering for environments (env list)--env/-e- Filter by environment name (env list hosts/servers)--host- Filter by host name (mcp list servers, env list servers)--server- Filter by server name (mcp list hosts, env list hosts)New Confirmation Prompts:
hatch env remove- Requires confirmation before deletionhatch package remove- Requires confirmation before deletion--yes/-yfor auto-approvalDeprecated Commands (with stderr warnings and migration guidance):
hatch mcp discover servers→ Usehatch mcp list servershatch package list→ Usehatch env list(shows packages inline with environment info)HCL Color Palette
Semantic color categories with true color support:
Accessibility:
📚 Documentation Updates
Comprehensive Documentation Alignment
Scope: 31 files updated across tutorials, guides, and API reference
Categories:
CLI Reference (
CLIReference.md)env show,env list hosts/servers,mcp show hosts/serversTutorials (4 tutorial series)
Getting Started Guide
MCP Host Configuration Guide
Developer Documentation
Verification: All command syntax and output formats verified against implementation code
🧪 Testing
Test Coverage
CLI UX Tests:
MCP Architecture Tests:
Overall: 214 tests passing
Test Strategy
Behavioral contracts over output strings:
🎯 Migration Guide
Breaking Changes
None - All existing commands remain functional. Deprecated commands emit warnings to stderr but continue to work.
For Users
User-Facing Commands (emit warnings, still functional):
hatch mcp discover servers→ Migrate tohatch mcp list servershatch package list→ Migrate tohatch env list(shows packages inline)New capabilities:
NO_COLOR=1)--dry-runflag for preview mode--jsonflag for machine-readable outputFor Developers
Developer APIs (emit DeprecationWarning):
hatch.cli_hatchmodule → Import fromhatch.clipackage instead (removal in v0.9.0)display_report()function → UseResultReporter.add_from_conversion_report()insteadHandler Pattern (all handlers follow this):
Adapter Pattern (for new MCP hosts):
🔗 Related Documentation
docs/articles/devs/architecture/cli_architecture.mddocs/articles/devs/implementation_guides/adding_cli_commands.mddocs/articles/devs/architecture/mcp_host_configuration.mddocs/articles/devs/implementation_guides/mcp_host_configuration_extension.mddocs/articles/users/CLIReference.md