Skip to content

feat: add ask CLI command with streaming, encrypted token storage, and all extra#45

Merged
henrique-coder merged 3 commits into
prodfrom
feature/ask-cli-command
May 23, 2026
Merged

feat: add ask CLI command with streaming, encrypted token storage, and all extra#45
henrique-coder merged 3 commits into
prodfrom
feature/ask-cli-command

Conversation

@henrique-coder
Copy link
Copy Markdown
Owner

  • 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

…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
Copilot AI review requested due to automatic review settings May 23, 2026 05:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 chat CLI (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 all extra 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 thread README.md
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 thread docs/getting-started.md
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 thread CHANGELOG.md
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.
Comment thread tests/test_cli.py
)


def test_ask_setup_subcommand_delegates() -> None:
Comment thread pyproject.toml
Comment on lines +51 to +53
all = [
"perplexity-webui-scraper[cli,api,mcp]",
]
@henrique-coder henrique-coder merged commit 3953e72 into prod May 23, 2026
1 of 2 checks passed
@henrique-coder henrique-coder deleted the feature/ask-cli-command branch May 23, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants