Skip to main content

ALiCE — AI research uility for the Johns Hopkins Libraries

Project description

alice-cli

PyPI version Python versions License: MIT CI codecov

CLI for the ALICE (AWS Language Intelligence and Cognitive Exploration) project at Johns Hopkins. Manages Bedrock credentials, invokes LLMs, and provides AI research utilities.

Built with Click, boto3, Rich, and Textual. Packaged with Poetry.

Prerequisites

  • Python 3.12+
  • AWS CLI configured with an SSO profile (e.g. drcc-ai)
  • Active SSO session: aws sso login --profile <PROFILE>

Installation

cd alice-cli

# Standard
poetry install

# With TUI support
poetry install --extras tui

# With AgentCore support
poetry install --extras agentcore

# pipx (isolated, recommended for CLI tools)
pipx install .
pipx install ".[tui]"

The alice command is available on your PATH after installation.

One-off use without installing:

uvx --from ./alice-cli alice env --profile myprofile

Getting started

1. Authenticate

alice auth --profile <PROFILE>

Detects your JHED from the SSO session, fetches your Bedrock API key from Secrets Manager, and saves credentials (including per-user inference profile ARNs) to ~/.alice/credentials.json. Most commands work without --profile after this.

2. Verify

alice status

Shows SSO session state, identity, region, and namespace.

3. Export credentials

# Load credentials into your current shell
eval $(alice env --eval)

# .env file format
alice env --env-file

# Raw JSON
alice env --json

Output to stdout. Status messages to stderr, so piping and eval work correctly.

Using with Claude Code

alice auth --profile <PROFILE> --claude

Fetches credentials, sets all required environment variables (including per-user inference profile ARNs for Opus, Sonnet, Haiku), and execs into claude. After the first run, you can use just:

alice auth --claude

API key mode

Skip SSO entirely with a Bedrock API key:

alice auth --api-key <SECRET_KEY>
# or
export BEDROCK_SECRET_KEY="ABSK..."
export BEDROCK_ACCESS_KEY="BedrockAPIKey-yourjhed-at-123456789012"

Note: inference profile ARNs require at least one prior alice auth --profile run.

Invoking models

alice invoke "Explain the Krebs cycle"
alice invoke --model-id opus "Summarize this paper"
alice chat
alice chat --model-id nova-pro

Default model: sonnetus.anthropic.claude-sonnet-4-6.

alice list-aliases   # show all aliases (sonnet, opus, haiku, nova-pro, deepseek-r1, etc.)
alice list-models    # list Bedrock foundation models

Multi-model commands

# Compare responses from multiple models
alice compare "What is entropy?" --models sonnet,nova-pro,mistral-large

# Watch two models debate each other
alice dialog "What is the best programming language?" --models sonnet,nova-pro

# Process many prompts from a CSV
alice batch prompts.csv

# Summarize a file or stdin
alice summarize paper.pdf
cat notes.txt | alice summarize -

Session history

alice recall              # browse all sessions
alice recall --type chat  # filter by type
alice recall --model sonnet
alice appraise            # view token usage and costs

Sessions are stored in S3 (CloudLocker) with local fallback under ~/.alice/locker/.

Secrets

alice get-secret                  # your own Bedrock API key secret
alice get-secret myapp-config     # short name (auto-prefixes namespace/environment)
alice list-secrets                # list all secrets under namespace/environment

Quota

alice quota
alice quota --jhed someuser

View token usage and remaining quota from the Cheshire Gate tracking table.

AWS CLI passthrough

alice run s3 ls
alice run secretsmanager list-secrets

Injects --region and --profile from alice context if not already present.

Configuration

alice config    # show resolved config and sources

Precedence: CLI flag > environment variable > stored credentials > default.

Setting Default Env var CLI flag
Profile AWS_PROFILE --profile
Region us-east-1 --region
Namespace drcc ALICE_NAMESPACE --namespace
Environment ai ALICE_ENVIRONMENT --environment
API key BEDROCK_SECRET_KEY --api-key

Command reference

Command Description
alice auth Authenticate and store credentials
alice auth --claude Authenticate and launch Claude Code
alice env Export Bedrock credentials for shell use
alice invoke <prompt> Invoke a Bedrock model
alice chat Multi-turn conversation
alice batch <file> Batch prompts from CSV
alice compare <prompt> Compare responses across models
alice dialog <prompt> Two-model conversation
alice summarize [file] Summarize file or stdin
alice appraise View token usage and session costs
alice recall Browse session history
alice quota View token quota
alice compose AgentCore agent wizard
alice get-secret [name] Retrieve a secret
alice list-secrets List secrets in namespace
alice list-aliases Show model alias mappings
alice list-models List Bedrock foundation models
alice run <args> AWS CLI passthrough
alice config Show configuration
alice status Health check
alice diagnose Diagnostic checks
alice install-completion Install shell tab completion

