# Tasks: Refactor CLI Scripts to Web Application **Feature**: Refactor CLI Scripts to Web Application **Status**: Pending **Spec**: [specs/010-refactor-cli-to-web/spec.md](specs/010-refactor-cli-to-web/spec.md) ## Phase 1: Core & Infrastructure *Goal: Enhance TaskManager to support returning results and set up Connection management.* - [ ] T001 Create `backend/src/models/connection.py` with `ConnectionConfig` model (ensure secure storage of credentials) - [ ] T002 Update `backend/src/core/task_manager/models.py` to add `result: Optional[Dict[str, Any]]` field to `Task` model - [ ] T003 Update `backend/src/core/task_manager/manager.py` to capture `plugin.execute` return value and store it in `task.result` - [ ] T004 [P] Create `frontend/src/services/toolsService.js` for generic Task API communication (run task, poll status, get result) - [ ] T005 [P] Create `frontend/src/services/connectionService.js` for Connection API - [ ] T006 Create `frontend/src/components/tools/` directory structure ## Phase 2: User Story 1 - Search Datasets *Goal: Enable users to search datasets via the Web UI using a Plugin.* - [ ] T007 [US1] Implement `SearchPlugin` in `backend/src/plugins/search.py` (port logic from `search_script.py`, return results) - [ ] T008 [US1] Create `frontend/src/components/tools/SearchTool.svelte` component (triggers SearchPlugin, displays results) - [ ] T009 [US1] Create `frontend/src/routes/tools/search/+page.svelte` page ## Phase 3: User Story 2 - Map Dataset Columns *Goal: Enable users to map columns using saved connections via a Plugin.* - [ ] T010 [US2] Create API endpoints for Connections (`GET`, `POST`, `DELETE`) in `backend/src/api/routes/connections.py` - [ ] T011 [US2] Register `connections` router in `backend/src/api/routes/__init__.py` - [ ] T012 [US2] Implement `MapperPlugin` in `backend/src/plugins/mapper.py` (port logic from `run_mapper.py`, support `connection_id`) - [ ] T013 [US2] Create `frontend/src/components/tools/ConnectionForm.svelte` and `ConnectionList.svelte` - [ ] T014 [US2] Create `frontend/src/routes/settings/connections/+page.svelte` for managing connections - [ ] T015 [US2] Create `frontend/src/components/tools/MapperTool.svelte` component - [ ] T016 [US2] Create `frontend/src/routes/tools/mapper/+page.svelte` page ## Phase 4: User Story 3 - System Debugging *Goal: Enable users to run system diagnostics via a Plugin.* - [ ] T017 [US3] Implement `DebugPlugin` in `backend/src/plugins/debug.py` (port logic from `debug_db_api.py`, `get_dataset_structure.py`) - [ ] T018 [US3] Create `frontend/src/components/tools/DebugTool.svelte` component - [ ] T019 [US3] Create `frontend/src/routes/tools/debug/+page.svelte` page ## Phase 5: Cleanup & Polish *Goal: Remove legacy scripts and ensure system stability.* - [ ] T020 Verify all new tools are functional (Manual Test) - [ ] T021 Verify existing Backup functionality fully covers legacy `backup_script.py` capabilities - [ ] T022 Remove legacy script `search_script.py` - [ ] T023 Remove legacy script `run_mapper.py` - [ ] T024 Remove legacy script `debug_db_api.py` - [ ] T025 Remove legacy script `get_dataset_structure.py` - [ ] T026 Remove legacy script `backup_script.py` - [ ] T027 Update main navigation in `frontend/src/components/Navbar.svelte` to include "Tools" dropdown ## Dependencies - Phase 2 (Search) depends on Phase 1 (Task Result support) - Phase 3 (Mapper) depends on Phase 1 (Connection Model) - Phase 4 (Debug) depends on Phase 1 (Task Result support) - Phase 5 (Cleanup) depends on Phase 2, 3, 4 completion ## Implementation Strategy 1. **Core**: Upgrade TaskManager first to support return values. 2. **Search**: Implement SearchPlugin as the first "Result-returning" plugin. 3. **Connections**: Build connection management. 4. **Mapper**: Implement MapperPlugin using Connections. 5. **Debug**: Implement DebugPlugin. 6. **Cleanup**: Verify and delete.