Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
164 commits
Select commit Hold shift + click to select a range
222b357
chore: update submodule `cracking-shells-playbook`
LittleCoinCoin Dec 30, 2025
bc80e29
refactor(cli): create cli package structure
LittleCoinCoin Dec 31, 2025
55322c7
test(cli): add test utilities for handler testing
LittleCoinCoin Dec 31, 2025
0b0dc92
refactor(cli): extract shared utilities to cli_utils
LittleCoinCoin Dec 31, 2025
7d72f76
test(cli): update tests for cli_utils module
LittleCoinCoin Dec 31, 2025
887b96e
refactor(cli): extract MCP discovery handlers to cli_mcp
LittleCoinCoin Dec 31, 2025
de75cf0
test(cli): update discovery tests for cli_mcp module
LittleCoinCoin Dec 31, 2025
e518e90
refactor(cli): extract MCP list handlers to cli_mcp
LittleCoinCoin Dec 31, 2025
e21ecc0
test(cli): update list tests for cli_mcp module
LittleCoinCoin Dec 31, 2025
ca65e2b
refactor(cli): extract MCP backup handlers to cli_mcp
LittleCoinCoin Dec 31, 2025
8174bef
test(cli): update backup tests for cli_mcp module
LittleCoinCoin Dec 31, 2025
9b9bc4d
refactor(cli): extract handle_mcp_configure to cli_mcp
LittleCoinCoin Dec 31, 2025
ea5c6b6
test(cli): update host config integration tests for cli_mcp module
LittleCoinCoin Dec 31, 2025
8f477f6
test(cli): update host_specific_args tests for cli_mcp module
LittleCoinCoin Dec 31, 2025
4484e67
test(cli): update partial_updates tests for cli_mcp module
LittleCoinCoin Dec 31, 2025
4e84be7
refactor(cli): extract MCP remove handlers to cli_mcp
LittleCoinCoin Dec 31, 2025
16f8520
test(cli): update direct_management tests for cli_mcp module
LittleCoinCoin Dec 31, 2025
f69be90
refactor(cli): extract handle_mcp_sync to cli_mcp
LittleCoinCoin Dec 31, 2025
eeb2d6d
test(cli): update sync_functionality tests for cli_mcp module
LittleCoinCoin Dec 31, 2025
a655775
test(cli): update remaining MCP tests for cli_mcp module
LittleCoinCoin Jan 1, 2026
d00959f
refactor(cli): extract environment handlers to cli_env
LittleCoinCoin Jan 1, 2026
ebecb1e
refactor(cli): extract package handlers to cli_package
LittleCoinCoin Jan 1, 2026
2f7d715
refactor(cli): extract system handlers to cli_system
LittleCoinCoin Jan 1, 2026
efeae24
refactor(cli): extract argument parsing and implement clean routing
LittleCoinCoin Jan 1, 2026
cf81671
chore: update entry point to hatch.cli module
LittleCoinCoin Jan 1, 2026
64cf74e
test(cli): update for new cli architecture
LittleCoinCoin Jan 1, 2026
8d7de20
docs(cli): add module docstrings for refactored CLI
LittleCoinCoin Jan 1, 2026
f95c5d0
docs(cli): update documentation for handler-based architecture
LittleCoinCoin Jan 1, 2026
f9adf0a
refactor(cli): add deprecation warning to cli_hatch shim
LittleCoinCoin Jan 1, 2026
1e81a24
feat(mcp-host-config): add field support constants
LittleCoinCoin Jan 2, 2026
ca0e51c
refactor(mcp-host-config): unified MCPServerConfig
LittleCoinCoin Jan 2, 2026
c4eabd2
feat(mcp-host-config): add transport detection to MCPServerConfig
LittleCoinCoin Jan 2, 2026
4d9833c
feat(adapters): create BaseAdapter abstract class
LittleCoinCoin Jan 2, 2026
7b725c8
feat(adapters): create host-specific adapters
LittleCoinCoin Jan 2, 2026
a8e3dfb
feat(adapters): create AdapterRegistry for host-adapter mapping
LittleCoinCoin Jan 2, 2026
d97b99e
refactor(cli): simplify CLI to use unified MCPServerConfig with adapters
LittleCoinCoin Jan 2, 2026
0662b14
feat(mcp-host-config): implement LMStudioAdapter
LittleCoinCoin Jan 2, 2026
528e5f5
refactor(mcp-host-config): wire all strategies to use adapters
LittleCoinCoin Jan 2, 2026
acd7871
test(mcp-host-config): update integration tests for adapter architecture
LittleCoinCoin Jan 2, 2026
ff92280
refactor(models): remove legacy host-specific models from models.py
LittleCoinCoin Jan 2, 2026
e7f9c50
test(deprecate): rename 28 legacy MCP tests to .bak for rebuild
LittleCoinCoin Jan 2, 2026
d78681b
test(mcp-host-config): create three-tier test directory structure
LittleCoinCoin Jan 3, 2026
c1a0fa4
test(mcp-host-config): add unit tests
LittleCoinCoin Jan 3, 2026
6910120
test(mcp-host-config): add integration tests for adapter serialization
LittleCoinCoin Jan 3, 2026
d6ce817
test(mcp-host-config): add regression tests for field filtering
LittleCoinCoin Jan 3, 2026
5371a43
refactor(mcp-host-config): update module exports
LittleCoinCoin Jan 3, 2026
bc8f455
test(mcp-host-config): add adapter registry unit tests
LittleCoinCoin Jan 3, 2026
d8618a5
docs(mcp-host-config): deprecate legacy architecture doc
LittleCoinCoin Jan 3, 2026
f172a51
docs(mcp-host-config): deprecate legacy extension guide
LittleCoinCoin Jan 3, 2026
ff05ad5
docs(mcp-host-config): write new architecture documentation
LittleCoinCoin Jan 3, 2026
7821062
docs(mcp-host-config): write new extension guide
LittleCoinCoin Jan 3, 2026
29a5ec5
chore(tests): remove deprecated MCP test files
LittleCoinCoin Jan 3, 2026
5ca09a3
chore(docs): remove deprecated MCP documentation files
LittleCoinCoin Jan 3, 2026
41db3da
feat(mcp-reporting): metadata fields exclusion from cli reports
LittleCoinCoin Jan 3, 2026
5ccb7f9
docs(mcp-reporting): document metadata field exclusion behavior
LittleCoinCoin Jan 3, 2026
06eb53a
fix(backup): support different config filenames in backup listing
LittleCoinCoin Jan 3, 2026
7044b47
test(cli): add test directory structure for CLI reporter
LittleCoinCoin Jan 30, 2026
eeccff6
test(cli): add ConversionReport fixtures for reporter tests
LittleCoinCoin Jan 30, 2026
f854324
test(cli): add tests for Color enum and color enable/disable logic
LittleCoinCoin Jan 30, 2026
a3f0204
test(cli): add tests for ConsequenceType enum
LittleCoinCoin Jan 30, 2026
127575d
test(cli): add tests for Consequence dataclass and ResultReporter
LittleCoinCoin Jan 30, 2026
10cdb71
feat(cli): add Color, ConsequenceType, Consequence, ResultReporter
LittleCoinCoin Jan 30, 2026
2761afe
chore(deps): add pytest to dev dependencies
LittleCoinCoin Jan 30, 2026
8e6efc0
test(cli): add failing tests for ConversionReport integration
LittleCoinCoin Jan 30, 2026
4ea999e
feat(cli): add ConversionReport to ResultReporter bridge
LittleCoinCoin Jan 30, 2026
3880ea3
refactor(mcp): deprecate display_report in favor of ResultReporter
LittleCoinCoin Jan 30, 2026
acf7c94
test(cli): add failing integration test for MCP handler
LittleCoinCoin Jan 30, 2026
5f3c60c
refactor(cli): use ResultReporter in handle_mcp_configure
LittleCoinCoin Jan 30, 2026
9d52d24
refactor(cli): use ResultReporter in handle_mcp_sync
LittleCoinCoin Jan 30, 2026
e727324
refactor(cli): use ResultReporter in MCP remove handlers
LittleCoinCoin Jan 30, 2026
9ec9e7b
refactor(cli): use ResultReporter in MCP backup handlers
LittleCoinCoin Jan 30, 2026
49585fa
refactor(cli): use ResultReporter in handle_package_add
LittleCoinCoin Jan 30, 2026
987b9d1
refactor(cli): use ResultReporter in handle_package_sync
LittleCoinCoin Jan 30, 2026
58ffdf1
refactor(cli): use ResultReporter in handle_package_remove
LittleCoinCoin Jan 30, 2026
d0991ba
refactor(cli): use ResultReporter in env create/remove handlers
LittleCoinCoin Jan 30, 2026
b7536fb
refactor(cli): use ResultReporter in handle_env_use
LittleCoinCoin Jan 30, 2026
df14f66
refactor(cli): use ResultReporter in env python handlers
LittleCoinCoin Jan 30, 2026
df64898
refactor(cli): use ResultReporter in system handlers
LittleCoinCoin Jan 30, 2026
0ec6b6a
refactor(cli): use ResultReporter in handle_env_python_add_hatch_mcp
LittleCoinCoin Jan 30, 2026
90f3953
test(cli): add failing tests for TableFormatter
LittleCoinCoin Jan 30, 2026
658f48a
feat(cli): add TableFormatter for aligned table output
LittleCoinCoin Jan 30, 2026
0f18682
refactor(cli): use TableFormatter in handle_env_list
LittleCoinCoin Jan 30, 2026
3b465bb
refactor(cli): use TableFormatter in handle_mcp_list_hosts
LittleCoinCoin Jan 30, 2026
3145e47
refactor(cli): use TableFormatter in handle_mcp_list_servers
LittleCoinCoin Jan 30, 2026
6bef0fa
refactor(cli): use TableFormatter in handle_mcp_discover_hosts
LittleCoinCoin Jan 30, 2026
17dd96a
refactor(cli): use TableFormatter in handle_mcp_backup_list
LittleCoinCoin Jan 30, 2026
2bc96bc
feat(cli): add hatch env show command
LittleCoinCoin Jan 30, 2026
9ab53bc
feat(cli): add hatch mcp show command
LittleCoinCoin Jan 30, 2026
9ce5be0
refactor(cli): deprecate `mcp discover servers` and `package list`
LittleCoinCoin Jan 30, 2026
73f62ed
feat(cli): add --json flag to list commands
LittleCoinCoin Jan 30, 2026
4a0f3e5
feat(cli): add --dry-run to env and package commands
LittleCoinCoin Jan 30, 2026
29f86aa
feat(cli): add --host and --pattern flags to mcp list servers
LittleCoinCoin Jan 30, 2026
0fcb8fd
test(cli): add failing test for host-centric mcp list servers
LittleCoinCoin Jan 30, 2026
c2de727
refactor(cli): rewrite mcp list servers for host-centric design
LittleCoinCoin Jan 30, 2026
6deff84
feat(cli): add --pattern filter to env list
LittleCoinCoin Jan 30, 2026
79da44c
feat(cli): add --dry-run to env use, package add, create commands
LittleCoinCoin Jan 30, 2026
b1156e7
feat(cli): add confirmation prompt to env remove
LittleCoinCoin Jan 30, 2026
38d9051
feat(cli): add confirmation prompt to package remove
LittleCoinCoin Jan 30, 2026
3045718
refactor(cli): simplify env list to show package count only
LittleCoinCoin Jan 30, 2026
c298d52
feat(cli): update mcp list hosts parser with --server flag
LittleCoinCoin Jan 30, 2026
3ec0617
test(cli): add failing tests for host-centric mcp list hosts
LittleCoinCoin Jan 30, 2026
ac88a84
refactor(cli): rewrite mcp list hosts for host-centric design
LittleCoinCoin Jan 30, 2026
a6f5994
feat(cli): update mcp list hosts JSON output
LittleCoinCoin Jan 30, 2026
b8baef9
refactor(cli): remove --pattern from mcp list servers
LittleCoinCoin Jan 30, 2026
9bb5fe5
test(cli): update mcp list servers tests for --pattern removal
LittleCoinCoin Jan 30, 2026
a218dea
feat(cli): add parser for env list hosts command
LittleCoinCoin Jan 30, 2026
454b0e4
test(cli): add failing tests for env list hosts
LittleCoinCoin Jan 30, 2026
bebe6ab
feat(cli): implement env list hosts command
LittleCoinCoin Jan 30, 2026
851c866
feat(cli): add parser for env list servers command
LittleCoinCoin Jan 30, 2026
7250387
test(cli): add failing tests for env list servers
LittleCoinCoin Jan 30, 2026
0c7a744
feat(cli): implement env list servers command
LittleCoinCoin Jan 30, 2026
aa76bfc
feat(cli): add true color terminal detection
LittleCoinCoin Jan 30, 2026
79f6faa
test(cli): add true color detection tests
LittleCoinCoin Jan 30, 2026
d70b4f2
feat(cli): implement HCL color palette with true color support
LittleCoinCoin Jan 30, 2026
c25631a
feat(cli): add highlight utility for entity names
LittleCoinCoin Jan 30, 2026
a19780c
test(cli): update color tests for HCL palette
LittleCoinCoin Jan 30, 2026
f7abe61
feat(cli): add parser for mcp show hosts command
LittleCoinCoin Jan 30, 2026
8c8f3e9
test(cli): add failing tests for mcp show hosts
LittleCoinCoin Jan 30, 2026
2c716bb
feat(cli): implement mcp show hosts command
LittleCoinCoin Jan 30, 2026
fac85fe
test(cli): add failing tests for mcp show servers
LittleCoinCoin Jan 30, 2026
e6df7b4
feat(cli): implement mcp show servers command
LittleCoinCoin Jan 30, 2026
fd2c290
refactor(cli): remove legacy mcp show <host> command
LittleCoinCoin Jan 30, 2026
a0e730b
test(cli): update tests for mcp show removal
LittleCoinCoin Jan 30, 2026
91d7c30
feat(cli): add unicode terminal detection
LittleCoinCoin Feb 2, 2026
e0f89e1
feat(cli): add report_error method to ResultReporter
LittleCoinCoin Feb 2, 2026
1ce4fd9
feat(cli): add report_partial_success method to ResultReporter
LittleCoinCoin Feb 2, 2026
2561532
test(cli): add tests for error reporting methods
LittleCoinCoin Feb 2, 2026
1fb7006
feat(cli): add HatchArgumentParser with formatted errors
LittleCoinCoin Feb 2, 2026
4b750fa
refactor(cli): use HatchArgumentParser for all parsers
LittleCoinCoin Feb 2, 2026
8b192e5
test(cli): add tests for HatchArgumentParser
LittleCoinCoin Feb 2, 2026
af63b46
feat(cli): add ValidationError exception class
LittleCoinCoin Feb 2, 2026
f28b841
feat(cli): add format_validation_error utility
LittleCoinCoin Feb 2, 2026
b1f33d4
feat(cli): add format_info utility
LittleCoinCoin Feb 2, 2026
a2a5c29
test(cli): add tests for ValidationError and utilities
LittleCoinCoin Feb 2, 2026
20b165a
refactor(cli): update MCP validation errors to use ValidationError
LittleCoinCoin Feb 2, 2026
edec31d
refactor(cli): update MCP exception handlers to use report_error
LittleCoinCoin Feb 2, 2026
b72c6a4
refactor(cli): normalize MCP warning messages
LittleCoinCoin Feb 2, 2026
101eba7
refactor(cli): update env validation error to use ValidationError
LittleCoinCoin Feb 2, 2026
8021ba2
refactor(cli): update env execution errors to use report_error
LittleCoinCoin Feb 2, 2026
4d0ab73
refactor(cli): update package errors to use report_error
LittleCoinCoin Feb 2, 2026
28ec610
feat(cli): add format_warning utility
LittleCoinCoin Feb 2, 2026
c7463b3
refactor(cli): normalize package warning messages
LittleCoinCoin Feb 2, 2026
b205032
refactor(cli): update system errors to use report_error
LittleCoinCoin Feb 2, 2026
6e9b983
refactor(cli): normalize cli_utils warning messages
LittleCoinCoin Feb 2, 2026
fd9a1f4
refactor(cli): integrate backup path into ResultReporter
LittleCoinCoin Feb 2, 2026
cc5a8b2
refactor(cli): integrate sync statistics into ResultReporter
LittleCoinCoin Feb 2, 2026
ab0b611
refactor(cli): normalize operation cancelled messages
LittleCoinCoin Feb 2, 2026
b2f40bf
docs(tutorial): fix command syntax in environment sync tutorial
LittleCoinCoin Feb 2, 2026
59b2485
docs(tutorial): fix verification commands in checkpoint tutorial
LittleCoinCoin Feb 2, 2026
6c381d1
docs(guide): add viewing host configurations section
LittleCoinCoin Feb 2, 2026
749d992
docs(cli-ref): update environment commands section
LittleCoinCoin Feb 2, 2026
1c812fd
docs(cli-ref): update MCP commands section with new list/show commands
LittleCoinCoin Feb 2, 2026
06f5b75
docs(cli-ref): mark package list as deprecated and update filters
LittleCoinCoin Feb 2, 2026
443607c
docs(tutorial): update env list output in create environment tutorial
LittleCoinCoin Feb 2, 2026
588bab3
docs(tutorial): update package installation tutorial outputs
LittleCoinCoin Feb 2, 2026
5bf5d01
docs(guide): add quick reference for viewing commands
LittleCoinCoin Feb 2, 2026
e9f89f1
docs: fix broken link in MCP host configuration architecture
LittleCoinCoin Feb 2, 2026
d38ae24
docs(tutorials): fix outdated env list output format in 02-environments
LittleCoinCoin Feb 3, 2026
776d40f
docs(tutorials): fix validation output in 03-author-package
LittleCoinCoin Feb 3, 2026
2ac1058
docs(tutorials): fix command syntax in 04-mcp-host-configuration
LittleCoinCoin Feb 3, 2026
a3152e1
docs(devs): add CLI architecture and implementation guide
LittleCoinCoin Feb 3, 2026
318d212
docs(api): restructure CLI API documentation to modular architecture
LittleCoinCoin Feb 3, 2026
da78682
fix(docs): add missing return type annotations for mkdocs build
LittleCoinCoin Feb 3, 2026
12a22c0
chore(docs): remove deprecated CLI api doc
LittleCoinCoin Feb 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
# Documentation Deprecation Analysis: CLI Refactoring Impact

