feat: add ask CLI command with streaming, encrypted token storage, and all extra#45
Merged
Merged
Conversation
…d all extra - New 'ask' subcommand for querying Perplexity AI from the terminal with real-time streaming output via Rich Live panels - New 'ask setup' subcommand for interactive token and model config - Encrypted token storage using Fernet + platformdirs - New 'all' optional dependency extra for one-liner installs - Added cryptography and platformdirs to cli extra - Model as second positional argument, anonymous mode by default - --raw/-r for piping, --copy/-cp for clipboard, --token/-t override - Restructured README and docs installation sections - Fixed Typer routing for 'ask setup' command
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new interactive terminal chat experience to the project’s Typer CLI, including token persistence, model selection, and updated packaging/docs for optional extras.
Changes:
- Introduces a new interactive
chatCLI (streaming output, REPL-style loop, clipboard copy, raw output). - Adds encrypted local token + default-model storage for the CLI via
cryptography+platformdirs. - Adds a new
allextra and updates docs/changelog/tests accordingly.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
uv.lock |
Adds all extra and includes cryptography/platformdirs under cli. |
tests/test_cli.py |
Extends CLI delegation tests to include the new chat command paths. |
src/perplexity_webui_scraper/cli/commands/chat.py |
Implements streaming chat/REPL command and interactive setup wizard. |
src/perplexity_webui_scraper/cli/commands/_token_store.py |
Implements Fernet-encrypted token + config persistence in user config dir. |
src/perplexity_webui_scraper/cli/__main__.py |
Registers the new chat Typer app and wires CLI options/args to handlers. |
README.md |
Updates installation guidance and CLI command table (but currently inconsistent with implemented command naming). |
pyproject.toml |
Adds cryptography/platformdirs to cli extra and introduces all meta-extra. |
docs/getting-started.md |
Restructures install instructions and references the new CLI command (currently naming mismatch). |
CHANGELOG.md |
Documents the new CLI command, setup wizard, all extra, and encrypted token storage (currently naming mismatch). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+17
to
+23
| chat_app = Typer( | ||
| name="chat", | ||
| help="Chat with Perplexity AI directly from the terminal.", | ||
| invoke_without_command=True, | ||
| no_args_is_help=False, | ||
| context_settings={"allow_interspersed_args": True}, | ||
| ) |
Comment on lines
+79
to
+86
| if ctx.invoked_subcommand is not None: | ||
| return | ||
|
|
||
| if query == "setup" and model is None: | ||
| from perplexity_webui_scraper.cli.commands.chat import setup as run_setup # noqa: PLC0415 | ||
|
|
||
| run_setup() | ||
| return |
Comment on lines
+216
to
+220
| current_token = load_token() | ||
| if current_token: | ||
| masked = current_token[:12] + "..." + current_token[-8:] | ||
| console.print(f" [green]✔ Token configured:[/green] [dim]{masked}[/dim]") | ||
|
|
Comment on lines
+124
to
+130
| | Command | Extra | Description | | ||
| | ------------------------------------ | ----- | ----------------------------------------------------------------------------- | | ||
| | `perplexity-webui-scraper token` | `cli` | Interactive email auth wizard to generate a session token (supports TOTP 2FA) | | ||
| | `perplexity-webui-scraper ask` | `cli` | Ask Perplexity AI questions with real-time streaming output | | ||
| | `perplexity-webui-scraper ask setup` | `cli` | Configure saved token and default model for the ask command | | ||
| | `perplexity-webui-scraper mcp` | `mcp` | Start the MCP server | | ||
| | `perplexity-webui-scraper api` | `api` | Start the OpenAI-compatible REST API server | |
Comment on lines
+27
to
+33
| ### Command Line Tools (CLI) | ||
|
|
||
| Install with the `cli` extra to use the `token` generator and the interactive `ask` command directly from your terminal. | ||
|
|
||
| ```bash | ||
| # From PyPI (stable) | ||
| uv add "perplexity-webui-scraper[cli]" |
Comment on lines
+18
to
+21
| - **`chat` CLI command:** New interactive REPL command `perplexity-webui-scraper chat "query"` for querying Perplexity AI directly from the terminal with real-time streaming token output via Rich Live panels. It maintains the conversation context until exited and features a clean, borderless UX inspired by Claude Code. Supports all `ConversationConfig` options as CLI arguments with short aliases, file attachments, clipboard copy, and raw output mode. | ||
| - **`chat setup` subcommand:** Interactive setup wizard that configures and saves the session token (Fernet-encrypted in the platform-specific config directory) and the default model. First-time users are guided to configure their token before using `chat`. | ||
| - **`all` optional dependency extra:** New `[all]` meta-extra that installs all optional dependencies (`cli`, `api`, `mcp`) in one go: `uv add "perplexity-webui-scraper[all]"`. | ||
| - **Encrypted token storage:** Session tokens are now encrypted with Fernet and stored in the platform-specific config directory (`platformdirs`). The `ask` command reads from this store automatically. |
| ) | ||
|
|
||
|
|
||
| def test_ask_setup_subcommand_delegates() -> None: |
Comment on lines
+51
to
+53
| all = [ | ||
| "perplexity-webui-scraper[cli,api,mcp]", | ||
| ] |
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.
with real-time streaming output via Rich Live panels