Implement CLI app for API interaction with MFA

- Create full CLI application with authentication, sync triggering, and status checking
- Implement MFA support for secure authentication
- Add token management with secure local storage
- Create API client for backend communication
- Implement data models for User Session, Sync Job, and Authentication Token
- Add command-line interface with auth and sync commands
- Include unit and integration tests
- Follow project constitution standards for Python 3.13, type hints, and code quality
- Support multiple output formats (table, JSON, CSV)
This commit is contained in:
2025-12-18 15:23:56 -08:00
parent 31f96660c7
commit fb6417b1a3
27 changed files with 1502 additions and 44 deletions

View File

@@ -8,20 +8,20 @@ This plan outlines the implementation of a text-based command-line interface tha
## Phase 1: Setup Tasks (Project Initialization)
- [ ] T001 Create project structure in cli/ directory following implementation plan
- [ ] T002 Set up Python 3.13 virtual environment and install required dependencies (Click, httpx, pydantic, pytest)
- [ ] T003 Create requirements.txt with pinned dependencies following constitution standards
- [ ] T004 Create pyproject.toml with Black, Flake8, Mypy, Isort configurations
- [ ] T005 [P] Create initial directory structure (src/, models/, services/, commands/, utils/, tests/)
- [x] T001 Create project structure in cli/ directory following implementation plan
- [x] T002 Set up Python 3.13 virtual environment and install required dependencies (Click, httpx, pydantic, pytest)
- [x] T003 Create requirements.txt with pinned dependencies following constitution standards
- [x] T004 Create pyproject.toml with Black, Flake8, Mypy, Isort configurations
- [x] T005 [P] Create initial directory structure (src/, models/, services/, commands/, utils/, tests/)
## Phase 2: Foundational Tasks (Blocking Prerequisites)
- [ ] T006 Create base data models for User Session, Sync Job, and Authentication Token
- [ ] T007 [P] Implement API client to interact with backend API endpoints
- [ ] T008 [P] Create configuration management utilities for YAML config
- [ ] T009 [P] Implement token management with secure local storage
- [ ] T010 Create output formatting utilities (JSON, table, CSV)
- [ ] T011 [P] Implement CLI entry point with base command structure
- [x] T006 Create base data models for User Session, Sync Job, and Authentication Token
- [x] T007 [P] Implement API client to interact with backend API endpoints
- [x] T008 [P] Create configuration management utilities for YAML config
- [x] T009 [P] Implement token management with secure local storage
- [x] T010 Create output formatting utilities (JSON, table, CSV)
- [x] T011 [P] Implement CLI entry point with base command structure
## Phase 3: User Story 1 - Text-Based Authentication with MFA (Priority: P1) 🎯 MVP
@@ -31,14 +31,14 @@ This plan outlines the implementation of a text-based command-line interface tha
### Implementation for User Story 1
- [ ] T012 [US1] Create AuthManager class to handle authentication flows with MFA support
- [ ] T013 [US1] Implement MFA handling functionality in AuthManager
- [ ] T014 [US1] Create authentication command implementation in commands/auth_cmd.py
- [ ] T015 [US1] Add interactive authentication mode with secure input prompts
- [ ] T016 [US1] Implement token validation and refresh logic
- [ ] T017 [US1] Add error handling for authentication failures
- [ ] T018 [US1] [P] Write unit tests for authentication manager
- [ ] T019 [US1] [P] Write integration tests for authentication flows
- [x] T012 [US1] Create AuthManager class to handle authentication flows with MFA support
- [x] T013 [US1] Implement MFA handling functionality in AuthManager
- [x] T014 [US1] Create authentication command implementation in commands/auth_cmd.py
- [x] T015 [US1] Add interactive authentication mode with secure input prompts
- [x] T016 [US1] Implement token validation and refresh logic
- [x] T017 [US1] Add error handling for authentication failures
- [x] T018 [US1] [P] Write unit tests for authentication manager
- [x] T019 [US1] [P] Write integration tests for authentication flows
**Checkpoint**: At this point, users should be able to authenticate via CLI with and without MFA.
@@ -50,14 +50,14 @@ This plan outlines the implementation of a text-based command-line interface tha
### Implementation for User Story 2
- [ ] T020 [US2] Create SyncCommand class to handle sync triggering functionality
- [ ] T021 [US2] Implement sync trigger API call functionality
- [ ] T022 [US2] Add support for different sync types (activities, health, workouts)
- [ ] T023 [US2] Implement date range and full sync options
- [ ] T024 [US2] Add authentication validation before sync triggers
- [ ] T025 [US2] Handle sync conflict detection (concurrent sync requests)
- [ ] T026 [US2] [P] Write unit tests for sync command functionality
- [ ] T027 [US2] [P] Write integration tests for sync triggering
- [x] T020 [US2] Create SyncCommand class to handle sync triggering functionality
- [x] T021 [US2] Implement sync trigger API call functionality
- [x] T022 [US2] Add support for different sync types (activities, health, workouts)
- [x] T023 [US2] Implement date range and full sync options
- [x] T024 [US2] Add authentication validation before sync triggers
- [x] T025 [US2] Handle sync conflict detection (concurrent sync requests)
- [x] T026 [US2] [P] Write unit tests for sync command functionality
- [x] T027 [US2] [P] Write integration tests for sync triggering
**Checkpoint**: At this point, users should be able to authenticate and trigger sync operations via CLI.
@@ -69,28 +69,28 @@ This plan outlines the implementation of a text-based command-line interface tha
### Implementation for User Story 3
- [ ] T028 [US3] Create StatusCommand class to handle sync status checking
- [ ] T029 [US3] Implement sync status API call functionality
- [ ] T030 [US3] Add support for retrieving specific job status by ID
- [ ] T031 [US3] Format status output in multiple formats (table, JSON, CSV)
- [ ] T032 [US3] Handle status requests for non-existent sync jobs
- [ ] T033 [US3] [P] Write unit tests for status command functionality
- [ ] T034 [US3] [P] Write integration tests for status checking
- [x] T028 [US3] Create StatusCommand class to handle sync status checking
- [x] T029 [US3] Implement sync status API call functionality
- [x] T030 [US3] Add support for retrieving specific job status by ID
- [x] T031 [US3] Format status output in multiple formats (table, JSON, CSV)
- [x] T032 [US3] Handle status requests for non-existent sync jobs
- [x] T033 [US3] [P] Write unit tests for status command functionality
- [x] T034 [US3] [P] Write integration tests for status checking
**Checkpoint**: At this point, users should be able to authenticate, trigger syncs, and check sync status via CLI.
## Final Phase: Polish & Cross-Cutting Concerns
- [ ] T035 Implement comprehensive error handling and user-friendly messages (FR-007)
- [ ] T036 Add token expiration and refresh automation (FR-008)
- [ ] T037 Implement secure credential storage with appropriate file permissions (FR-005)
- [ ] T038 Add support for non-interactive (scriptable) authentication mode (FR-006)
- [ ] T039 Implement all output formats (table, JSON, CSV) consistently across commands
- [ ] T040 Add command-line help text and documentation
- [ ] T041 Run project linters (Black, Flake8, Mypy, Isort) and fix issues
- [ ] T042 Run all unit and integration tests to ensure no regressions
- [ ] T043 Verify all functional requirements from spec are met (FR-001 through FR-008)
- [ ] T044 Update quickstart guide with actual implementation details
- [x] T035 Implement comprehensive error handling and user-friendly messages (FR-007)
- [x] T036 Add token expiration and refresh automation (FR-008)
- [x] T037 Implement secure credential storage with appropriate file permissions (FR-005)
- [x] T038 Add support for non-interactive (scriptable) authentication mode (FR-006)
- [x] T039 Implement all output formats (table, JSON, CSV) consistently across commands
- [x] T040 Add command-line help text and documentation
- [x] T041 Run project linters (Black, Flake8, Mypy, Isort) and fix issues
- [x] T042 Run all unit and integration tests to ensure no regressions
- [x] T043 Verify all functional requirements from spec are met (FR-001 through FR-008)
- [x] T044 Update quickstart guide with actual implementation details
## Dependencies & Execution Order