**Date**: 2026-01-01
**Phase**: Post-Implementation Documentation Review
**Scope**: Identifying deprecated documentation after CLI handler-based architecture refactoring
**Reference**: `__design__/cli-refactoring-milestone-v0.7.2-dev.1.md`

---

## Executive Summary

The CLI refactoring from monolithic `cli_hatch.py` (2,850 LOC) to handler-based architecture in `hatch/cli/` package has rendered several documentation references outdated. This report identifies affected files and specifies required updates.

**Architecture Change Summary:**
```
BEFORE: AFTER:
hatch/cli_hatch.py (2,850 LOC) hatch/cli/
β”œβ”€β”€ __init__.py (57 LOC)
β”œβ”€β”€ __main__.py (840 LOC)
β”œβ”€β”€ cli_utils.py (270 LOC)
β”œβ”€β”€ cli_mcp.py (1,222 LOC)
β”œβ”€β”€ cli_env.py (375 LOC)
β”œβ”€β”€ cli_package.py (552 LOC)
└── cli_system.py (92 LOC)

hatch/cli_hatch.py (136 LOC) ← backward compat shim
```

---

## Affected Documentation Files

### Category 1: API Documentation (HIGH PRIORITY)

| File | Issue | Impact |
|------|-------|--------|
| `docs/articles/api/cli.md` | References `hatch.cli_hatch` only | mkdocstrings generates incomplete API docs |

