alice-cli 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- alice_cli-0.1.0/PKG-INFO +309 -0
- alice_cli-0.1.0/README.md +289 -0
- alice_cli-0.1.0/pyproject.toml +49 -0
- alice_cli-0.1.0/src/alice_cli/.kiro/settings/lsp.json +198 -0
- alice_cli-0.1.0/src/alice_cli/__init__.py +1 -0
- alice_cli-0.1.0/src/alice_cli/auth.py +64 -0
- alice_cli-0.1.0/src/alice_cli/cli.py +98 -0
- alice_cli-0.1.0/src/alice_cli/commands/__init__.py +1 -0
- alice_cli-0.1.0/src/alice_cli/commands/appraise.py +213 -0
- alice_cli-0.1.0/src/alice_cli/commands/auth.py +197 -0
- alice_cli-0.1.0/src/alice_cli/commands/batch.py +364 -0
- alice_cli-0.1.0/src/alice_cli/commands/chat.py +229 -0
- alice_cli-0.1.0/src/alice_cli/commands/compare.py +310 -0
- alice_cli-0.1.0/src/alice_cli/commands/compose.py +266 -0
- alice_cli-0.1.0/src/alice_cli/commands/config_cmd.py +60 -0
- alice_cli-0.1.0/src/alice_cli/commands/diagnose.py +325 -0
- alice_cli-0.1.0/src/alice_cli/commands/dialog.py +240 -0
- alice_cli-0.1.0/src/alice_cli/commands/get_key.py +51 -0
- alice_cli-0.1.0/src/alice_cli/commands/get_secret.py +87 -0
- alice_cli-0.1.0/src/alice_cli/commands/invoke.py +124 -0
- alice_cli-0.1.0/src/alice_cli/commands/list_aliases.py +24 -0
- alice_cli-0.1.0/src/alice_cli/commands/list_models.py +49 -0
- alice_cli-0.1.0/src/alice_cli/commands/list_secrets.py +77 -0
- alice_cli-0.1.0/src/alice_cli/commands/recall.py +229 -0
- alice_cli-0.1.0/src/alice_cli/commands/run.py +44 -0
- alice_cli-0.1.0/src/alice_cli/commands/status.py +46 -0
- alice_cli-0.1.0/src/alice_cli/commands/summarize.py +173 -0
- alice_cli-0.1.0/src/alice_cli/compose_engine.py +125 -0
- alice_cli-0.1.0/src/alice_cli/config.py +90 -0
- alice_cli-0.1.0/src/alice_cli/console.py +71 -0
- alice_cli-0.1.0/src/alice_cli/errors.py +40 -0
- alice_cli-0.1.0/src/alice_cli/formatting.py +56 -0
- alice_cli-0.1.0/src/alice_cli/locker.py +338 -0
- alice_cli-0.1.0/src/alice_cli/logo.py +29 -0
- alice_cli-0.1.0/src/alice_cli/models.py +252 -0
- alice_cli-0.1.0/src/alice_cli/personality.py +174 -0
- alice_cli-0.1.0/src/alice_cli/pricing.py +33 -0
- alice_cli-0.1.0/src/alice_cli/py.typed +1 -0
- alice_cli-0.1.0/src/alice_cli/save.py +173 -0
- alice_cli-0.1.0/src/alice_cli/secrets.py +89 -0
- alice_cli-0.1.0/src/alice_cli/session_record.py +84 -0
- alice_cli-0.1.0/src/alice_cli/store.py +53 -0
- alice_cli-0.1.0/src/alice_cli/tui/__init__.py +1 -0
- alice_cli-0.1.0/src/alice_cli/tui/app.py +102 -0
- alice_cli-0.1.0/src/alice_cli/tui/screens/__init__.py +1 -0
- alice_cli-0.1.0/src/alice_cli/tui/screens/compose.py +365 -0
- alice_cli-0.1.0/src/alice_cli/tui/screens/get_key.py +88 -0
- alice_cli-0.1.0/src/alice_cli/tui/screens/get_secret.py +111 -0
- alice_cli-0.1.0/src/alice_cli/tui/screens/home.py +92 -0
- alice_cli-0.1.0/src/alice_cli/tui/screens/invoke.py +99 -0
- alice_cli-0.1.0/src/alice_cli/tui/screens/quit.py +112 -0
- alice_cli-0.1.0/src/alice_cli/tui/screens/status.py +119 -0
- alice_cli-0.1.0/src/alice_cli/tui/theme.py +12 -0
- alice_cli-0.1.0/src/alice_cli/tui/theme.tcss +219 -0
- alice_cli-0.1.0/src/alice_cli/tui/widgets/__init__.py +1 -0
- alice_cli-0.1.0/src/alice_cli/tui/widgets/banner.py +76 -0
- alice_cli-0.1.0/src/alice_cli/tui/widgets/clock.py +41 -0
- alice_cli-0.1.0/src/alice_cli/tui/widgets/header_bar.py +26 -0
- alice_cli-0.1.0/src/alice_cli/tui/widgets/output.py +11 -0
- alice_cli-0.1.0/src/alice_cli/tui/widgets/typewriter.py +43 -0
- alice_cli-0.1.0/src/alice_cli/validators.py +36 -0
alice_cli-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: alice-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: ALiCE — Your AI research companion at Johns Hopkins
|
|
5
|
+
Author: JH DRCC
|
|
6
|
+
Requires-Python: >=3.12,<4.0
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
11
|
+
Provides-Extra: tui
|
|
12
|
+
Requires-Dist: boto3 (>=1.35,<2.0)
|
|
13
|
+
Requires-Dist: click (>=8.1,<9.0)
|
|
14
|
+
Requires-Dist: filelock (>=3.0,<4.0)
|
|
15
|
+
Requires-Dist: prompt-toolkit (>=3.0,<4.0)
|
|
16
|
+
Requires-Dist: rich (>=13.0,<14.0)
|
|
17
|
+
Requires-Dist: textual (>=1.0,<2.0) ; extra == "tui"
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# alice-cli
|
|
21
|
+
|
|
22
|
+
Python CLI for the ALICE (Artificial Language Intelligence and Cognitive Exploration) project at Johns Hopkins. A unified tool for Bedrock credential management, model invocation, secrets operations, and AWS passthrough.
|
|
23
|
+
|
|
24
|
+
Built with Click, boto3, and Rich. Packaged with Poetry. Runs with `uv`/`uvx`.
|
|
25
|
+
|
|
26
|
+
## Prerequisites
|
|
27
|
+
|
|
28
|
+
- Python 3.12+
|
|
29
|
+
- AWS CLI configured with an SSO profile (e.g. `drcc-ai`)
|
|
30
|
+
- Active SSO session: `aws sso login --profile <PROFILE>`
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
cd alice-cli
|
|
36
|
+
|
|
37
|
+
# Poetry (standard)
|
|
38
|
+
poetry install
|
|
39
|
+
|
|
40
|
+
# uv
|
|
41
|
+
uv pip install .
|
|
42
|
+
|
|
43
|
+
# With TUI support
|
|
44
|
+
poetry install --extras tui
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
After installation, the `alice` command is available on your PATH.
|
|
48
|
+
|
|
49
|
+
For one-off usage without installing:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
uvx --from ./alice-cli alice get-key --profile myprofile
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Getting started
|
|
56
|
+
|
|
57
|
+
### 1. Authenticate
|
|
58
|
+
|
|
59
|
+
Run `alice auth` with your AWS SSO profile to validate your identity and store your Bedrock API key credentials locally:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
alice auth --profile <PROFILE>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
This detects your JHED from the SSO session, fetches your Bedrock API key from Secrets Manager, and saves everything (including your per-user inference profile ARNs) to `~/.alice/credentials.json`.
|
|
66
|
+
|
|
67
|
+
After this initial auth, most commands work without `--profile` because the stored credentials are used automatically.
|
|
68
|
+
|
|
69
|
+
### 2. Verify your setup
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
alice status
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Shows your SSO session state, identity, region, and namespace.
|
|
76
|
+
|
|
77
|
+
### 3. Get your Bedrock API key
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Print export statements (default)
|
|
81
|
+
alice get-key
|
|
82
|
+
|
|
83
|
+
# Load credentials into your current shell
|
|
84
|
+
eval $(alice get-key --eval)
|
|
85
|
+
|
|
86
|
+
# .env file format
|
|
87
|
+
alice get-key --env-file
|
|
88
|
+
|
|
89
|
+
# Raw JSON from Secrets Manager
|
|
90
|
+
alice get-key --json
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Output goes to stdout. Banners and status messages go to stderr, so piping and `eval` work correctly.
|
|
94
|
+
|
|
95
|
+
The credential set includes: `AWS_BEARER_TOKEN_BEDROCK`, `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `BEDROCK_ACCESS_KEY`, `BEDROCK_SECRET_KEY`, `AWS_REGION`, `CLAUDE_CODE_USE_BEDROCK`, `ANTHROPIC_MODEL`, and the `ANTHROPIC_DEFAULT_*_MODEL` inference profile vars.
|
|
96
|
+
|
|
97
|
+
## Using with Claude Code
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
alice auth --profile <PROFILE> --claude
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
This retrieves your credentials, sets all required environment variables (including your per-user application inference profile ARNs for Opus, Sonnet, and Haiku), and `exec`s into `claude`. Requires `claude` on your PATH.
|
|
104
|
+
|
|
105
|
+
Once you've authenticated with `--profile` at least once, you can launch Claude using just your stored API key:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
alice auth --claude
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## API key mode
|
|
112
|
+
|
|
113
|
+
If you have a Bedrock API key but no AWS SSO profile, you can use it directly:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
alice auth --api-key <SECRET_KEY>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Or set the environment variables:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
export BEDROCK_ACCESS_KEY="BedrockAPIKey-yourjhed-at-123456789012"
|
|
123
|
+
export BEDROCK_SECRET_KEY="ABSK..."
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
API key mode skips SSO and Secrets Manager entirely. Note that inference profile ARNs require at least one prior `alice auth --profile <PROFILE>` run to be stored — the API key alone cannot fetch them from Secrets Manager.
|
|
127
|
+
|
|
128
|
+
## Invoking models
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
alice invoke "Explain the Krebs cycle"
|
|
132
|
+
|
|
133
|
+
# Specify a model by alias
|
|
134
|
+
alice invoke --model-id claude-opus-4.6 "Hello"
|
|
135
|
+
|
|
136
|
+
# Or by full model ID
|
|
137
|
+
alice invoke --model-id us.anthropic.claude-sonnet-4-6 "Hello"
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Default model: `sonnet` → `us.anthropic.claude-sonnet-4-6`.
|
|
141
|
+
|
|
142
|
+
### Model aliases
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
alice list-aliases
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Shows all available short names (e.g. `sonnet`, `opus`, `haiku`, `nova-pro`, `deepseek-r1`) and their corresponding Bedrock model IDs.
|
|
149
|
+
|
|
150
|
+
### List foundation models
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
alice list-models
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Lists all available foundation models from the Bedrock API.
|
|
157
|
+
|
|
158
|
+
## Secrets operations
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# Get your own Bedrock API key secret
|
|
162
|
+
alice get-secret
|
|
163
|
+
|
|
164
|
+
# Get a secret by short name (auto-prefixes namespace/environment)
|
|
165
|
+
alice get-secret myapp-config
|
|
166
|
+
|
|
167
|
+
# List all secrets under the namespace/environment prefix
|
|
168
|
+
alice list-secrets
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## AWS CLI passthrough
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
alice run s3 ls
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Forwards arguments to `aws` and injects `--region` and `--profile` from the alice context if not already present.
|
|
178
|
+
|
|
179
|
+
## Configuration
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
# Show resolved config values and their sources
|
|
183
|
+
alice config
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Defaults can be overridden with CLI flags, environment variables, or stored credentials. Precedence: CLI flag > environment variable > stored credentials > default.
|
|
187
|
+
|
|
188
|
+
| Setting | Default | Env var | CLI flag |
|
|
189
|
+
|---|---|---|---|
|
|
190
|
+
| Profile | — | `AWS_PROFILE` | `--profile` |
|
|
191
|
+
| Region | `us-east-1` | — | `--region` |
|
|
192
|
+
| Namespace | `drcc` | `ALICE_NAMESPACE` | `--namespace` |
|
|
193
|
+
| Environment | `ai` | `ALICE_ENVIRONMENT` | `--environment` |
|
|
194
|
+
| API key | — | `BEDROCK_SECRET_KEY` | `--api-key` |
|
|
195
|
+
|
|
196
|
+
## Command reference
|
|
197
|
+
|
|
198
|
+
| Command | Description |
|
|
199
|
+
|---|---|
|
|
200
|
+
| `alice auth` | Authenticate and store credentials |
|
|
201
|
+
| `alice auth --claude` | Authenticate and launch Claude Code |
|
|
202
|
+
| `alice get-key` | Print Bedrock credentials for shell export |
|
|
203
|
+
| `alice get-secret [name]` | Retrieve a secret (defaults to your own) |
|
|
204
|
+
| `alice list-secrets` | List secrets under your namespace |
|
|
205
|
+
| `alice invoke <prompt>` | Invoke a Bedrock model |
|
|
206
|
+
| `alice list-aliases` | Show model alias → model ID mappings |
|
|
207
|
+
| `alice list-models` | List available Bedrock foundation models |
|
|
208
|
+
| `alice run <args>` | AWS CLI passthrough |
|
|
209
|
+
| `alice config` | Show resolved configuration |
|
|
210
|
+
| `alice status` | Health check (SSO, identity, region) |
|
|
211
|
+
|
|
212
|
+
### Global options
|
|
213
|
+
|
|
214
|
+
| Option | Default | Description |
|
|
215
|
+
|---|---|---|
|
|
216
|
+
| `--profile` | `$AWS_PROFILE` | AWS CLI profile |
|
|
217
|
+
| `--region` | `us-east-1` | AWS region |
|
|
218
|
+
| `--namespace` | `drcc` | Resource namespace |
|
|
219
|
+
| `--environment` | `ai` | Deployment environment |
|
|
220
|
+
| `--api-key` | `$BEDROCK_SECRET_KEY` | Bedrock API key (skips SSO) |
|
|
221
|
+
| `--quiet` | off | Suppress banner and status messages |
|
|
222
|
+
| `--tui` | off | Launch interactive TUI mode |
|
|
223
|
+
| `--version` | — | Print version and exit |
|
|
224
|
+
|
|
225
|
+
## TUI mode
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
alice --tui
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Launches a full-screen terminal interface built with Textual. Amber-on-black retro CRT aesthetic. Keyboard-driven: arrow keys to navigate, Enter to select, Escape to go back, `q` to quit.
|
|
232
|
+
|
|
233
|
+
Requires the `tui` extra: `poetry install --extras tui`
|
|
234
|
+
|
|
235
|
+
### Recommended terminal font
|
|
236
|
+
|
|
237
|
+
For the intended look, set your terminal emulator's font to **Source Code Pro** or **Fira Code**. Both are free, open-source monospace fonts that pair well with the JHU brand palette. The TUI will display a hint on startup if it detects a different font (macOS only).
|
|
238
|
+
|
|
239
|
+
- [Source Code Pro](https://github.com/adobe-fonts/source-code-pro) — Adobe's monospace companion to Source Sans/Serif
|
|
240
|
+
- [Fira Code](https://github.com/tonsky/FiraCode) — monospace with programming ligatures
|
|
241
|
+
|
|
242
|
+
## How JHED detection works
|
|
243
|
+
|
|
244
|
+
The CLI detects your JHED automatically from your active SSO session. It calls `sts get-caller-identity`, parses the assumed-role ARN to extract the session name (an email address), and takes the portion before `@` as your JHED.
|
|
245
|
+
|
|
246
|
+
Secrets are keyed by `{namespace}/{environment}/bedrock-api-keys/{jhed}@jhu.edu`.
|
|
247
|
+
|
|
248
|
+
## Project structure
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
alice-cli/
|
|
252
|
+
├── pyproject.toml
|
|
253
|
+
├── poetry.lock
|
|
254
|
+
└── src/alice_cli/
|
|
255
|
+
├── cli.py # Click group, global options, command registration
|
|
256
|
+
├── commands/
|
|
257
|
+
│ ├── auth.py # alice auth [--claude]
|
|
258
|
+
│ ├── get_key.py # alice get-key [--eval|--env-file|--json]
|
|
259
|
+
│ ├── invoke.py # alice invoke
|
|
260
|
+
│ ├── list_models.py # alice list-models
|
|
261
|
+
│ ├── list_aliases.py # alice list-aliases
|
|
262
|
+
│ ├── get_secret.py # alice get-secret [name]
|
|
263
|
+
│ ├── list_secrets.py # alice list-secrets
|
|
264
|
+
│ ├── run.py # alice run <aws args...>
|
|
265
|
+
│ ├── config_cmd.py # alice config
|
|
266
|
+
│ └── status.py # alice status
|
|
267
|
+
├── auth.py # JHED detection from STS
|
|
268
|
+
├── secrets.py # Secrets Manager retrieval and validation
|
|
269
|
+
├── formatting.py # Output formatters (export, eval, dotenv, json)
|
|
270
|
+
├── config.py # Configuration resolution and precedence
|
|
271
|
+
├── store.py # Persistent credential storage (~/.alice/)
|
|
272
|
+
├── console.py # Rich console helpers (stderr output)
|
|
273
|
+
├── personality.py # All user-facing text and messaging
|
|
274
|
+
├── validators.py # Dependency checks (aws, jq, python version)
|
|
275
|
+
├── models.py # Dataclasses, enums, model aliases
|
|
276
|
+
├── errors.py # Error hierarchy (AuthError, SecretError, DependencyError)
|
|
277
|
+
└── tui/ # Optional Textual TUI (requires extras)
|
|
278
|
+
├── app.py
|
|
279
|
+
├── theme.py
|
|
280
|
+
├── theme.tcss
|
|
281
|
+
├── screens/
|
|
282
|
+
└── widgets/
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## Development
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
cd alice-cli
|
|
289
|
+
poetry install --extras tui
|
|
290
|
+
|
|
291
|
+
# Run tests
|
|
292
|
+
poetry run pytest
|
|
293
|
+
|
|
294
|
+
# Lint and format
|
|
295
|
+
poetry run ruff check .
|
|
296
|
+
poetry run ruff format .
|
|
297
|
+
|
|
298
|
+
# Type checking
|
|
299
|
+
poetry run mypy src/
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
Dev dependencies: pytest, hypothesis, pytest-mock, ruff, mypy, boto3-stubs.
|
|
303
|
+
|
|
304
|
+
Tests use Hypothesis for property-based testing (format correctness, config precedence, JHED extraction, secret path construction, AWS passthrough argument forwarding) alongside standard unit tests for error conditions and edge cases.
|
|
305
|
+
|
|
306
|
+
## License
|
|
307
|
+
|
|
308
|
+
[MIT](../LICENSE)
|
|
309
|
+
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
# alice-cli
|
|
2
|
+
|
|
3
|
+
Python CLI for the ALICE (Artificial Language Intelligence and Cognitive Exploration) project at Johns Hopkins. A unified tool for Bedrock credential management, model invocation, secrets operations, and AWS passthrough.
|
|
4
|
+
|
|
5
|
+
Built with Click, boto3, and Rich. Packaged with Poetry. Runs with `uv`/`uvx`.
|
|
6
|
+
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
- Python 3.12+
|
|
10
|
+
- AWS CLI configured with an SSO profile (e.g. `drcc-ai`)
|
|
11
|
+
- Active SSO session: `aws sso login --profile <PROFILE>`
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
cd alice-cli
|
|
17
|
+
|
|
18
|
+
# Poetry (standard)
|
|
19
|
+
poetry install
|
|
20
|
+
|
|
21
|
+
# uv
|
|
22
|
+
uv pip install .
|
|
23
|
+
|
|
24
|
+
# With TUI support
|
|
25
|
+
poetry install --extras tui
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
After installation, the `alice` command is available on your PATH.
|
|
29
|
+
|
|
30
|
+
For one-off usage without installing:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
uvx --from ./alice-cli alice get-key --profile myprofile
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Getting started
|
|
37
|
+
|
|
38
|
+
### 1. Authenticate
|
|
39
|
+
|
|
40
|
+
Run `alice auth` with your AWS SSO profile to validate your identity and store your Bedrock API key credentials locally:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
alice auth --profile <PROFILE>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
This detects your JHED from the SSO session, fetches your Bedrock API key from Secrets Manager, and saves everything (including your per-user inference profile ARNs) to `~/.alice/credentials.json`.
|
|
47
|
+
|
|
48
|
+
After this initial auth, most commands work without `--profile` because the stored credentials are used automatically.
|
|
49
|
+
|
|
50
|
+
### 2. Verify your setup
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
alice status
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Shows your SSO session state, identity, region, and namespace.
|
|
57
|
+
|
|
58
|
+
### 3. Get your Bedrock API key
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Print export statements (default)
|
|
62
|
+
alice get-key
|
|
63
|
+
|
|
64
|
+
# Load credentials into your current shell
|
|
65
|
+
eval $(alice get-key --eval)
|
|
66
|
+
|
|
67
|
+
# .env file format
|
|
68
|
+
alice get-key --env-file
|
|
69
|
+
|
|
70
|
+
# Raw JSON from Secrets Manager
|
|
71
|
+
alice get-key --json
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Output goes to stdout. Banners and status messages go to stderr, so piping and `eval` work correctly.
|
|
75
|
+
|
|
76
|
+
The credential set includes: `AWS_BEARER_TOKEN_BEDROCK`, `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `BEDROCK_ACCESS_KEY`, `BEDROCK_SECRET_KEY`, `AWS_REGION`, `CLAUDE_CODE_USE_BEDROCK`, `ANTHROPIC_MODEL`, and the `ANTHROPIC_DEFAULT_*_MODEL` inference profile vars.
|
|
77
|
+
|
|
78
|
+
## Using with Claude Code
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
alice auth --profile <PROFILE> --claude
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
This retrieves your credentials, sets all required environment variables (including your per-user application inference profile ARNs for Opus, Sonnet, and Haiku), and `exec`s into `claude`. Requires `claude` on your PATH.
|
|
85
|
+
|
|
86
|
+
Once you've authenticated with `--profile` at least once, you can launch Claude using just your stored API key:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
alice auth --claude
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## API key mode
|
|
93
|
+
|
|
94
|
+
If you have a Bedrock API key but no AWS SSO profile, you can use it directly:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
alice auth --api-key <SECRET_KEY>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Or set the environment variables:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
export BEDROCK_ACCESS_KEY="BedrockAPIKey-yourjhed-at-123456789012"
|
|
104
|
+
export BEDROCK_SECRET_KEY="ABSK..."
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
API key mode skips SSO and Secrets Manager entirely. Note that inference profile ARNs require at least one prior `alice auth --profile <PROFILE>` run to be stored — the API key alone cannot fetch them from Secrets Manager.
|
|
108
|
+
|
|
109
|
+
## Invoking models
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
alice invoke "Explain the Krebs cycle"
|
|
113
|
+
|
|
114
|
+
# Specify a model by alias
|
|
115
|
+
alice invoke --model-id claude-opus-4.6 "Hello"
|
|
116
|
+
|
|
117
|
+
# Or by full model ID
|
|
118
|
+
alice invoke --model-id us.anthropic.claude-sonnet-4-6 "Hello"
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Default model: `sonnet` → `us.anthropic.claude-sonnet-4-6`.
|
|
122
|
+
|
|
123
|
+
### Model aliases
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
alice list-aliases
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Shows all available short names (e.g. `sonnet`, `opus`, `haiku`, `nova-pro`, `deepseek-r1`) and their corresponding Bedrock model IDs.
|
|
130
|
+
|
|
131
|
+
### List foundation models
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
alice list-models
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Lists all available foundation models from the Bedrock API.
|
|
138
|
+
|
|
139
|
+
## Secrets operations
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# Get your own Bedrock API key secret
|
|
143
|
+
alice get-secret
|
|
144
|
+
|
|
145
|
+
# Get a secret by short name (auto-prefixes namespace/environment)
|
|
146
|
+
alice get-secret myapp-config
|
|
147
|
+
|
|
148
|
+
# List all secrets under the namespace/environment prefix
|
|
149
|
+
alice list-secrets
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## AWS CLI passthrough
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
alice run s3 ls
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Forwards arguments to `aws` and injects `--region` and `--profile` from the alice context if not already present.
|
|
159
|
+
|
|
160
|
+
## Configuration
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# Show resolved config values and their sources
|
|
164
|
+
alice config
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Defaults can be overridden with CLI flags, environment variables, or stored credentials. Precedence: CLI flag > environment variable > stored credentials > default.
|
|
168
|
+
|
|
169
|
+
| Setting | Default | Env var | CLI flag |
|
|
170
|
+
|---|---|---|---|
|
|
171
|
+
| Profile | — | `AWS_PROFILE` | `--profile` |
|
|
172
|
+
| Region | `us-east-1` | — | `--region` |
|
|
173
|
+
| Namespace | `drcc` | `ALICE_NAMESPACE` | `--namespace` |
|
|
174
|
+
| Environment | `ai` | `ALICE_ENVIRONMENT` | `--environment` |
|
|
175
|
+
| API key | — | `BEDROCK_SECRET_KEY` | `--api-key` |
|
|
176
|
+
|
|
177
|
+
## Command reference
|
|
178
|
+
|
|
179
|
+
| Command | Description |
|
|
180
|
+
|---|---|
|
|
181
|
+
| `alice auth` | Authenticate and store credentials |
|
|
182
|
+
| `alice auth --claude` | Authenticate and launch Claude Code |
|
|
183
|
+
| `alice get-key` | Print Bedrock credentials for shell export |
|
|
184
|
+
| `alice get-secret [name]` | Retrieve a secret (defaults to your own) |
|
|
185
|
+
| `alice list-secrets` | List secrets under your namespace |
|
|
186
|
+
| `alice invoke <prompt>` | Invoke a Bedrock model |
|
|
187
|
+
| `alice list-aliases` | Show model alias → model ID mappings |
|
|
188
|
+
| `alice list-models` | List available Bedrock foundation models |
|
|
189
|
+
| `alice run <args>` | AWS CLI passthrough |
|
|
190
|
+
| `alice config` | Show resolved configuration |
|
|
191
|
+
| `alice status` | Health check (SSO, identity, region) |
|
|
192
|
+
|
|
193
|
+
### Global options
|
|
194
|
+
|
|
195
|
+
| Option | Default | Description |
|
|
196
|
+
|---|---|---|
|
|
197
|
+
| `--profile` | `$AWS_PROFILE` | AWS CLI profile |
|
|
198
|
+
| `--region` | `us-east-1` | AWS region |
|
|
199
|
+
| `--namespace` | `drcc` | Resource namespace |
|
|
200
|
+
| `--environment` | `ai` | Deployment environment |
|
|
201
|
+
| `--api-key` | `$BEDROCK_SECRET_KEY` | Bedrock API key (skips SSO) |
|
|
202
|
+
| `--quiet` | off | Suppress banner and status messages |
|
|
203
|
+
| `--tui` | off | Launch interactive TUI mode |
|
|
204
|
+
| `--version` | — | Print version and exit |
|
|
205
|
+
|
|
206
|
+
## TUI mode
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
alice --tui
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Launches a full-screen terminal interface built with Textual. Amber-on-black retro CRT aesthetic. Keyboard-driven: arrow keys to navigate, Enter to select, Escape to go back, `q` to quit.
|
|
213
|
+
|
|
214
|
+
Requires the `tui` extra: `poetry install --extras tui`
|
|
215
|
+
|
|
216
|
+
### Recommended terminal font
|
|
217
|
+
|
|
218
|
+
For the intended look, set your terminal emulator's font to **Source Code Pro** or **Fira Code**. Both are free, open-source monospace fonts that pair well with the JHU brand palette. The TUI will display a hint on startup if it detects a different font (macOS only).
|
|
219
|
+
|
|
220
|
+
- [Source Code Pro](https://github.com/adobe-fonts/source-code-pro) — Adobe's monospace companion to Source Sans/Serif
|
|
221
|
+
- [Fira Code](https://github.com/tonsky/FiraCode) — monospace with programming ligatures
|
|
222
|
+
|
|
223
|
+
## How JHED detection works
|
|
224
|
+
|
|
225
|
+
The CLI detects your JHED automatically from your active SSO session. It calls `sts get-caller-identity`, parses the assumed-role ARN to extract the session name (an email address), and takes the portion before `@` as your JHED.
|
|
226
|
+
|
|
227
|
+
Secrets are keyed by `{namespace}/{environment}/bedrock-api-keys/{jhed}@jhu.edu`.
|
|
228
|
+
|
|
229
|
+
## Project structure
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
alice-cli/
|
|
233
|
+
├── pyproject.toml
|
|
234
|
+
├── poetry.lock
|
|
235
|
+
└── src/alice_cli/
|
|
236
|
+
├── cli.py # Click group, global options, command registration
|
|
237
|
+
├── commands/
|
|
238
|
+
│ ├── auth.py # alice auth [--claude]
|
|
239
|
+
│ ├── get_key.py # alice get-key [--eval|--env-file|--json]
|
|
240
|
+
│ ├── invoke.py # alice invoke
|
|
241
|
+
│ ├── list_models.py # alice list-models
|
|
242
|
+
│ ├── list_aliases.py # alice list-aliases
|
|
243
|
+
│ ├── get_secret.py # alice get-secret [name]
|
|
244
|
+
│ ├── list_secrets.py # alice list-secrets
|
|
245
|
+
│ ├── run.py # alice run <aws args...>
|
|
246
|
+
│ ├── config_cmd.py # alice config
|
|
247
|
+
│ └── status.py # alice status
|
|
248
|
+
├── auth.py # JHED detection from STS
|
|
249
|
+
├── secrets.py # Secrets Manager retrieval and validation
|
|
250
|
+
├── formatting.py # Output formatters (export, eval, dotenv, json)
|
|
251
|
+
├── config.py # Configuration resolution and precedence
|
|
252
|
+
├── store.py # Persistent credential storage (~/.alice/)
|
|
253
|
+
├── console.py # Rich console helpers (stderr output)
|
|
254
|
+
├── personality.py # All user-facing text and messaging
|
|
255
|
+
├── validators.py # Dependency checks (aws, jq, python version)
|
|
256
|
+
├── models.py # Dataclasses, enums, model aliases
|
|
257
|
+
├── errors.py # Error hierarchy (AuthError, SecretError, DependencyError)
|
|
258
|
+
└── tui/ # Optional Textual TUI (requires extras)
|
|
259
|
+
├── app.py
|
|
260
|
+
├── theme.py
|
|
261
|
+
├── theme.tcss
|
|
262
|
+
├── screens/
|
|
263
|
+
└── widgets/
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## Development
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
cd alice-cli
|
|
270
|
+
poetry install --extras tui
|
|
271
|
+
|
|
272
|
+
# Run tests
|
|
273
|
+
poetry run pytest
|
|
274
|
+
|
|
275
|
+
# Lint and format
|
|
276
|
+
poetry run ruff check .
|
|
277
|
+
poetry run ruff format .
|
|
278
|
+
|
|
279
|
+
# Type checking
|
|
280
|
+
poetry run mypy src/
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
Dev dependencies: pytest, hypothesis, pytest-mock, ruff, mypy, boto3-stubs.
|
|
284
|
+
|
|
285
|
+
Tests use Hypothesis for property-based testing (format correctness, config precedence, JHED extraction, secret path construction, AWS passthrough argument forwarding) alongside standard unit tests for error conditions and edge cases.
|
|
286
|
+
|
|
287
|
+
## License
|
|
288
|
+
|
|
289
|
+
[MIT](../LICENSE)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "alice-cli"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "ALiCE — Your AI research companion at Johns Hopkins"
|
|
5
|
+
authors = ["JH DRCC"]
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
packages = [{include = "alice_cli", from = "src", format = ["sdist", "wheel"]}]
|
|
8
|
+
|
|
9
|
+
[tool.poetry.dependencies]
|
|
10
|
+
python = "^3.12"
|
|
11
|
+
click = "^8.1"
|
|
12
|
+
boto3 = "^1.35"
|
|
13
|
+
rich = "^13.0"
|
|
14
|
+
prompt-toolkit = "^3.0"
|
|
15
|
+
filelock = "^3.0"
|
|
16
|
+
textual = {version = "^1.0", optional = true}
|
|
17
|
+
|
|
18
|
+
[tool.poetry.extras]
|
|
19
|
+
tui = ["textual"]
|
|
20
|
+
|
|
21
|
+
[tool.poetry.group.dev.dependencies]
|
|
22
|
+
pytest = "^8.0"
|
|
23
|
+
hypothesis = "^6.0"
|
|
24
|
+
pytest-mock = "^3.0"
|
|
25
|
+
ruff = "^0.8"
|
|
26
|
+
mypy = "^1.13"
|
|
27
|
+
boto3-stubs = {extras = ["sts", "secretsmanager", "bedrock", "bedrock-runtime"], version = "^1.35"}
|
|
28
|
+
textual-dev = "^1.0"
|
|
29
|
+
|
|
30
|
+
[tool.poetry.scripts]
|
|
31
|
+
alice = "alice_cli.cli:cli"
|
|
32
|
+
|
|
33
|
+
[build-system]
|
|
34
|
+
requires = ["poetry-core"]
|
|
35
|
+
build-backend = "poetry.core.masonry.api"
|
|
36
|
+
|
|
37
|
+
[tool.ruff]
|
|
38
|
+
target-version = "py312"
|
|
39
|
+
line-length = 100
|
|
40
|
+
|
|
41
|
+
[tool.ruff.lint]
|
|
42
|
+
select = ["E", "F", "I", "N", "UP", "B", "SIM", "TCH"]
|
|
43
|
+
|
|
44
|
+
[tool.pytest.ini_options]
|
|
45
|
+
pythonpath = ["src"]
|
|
46
|
+
|
|
47
|
+
[tool.mypy]
|
|
48
|
+
python_version = "3.12"
|
|
49
|
+
strict = true
|