-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Summary
Implement a new execution flow for the Titan CLI that prioritizes configuration verification at both global and local levels, including an interactive setup wizard for first-time users.
Description
Currently, the initialization process for Titan needs to be more structured. This feature changes the startup logic so that Titan automatically detects the environment state. It will check for a global configuration first; if missing, it will guide the user through a setup wizard. Once a global configuration is established, it will then ensure the current project directory is properly configured before proceeding with execution.
This solves the problem of "unconfigured" states and improves the onboarding experience for new users.
Objectives
- [Objective 1: Ensure a valid global configuration exists before any CLI operations.]
- [Objective 2: Automate the detection of local (project-level) configurations.]
- [Objective 3: Provide a user-friendly interactive wizard for initial setup.]
- [Objective 4: Streamline the transition from a fresh install to a project-ready state.]
Proposed Solution
Modify the CLI entry point to follow this logic:
- Check Global Config: Look for a configuration file in the user's home directory (e.g.,
~/.titan/config). - Global Wizard: If no global config is found, launch an interactive setup wizard to generate it.
- Check Local Config: Once global config is confirmed, look for a configuration file in the current working directory (e.g.,
./titan.jsonor.titan.yaml). - Local Setup: If no local config is found, prompt the user to configure Titan for the current project.
Implementation Phases
Phase 1: Configuration Discovery Logic
- Implement the search logic for global and local configuration files.
- Define the precedence rules for settings.
Phase 2: Interactive Setup Wizard
- Create the CLI prompt interface for global settings (API keys, preferences, etc.).
- Implement file generation logic for the global config file.
Phase 3: Project Initialization
- Implement the logic to detect and initialize project-specific settings if they are missing.
- Ensure the CLI can proceed to main execution once both layers are verified.
Tasks
- Implement
ConfigManagerto handle file detection. - Create the interactive wizard using a library like
InquirerorQuestionary. - Implement the logic to generate configuration files with appropriate permissions.
- Add unit tests for the configuration resolution hierarchy.
- Update the main entry point to wrap execution with these checks.
Acceptance Criteria
- Running
titanfor the first time triggers the global setup wizard. - If a global config exists but no local config is present, Titan prompts to configure the current directory.
- If both configurations exist, Titan runs normally without prompts.
- Users can bypass or cancel the wizard safely.
- Documentation is updated to reflect the new initialization flow.
Testing Strategy
Unit Tests:
- Test
find_global_config()with mocked file systems. - Test
find_local_config()in various directory structures.
Integration Tests:
- Mock the wizard input to ensure it generates a valid config file.
- Verify that the CLI execution flow pauses for configuration and resumes correctly.
Manual Testing:
- Delete all Titan configs and run the tool to verify the wizard starts.
- Run Titan in a new project folder to verify the local setup prompt.
Considerations
- Backwards compatibility: Ensure existing global configs are recognized and not overwritten.
- Environment Variables: Consider if environment variables should override these configuration files.
- Silent Mode: Provide a flag (e.g.,
--non-interactive) to skip wizards in CI/CD environments.
Code Snippets (Optional)
N/A