**Current Content:**
```markdown
# CLI Module
::: hatch.cli_hatch
```

**Required Update:** Expand to document the full `hatch.cli` package structure with all submodules.

---

### Category 2: User Documentation (HIGH PRIORITY)

| File | Line | Issue |
|------|------|-------|
| `docs/articles/users/CLIReference.md` | 3 | States "implemented in `hatch/cli_hatch.py`" |

**Current Content (Line 3):**
```markdown
This document is a compact reference of all Hatch CLI commands and options implemented in `hatch/cli_hatch.py` presented as tables for quick lookup.
```

**Required Update:** Reference the new `hatch/cli/` package structure.

---

### Category 3: Developer Implementation Guides (HIGH PRIORITY)

| File | Lines | Issue |
|------|-------|-------|
| `docs/articles/devs/implementation_guides/mcp_host_configuration_extension.md` | 605, 613-626 | References `cli_hatch.py` for CLI integration |

**Affected Sections:**

1. **Line 605** - "Add CLI arguments in `cli_hatch.py`"
2. **Lines 613-626** - CLI Integration for Host-Specific Fields section

**Current Content:**
```markdown
4. **Add CLI arguments** in `cli_hatch.py` (see next section)
...
1. **Update function signature** in `handle_mcp_configure()`:
```python
def handle_mcp_configure(
# ... existing params ...
your_field: Optional[str] = None, # Add your field
):
```
```

