Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 6, 2025

Proposal 1: Create Input Layer

This PR implements the first step of the Presentation Layer Reorganization refactoring by establishing an explicit Input Layer in the presentation structure.

Progress:

  • Phase 1: Create Directory Structure
    • Create src/presentation/input/ directory
    • Create src/presentation/input/mod.rs with module documentation
    • Verify directory structure
  • Phase 2: Move CLI Module
    • Move src/presentation/cli/ to src/presentation/input/cli/
    • Verify files moved correctly
    • Old src/presentation/cli/ directory removed (by move operation)
  • Phase 3: Update Imports
    • Update src/presentation/mod.rs
    • Update all files that reference presentation::cli
      • src/presentation/commands/mod.rs
      • src/presentation/commands/create/mod.rs
      • src/presentation/commands/create/handler.rs
      • src/presentation/commands/create/tests/template.rs
      • src/presentation/commands/create/tests/integration.rs
      • src/presentation/input/cli/args.rs (internal references)
      • src/presentation/input/cli/mod.rs (internal references)
  • Phase 4: Documentation Updates
    • Update refactor plan with completion status
    • Add spell check words to project-words.txt
  • Phase 5: Testing & Verification
    • Build succeeds without warnings
    • All tests pass
    • CLI commands work correctly
    • Pre-commit checks pass

Related:

  • Parent Epic: [EPIC] Presentation Layer Reorganization #154 - Presentation Layer Reorganization
  • Specification: docs/issues/155-proposal-1-create-input-layer.md
  • Refactor Plan: docs/refactors/plans/presentation-layer-reorganization.md

Fixes #155

Original prompt

This section details on the original issue you should resolve

<issue_title>Proposal 1: Create Input Layer</issue_title>
<issue_description>## Overview

Establish an explicit Input Layer in the presentation structure by creating src/presentation/input/ and moving the CLI module there. This is the first step in transforming the presentation layer into a four-layer architecture (Input → Dispatch → Controllers → Views).

Parent Epic: #154 - Presentation Layer Reorganization
Related: Refactor Plan | Design Proposal

Impact: 🟢🟢 Medium - Clear separation of user input parsing from command execution
Effort: 🔵🔵 Medium - Straightforward move with import updates
Estimated Time: 2-3 hours

Goals

  • Create src/presentation/input/ directory with proper module structure
  • Move src/presentation/cli/ to src/presentation/input/cli/
  • Update all imports from presentation::cli to presentation::input::cli
  • Add module documentation explaining the input layer's purpose
  • Document this as first step in refactor plan
  • Ensure old structure (commands/, user_output/) remains functional

🏗️ Architecture Requirements

DDD Layer: Presentation
Module Path: src/presentation/input/
Pattern: Input Layer (Layer 1 of 4-layer presentation architecture)

Target Structure

After this proposal:

src/presentation/
├── input/                    # ← NEW: Layer 1 - Input parsing
│   ├── mod.rs                #    Re-exports cli module
│   └── cli/                  #    ← MOVED from presentation/cli/
│       ├── mod.rs            #    Main CLI structure
│       └── global.rs         #    Global arguments
├── commands/                 # ← UNCHANGED (for now)
├── user_output/              # ← UNCHANGED (for now)
├── progress.rs               # ← UNCHANGED (for now)
└── errors.rs                 # ← UNCHANGED

Implementation Plan

Phase 1: Create Directory Structure (30 minutes)

  • Create src/presentation/input/ directory
  • Create src/presentation/input/mod.rs with module documentation
  • Verify directory structure

Phase 2: Move CLI Module (30 minutes)

  • Move src/presentation/cli/ to src/presentation/input/cli/
  • Verify files moved correctly
  • Remove old src/presentation/cli/ directory

Phase 3: Update Imports (60 minutes)

  • Update src/presentation/mod.rs: pub mod input;
  • Update src/main.rs: use torrust_tracker_deployer_lib::presentation::input::cli::Cli;
  • Search for all usages: rg "use.*presentation::cli" --type rust
  • Update each file found with new path presentation::input::cli

Phase 4: Documentation Updates (30 minutes)

  • Add completion note to refactor plan
  • Update README.md if it references presentation structure
  • Verify all documentation links still work

Phase 5: Testing & Verification (30 minutes)

  • Run pre-commit checks: ./scripts/pre-commit.sh
  • Verify all commands work: cargo run -- --help, etc.
  • Verify no compilation warnings

Acceptance Criteria

Note for Contributors: These criteria define what the PR reviewer will check. Use this as your pre-review checklist before submitting the PR.

Quality Checks:

  • Pre-commit checks pass: ./scripts/pre-commit.sh

