feat: interactive init wizard with CI pipeline#3
Merged
Conversation
…ities - Created src/pdf2mcp/interactive.py with text_prompt, secret_prompt, confirm_prompt, select_prompt, print_banner, and print_step functions - Added WizardCancelledError exception for Ctrl+C handling - All output directed to stderr (Console with stderr=True) - Added 22 unit tests in tests/test_interactive.py - All quality gates pass (ruff, mypy, pytest) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Rename module-level console to _console (private convention) - Use MagicMock type for test mock parameters - Use injected mocks directly instead of re-importing module - Fix import from rich.console (not rich._console) - Update story specs to use WizardCancelledError name - Added 2 more test cases (24 total) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
….env generation - Added WizardResult dataclass holding all collected settings - Added 6-step wizard flow: project dir, API key, docs dir, embedding, server, OCR - Added generate_env_content() with smart commenting (defaults commented, custom uncommented) - Added apply_wizard_result() with summary panel, overwrite protection - API key validated (not empty, starts with sk-), masked in summary display - Conditional prompts: stdio skips host/port, OCR disabled skips language/DPI - Added 19 unit tests in tests/test_wizard.py Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…tion - Added --interactive / -i flag to init subparser - Refactored cmd_init into _cmd_init_scaffold and _cmd_init_interactive - Lazy import of interactive module (only when --interactive is used) - WizardCancelledError caught with exit code 130 and friendly message - Fixed existing test_cli.py tests to set args.interactive = False - Added 11 unit tests in tests/test_cli_init.py Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add _int_prompt() with validation loop for numeric inputs (prevents ValueError crash on non-numeric input in chunk size, port, DPI) - Safe key masking in summary (handles keys shorter than 12 chars) - Set .env file permissions to 0o600 (owner-only) after write - Extract _write_env() helper to avoid duplication Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add run_post_setup() to offer PDF ingestion and config generation after wizard - Extract build_config_snippet() and client constants as shared helpers - Add wizard_result_to_settings() to construct ServerSettings from wizard values - Refactor cli.py cmd_config() to reuse shared helpers (no duplication) - Added 17 unit tests covering all post-setup scenarios - Updated test_cli_init.py to mock new run_post_setup call Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Changed sk- prefix validation from hard-rejection to warning with confirmation (supports Azure OpenAI, Groq, and other OpenAI-compatible providers) - Fixed version test assertion (0.3.0 → 0.4.0) - Added test for non-sk key acceptance when user confirms - Fixed ruff import ordering in wizard_result_to_settings Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… post-setup Match the behavior of discover_pdfs() which uses **/*.pdf to find PDFs in subdirectories. The shallow *.pdf glob would miss nested PDFs and incorrectly skip the ingestion offer. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Version assertion now uses __version__ instead of hardcoded string. TestCmdConfig gets an autouse fixture to set OPENAI_API_KEY so get_settings() succeeds in CI where no .env file exists. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pdf2mcp init -i): 6-step guided flow collecting all configuration (API key, docs dir, embedding settings, server settings, OCR) with Rich TUI promptsTest plan
pdf2mcp init -i ./test-projectand walk through all 6 wizard steps.envis created with correct values and0600permissionspdf2mcp init ./test-project(non-interactive) still works🤖 Generated with Claude Code