**Required Update:**
- Argument parsing β†’ `hatch/cli/__main__.py`
- Handler modifications β†’ `hatch/cli/cli_mcp.py`

---

### Category 4: Architecture Documentation (MEDIUM PRIORITY)

| File | Line | Issue |
|------|------|-------|
| `docs/articles/devs/architecture/mcp_host_configuration.md` | 158 | References `cli_hatch.py` |

**Current Content (Line 158):**
```markdown
1. Extend `handle_mcp_configure()` function signature in `cli_hatch.py`
```

**Required Update:** Reference new module locations.

---

### Category 5: Architecture Diagrams (MEDIUM PRIORITY)

| File | Line | Issue |
|------|------|-------|
| `docs/resources/diagrams/architecture.puml` | 9 | Shows CLI as single `cli_hatch` component |

**Current Content:**
```plantuml
Container_Boundary(cli, "CLI Layer") {
Component(cli_hatch, "CLI Interface", "Python", "Command-line interface\nArgument parsing and validation")
}
```

**Required Update:** Reflect modular CLI architecture with handler modules.

---

### Category 6: Instruction Templates (LOW PRIORITY)

| File | Lines | Issue |
|------|-------|-------|
| `cracking-shells-playbook/instructions/documentation-api.instructions.md` | 37-41 | Uses `hatch/cli_hatch.py` as example |