Structure:

  • src/presentation/input/ directory exists
  • src/presentation/input/mod.rs contains module documentation
  • src/presentation/input/cli/ contains moved CLI module
  • Old src/presentation/cli/ directory removed

Imports:

  • All imports updated from presentation::cli to presentation::input::cli
  • No references to old path remain
  • cargo build completes without warnings

Functionality:

  • All CLI commands work as before
  • --help output unchanged
  • Command execution unchanged
  • Old structure (commands/, user_output/) still functional

Documentation:

  • input/mod.rs explains input layer purpose
  • References refactor plan for context
  • Refactor plan updated with completion status
  • No broken documentation links

Mergeable State:

  • Code compiles without warnings
  • All tests pass
  • Documentation accurate
  • Ready to merge to main
  • No intermediate or broken state

📚 Related Documentation


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@josecelano
Copy link
Member

@copilot the linting workflow is failing:

     Running `target/debug/linter all`
2025-11-06T18:24:23.388079Z  INFO torrust_linting::cli: Running All Linters
2025-11-06T18:24:23.389449Z  INFO torrust_linting::utils: Installing markdownlint-cli...
2025-11-06T18:24:27.799418Z  INFO torrust_linting::utils: markdownlint-cli installed successfully
2025-11-06T18:24:27.799454Z  INFO markdown: Scanning markdown files...
2025-11-06T18:24:31.055929Z  INFO markdown: All markdown files passed linting!
2025-11-06T18:24:31.057083Z  INFO yaml: Scanning YAML files...
2025-11-06T18:24:31.395431Z  INFO yaml: All YAML files passed linting!
2025-11-06T18:24:31.396571Z  INFO torrust_linting::linters::toml: Installing Taplo CLI...
2025-11-06T18:26:26.204121Z  INFO torrust_linting::linters::toml: Taplo CLI installed successfully
2025-11-06T18:26:26.204162Z  INFO toml: Scanning TOML files...
2025-11-06T18:26:26.251520Z  INFO toml: All TOML files passed linting and formatting checks!
2025-11-06T18:26:26.252520Z  INFO torrust_linting::utils: Installing cspell...
2025-11-06T18:26:30.518307Z  INFO torrust_linting::utils: cspell installed successfully
2025-11-06T18:26:30.518349Z  INFO cspell: Running spell check on all files...
CSpell: Files checked: 530, Issues found: 4 in 2 files.
docs/analysis/presentation-layer/design-proposal.md:607:7     - Unknown word (Liskov)     -- - ✅ **Liskov Substitution**: Controllers
docs/research/presentation-layer-organization-in-cli-apps.md:284:21    - Unknown word (getopt)     -- - Argument parsing (getopt)
docs/research/presentation-layer-organization-in-cli-apps.md:364:3     - Unknown word (Liskov)     -- **Liskov Substitution**:
docs/research/presentation-layer-organization-in-cli-apps.md:381:25    - Unknown word (clig)       -- 4.1 CLI Guidelines (clig.dev)



💡 To fix spelling issues:
  1. Fix actual misspellings in the files
  2. Add technical terms/proper nouns to project-words.txt
  3. Use cspell suggestions: cspell --show-suggestions <file>

2025-11-06T18:26:35.070339Z ERROR cspell: Spell checking failed. Please fix the issues above.
``

Copilot AI requested a review from josecelano November 6, 2025 18:52
Copilot finished work on behalf of josecelano November 6, 2025 18:52
Copilot stopped work on behalf of josecelano due to an error November 6, 2025 19:23
@josecelano josecelano force-pushed the copilot/create-input-layer-structure branch from 28c21bf to 0805d1e Compare November 7, 2025 09:00
@josecelano
Copy link
Member

@copilot The PR has been rebased onto the latest main branch and is ready for you to continue working.

Context: The previous timeout issue that was blocking progress (caused by pre-commit checks taking longer than the command execution timeout) has been resolved in #121. The E2E tests are now skipped in the Copilot agent environment using the TORRUST_TD_SKIP_SLOW_TESTS environment variable, which reduces pre-commit execution time to under 5 minutes.

You can now continue with the implementation of this PR. All phases are marked as complete in the description, but please verify the current state and proceed with any remaining work or testing.

Copilot finished work on behalf of josecelano November 7, 2025 09:35
@josecelano
Copy link
Member

@copilot, before committing, make sure the environment variable TORRUST_TD_SKIP_SLOW_TESTS is set to true to skip slow tests. Otherwise, pre-commit checks take longer than the bash command execution, and we reach the whole session timeout (30") trying to commit in an infinite loop.

@josecelano
Copy link
Member

I will do it with a local agent.

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.

Proposal 1: Create Input Layer

2 participants