Global options

Option Default Description
--profile $AWS_PROFILE AWS CLI profile
--region us-east-1 AWS region
--namespace drcc Resource namespace
--environment ai Deployment environment
--api-key $BEDROCK_SECRET_KEY Bedrock API key (skips SSO)
--quiet off Suppress banner and status messages
--debug off Enable structured debug logging to stderr
--personality alice Voice personality (alice, mr_rogers, shodan)
--tui off Launch interactive TUI
--version Print version and exit

TUI mode

alice --tui

Full-screen terminal UI built with Textual. Amber-on-black retro CRT aesthetic. Arrow keys to navigate, Enter to select, Escape to go back, q to quit.

Requires: poetry install --extras tui

Recommended font: Source Code Pro or Fira Code for the intended look.

Shell completion

alice install-completion

Installs tab completion for bash, zsh, fish, or PowerShell. Restart your shell or source the config file shown.

Project structure

alice-cli/
├── pyproject.toml
├── poetry.lock
└── src/alice_cli/
    ├── cli.py              # Click group, global options, command registration
    ├── commands/           # One file per verb (20+ commands)
    ├── auth.py             # JHED detection from STS
    ├── secrets.py          # Secrets Manager retrieval
    ├── config.py           # Configuration resolution and precedence
    ├── store.py            # Persistent credential storage (~/.alice/)
    ├── locker.py           # CloudLocker (S3 + local session storage)
    ├── session_record.py   # Session serialization
    ├── error_handler.py    # AWS error extraction and user-friendly messages
    ├── retry.py            # Tenacity retry decorators for AWS calls
    ├── logging.py          # Structlog configuration (--debug mode)
    ├── console.py          # Rich stderr helpers
    ├── personality.py      # All user-facing text and messaging
    ├── models.py           # Dataclasses, enums, model aliases
    ├── errors.py           # Error hierarchy
    ├── formatting.py       # Output formatters (export, eval, dotenv, json)
    ├── validators.py       # Dependency checks
    ├── pricing.py          # Model pricing table
    ├── agentcore_config.py # AgentCore runtime config persistence
    └── tui/                # Optional Textual TUI
        ├── app.py
        ├── theme.py
        ├── screens/
        └── widgets/

Development

cd alice-cli
poetry install --extras tui

# Tests
poetry run pytest
poetry run pytest -v
poetry run pytest tests/test_auth.py

# Lint and format
poetry run ruff check .
poetry run ruff format .
poetry run ruff check --fix .

# Type checking (strict mode)
poetry run mypy src/

# Benchmarks
poetry run pytest tests/benchmarks/ --benchmark-only

# Changelog (towncrier)
echo "Add my feature" > changes/123.feature.md
poetry run towncrier build --version 0.1.5 --draft

Test infrastructure: pytest + Hypothesis (property-based) + moto (AWS service mocking) + pytest-benchmark (performance regression).

Dev tooling: ruff, mypy strict, bandit (security linting), pre-commit hooks.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alice_cli-0.2.2.tar.gz (117.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

alice_cli-0.2.2-py3-none-any.whl (164.9 kB view details)

Uploaded Python 3

File details

Details for the file alice_cli-0.2.2.tar.gz.

File metadata

  • Download URL: alice_cli-0.2.2.tar.gz
  • Upload date:
  • Size: 117.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.14.3 Darwin/25.4.0

File hashes

Hashes for alice_cli-0.2.2.tar.gz
Algorithm Hash digest
SHA256 ffcb1acddc47faf67d50a85141b06deea0109c9433d747642a23c5a51c40a76a
MD5 c2ff8e10f4c1370f8c9c0104a0091b34
BLAKE2b-256 5990e965f7d8558040227b25b0c01a662d36299e1baeafbaeef8142abfd0e17d

See more details on using hashes here.

File details

Details for the file alice_cli-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: alice_cli-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 164.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.14.3 Darwin/25.4.0

File hashes

Hashes for alice_cli-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 71f8ae32dbc40236650588181f5c04f54740877db117867e388b9732fda56720
MD5 9f44610565fb91614e3b9bbe63e81640
BLAKE2b-256 a67730d1d116f9055055165cdc7f38d952c74cc0d304fcad5fce1d19f1257e98

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page