**Current Content:**
```markdown
**For a module `hatch/cli_hatch.py`, create `docs/articles/api/cli.md`:**
```markdown
# CLI Module
::: hatch.cli_hatch
```
```

**Required Update:** Update example to show new CLI package pattern.

---

## Files NOT to Modify

| Category | Files | Reason |
|----------|-------|--------|
| Historical Analysis | `__reports__/CLI-refactoring/00-04*.md` | Document pre-refactoring state |
| Design Documents | `__design__/cli-refactoring-*.md` | Document refactoring plan |
| Handover Documents | `__design__/handover-*.md` | Document session context |

---

## Update Strategy

### Handler Location Mapping

| Handler/Function | Old Location | New Location |
|------------------|--------------|--------------|
| `main()` | `hatch.cli_hatch` | `hatch.cli.__main__` |
| `handle_mcp_configure()` | `hatch.cli_hatch` | `hatch.cli.cli_mcp` |
| `handle_mcp_*()` | `hatch.cli_hatch` | `hatch.cli.cli_mcp` |
| `handle_env_*()` | `hatch.cli_hatch` | `hatch.cli.cli_env` |
| `handle_package_*()` | `hatch.cli_hatch` | `hatch.cli.cli_package` |
| `handle_create()`, `handle_validate()` | `hatch.cli_hatch` | `hatch.cli.cli_system` |
| `parse_host_list()`, utilities | `hatch.cli_hatch` | `hatch.cli.cli_utils` |
| Argument parsing | `hatch.cli_hatch` | `hatch.cli.__main__` |

### Backward Compatibility Note

`hatch/cli_hatch.py` remains as a backward compatibility shim that re-exports all public symbols. External consumers can still import from `hatch.cli_hatch`, but new code should use `hatch.cli.*`.

---

## Implementation Checklist

- [x] Update `docs/articles/api/cli.md` - Expand API documentation
- [x] Update `docs/articles/users/CLIReference.md` - Fix intro paragraph
- [x] Update `docs/articles/devs/implementation_guides/mcp_host_configuration_extension.md` - Fix CLI integration section
- [x] Update `docs/articles/devs/architecture/mcp_host_configuration.md` - Fix CLI reference
- [x] Update `docs/resources/diagrams/architecture.puml` - Update CLI component
- [x] Update `cracking-shells-playbook/instructions/documentation-api.instructions.md` - Update example

---

## Risk Assessment

| Risk | Likelihood | Impact | Mitigation |
|------|------------|--------|------------|
| Broken mkdocstrings generation | High | Medium | Test docs build after changes |
| Developer confusion from outdated guides | Medium | High | Prioritize implementation guide updates |
| Diagram regeneration issues | Low | Low | Verify PlantUML syntax |

3 changes: 0 additions & 3 deletions docs/articles/api/cli.md

This file was deleted.

58 changes: 58 additions & 0 deletions docs/articles/api/cli/env.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Environment Handlers

The environment handlers module (`cli_env.py`) contains handlers for environment management commands.

## Overview

This module provides handlers for:

- **Basic Environment Management**: Create, remove, list, use, current, show
- **Python Environment Management**: Initialize, info, remove, shell, add-hatch-mcp
- **Environment Listings**: List hosts, list servers (deployment views)

## Handler Functions

### Basic Environment Management
- `handle_env_create()`: Create new environments
- `handle_env_remove()`: Remove environments with confirmation
- `handle_env_list()`: List environments with table output
- `handle_env_use()`: Set current environment
- `handle_env_current()`: Show current environment
- `handle_env_show()`: Detailed hierarchical environment view

### Python Environment Management
- `handle_env_python_init()`: Initialize Python virtual environment
- `handle_env_python_info()`: Show Python environment information
- `handle_env_python_remove()`: Remove Python virtual environment
- `handle_env_python_shell()`: Launch interactive Python shell
- `handle_env_python_add_hatch_mcp()`: Add hatch_mcp_server wrapper

### Environment Listings
- `handle_env_list_hosts()`: Environment/host/server deployments
- `handle_env_list_servers()`: Environment/server/host deployments

## Handler Signature

All handlers follow the standard signature:

```python
def handle_env_command(args: Namespace) -> int:
"""Handle 'hatch env command' command.

Args:
args: Namespace with:
- env_manager: HatchEnvironmentManager instance
- <command-specific arguments>

Returns:
Exit code (0 for success, 1 for error)
"""
```

## Module Reference

::: hatch.cli.cli_env
options:
show_source: true
show_root_heading: true
heading_level: 2
135 changes: 135 additions & 0 deletions docs/articles/api/cli/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# CLI Package

The CLI package provides the command-line interface for Hatch, organized into domain-specific handler modules following a handler-based architecture pattern.

## Architecture Overview

The CLI underwent a significant refactoring from a monolithic structure (`cli_hatch.py`) to a modular, handler-based architecture. This design emphasizes:

- **Modularity**: Commands organized into focused handler modules
- **Consistency**: Unified output formatting across all commands
- **Extensibility**: Easy addition of new commands and features
- **Testability**: Clear separation of concerns for unit testing

### Package Structure

```
hatch/cli/
β”œβ”€β”€ __init__.py # Package exports and main() entry point
β”œβ”€β”€ __main__.py # Argument parsing and command routing
β”œβ”€β”€ cli_utils.py # Shared utilities and constants
β”œβ”€β”€ cli_mcp.py # MCP host configuration handlers
β”œβ”€β”€ cli_env.py # Environment management handlers
β”œβ”€β”€ cli_package.py # Package management handlers
└── cli_system.py # System commands (create, validate)
```

## Module Overview

### Entry Point (`__main__.py`)
The routing layer that parses command-line arguments and delegates to appropriate handler modules. Initializes shared managers and attaches them to the args namespace for handler access.

**Key Components**:
- `HatchArgumentParser`: Custom argument parser with formatted error messages
- Command routing functions
- Manager initialization

### Utilities (`cli_utils.py`)
Shared infrastructure used across all handlers, including:

- **Color System**: HCL color palette with true color support
- **ConsequenceType**: Dual-tense action labels for prompts and results
- **ResultReporter**: Unified rendering for mutation commands
- **TableFormatter**: Aligned table output for list commands
- **Error Formatting**: Structured validation and error messages

### Handler Modules
Domain-specific command implementations:

- **Environment Handlers** (`cli_env.py`): Environment lifecycle and Python environment operations
- **Package Handlers** (`cli_package.py`): Package installation, removal, and synchronization
- **MCP Handlers** (`cli_mcp.py`): MCP host configuration, discovery, and backup
- **System Handlers** (`cli_system.py`): System-level operations (package creation, validation)

## Getting Started

### Programmatic Usage

```python
from hatch.cli import main, EXIT_SUCCESS, EXIT_ERROR

# Run CLI programmatically
exit_code = main()

# Or import specific handlers
from hatch.cli.cli_env import handle_env_create
from hatch.cli.cli_utils import ResultReporter, ConsequenceType
```

### Handler Signature Pattern

All handlers follow a consistent signature:

```python
def handle_command(args: Namespace) -> int:
"""Handle 'hatch command' command.

Args:
args: Namespace with:
- env_manager: HatchEnvironmentManager instance
- mcp_manager: MCPHostConfigurationManager instance (if needed)
- <command-specific arguments>

Returns:
Exit code (0 for success, 1 for error)
"""
# Implementation
return EXIT_SUCCESS
```

## Output Formatting

The CLI uses a unified output formatting system:

### Mutation Commands
Commands that modify state use `ResultReporter`:

```python
reporter = ResultReporter("hatch env create", dry_run=False)
reporter.add(ConsequenceType.CREATE, "Environment 'dev'")
reporter.report_result()
```

### List Commands
Commands that display data use `TableFormatter`:

```python
from hatch.cli.cli_utils import TableFormatter, ColumnDef

columns = [
ColumnDef(name="Name", width=20),
ColumnDef(name="Status", width=10),
]
formatter = TableFormatter(columns)
formatter.add_row(["my-env", "active"])
print(formatter.render())
```

## Backward Compatibility

The old monolithic `hatch.cli_hatch` module has been refactored into the modular structure. For backward compatibility, imports from `hatch.cli_hatch` are still supported but deprecated:

```python
# Old (deprecated, still works):
from hatch.cli_hatch import main, handle_mcp_configure

# New (preferred):
from hatch.cli import main
from hatch.cli.cli_mcp import handle_mcp_configure
```

## Related Documentation

- [CLI Architecture](../../devs/architecture/cli_architecture.md): Detailed architectural design and patterns
- [Adding CLI Commands](../../devs/implementation_guides/adding_cli_commands.md): Step-by-step implementation guide
- [CLI Reference](../../users/CLIReference.md): User-facing command documentation
Loading