Enhance user configuration management and logging
- Introduced user configuration command to set API key. - Updated README and documentation for user config and logging paths. - Refactored logging to support user-specific log files. - Added tests for user configuration and logging behavior.
This commit is contained in:
@@ -54,16 +54,41 @@ Primary command:
|
||||
uv run nexus-claude-api start --port 4141 --claude-code
|
||||
```
|
||||
|
||||
User configuration command:
|
||||
|
||||
```powershell
|
||||
nexus-claude-api config set --api-key <key>
|
||||
```
|
||||
|
||||
Options:
|
||||
|
||||
- `--host`: default `127.0.0.1`
|
||||
- `--port`, `-p`: default `4141`
|
||||
- `--endpoint-url`: default `https://genai-nexus.api.corpinter.net`
|
||||
- `--api-key`: optional; fallback to ignored local config, `NEXUS_API_KEY`, then `AWS_BEARER_TOKEN_BEDROCK`
|
||||
- `--api-key`: optional; overrides config files and environment variables
|
||||
- `--model`: default `claude-opus-4.6`
|
||||
- `--small-model`: default `claude-opus-4.6`
|
||||
- `--claude-code`: print Claude Code launch command
|
||||
- `--verbose`, `-v`: debug logging without secrets
|
||||
- `--dev`: use current-directory development config and logs
|
||||
- `--dry-run`: validate config and print helper output without starting the server
|
||||
|
||||
Credential lookup order:
|
||||
|
||||
1. `--api-key`
|
||||
2. Current-mode config file
|
||||
3. `NEXUS_API_KEY`
|
||||
4. `AWS_BEARER_TOKEN_BEDROCK`
|
||||
|
||||
Config file paths:
|
||||
|
||||
- Default mode: `~/.config/nexus-claude-api/config.json`
|
||||
- Development mode with `--dev`: current-directory `nexus-claude-api.local.json`
|
||||
|
||||
Log file paths:
|
||||
|
||||
- Default mode: `~/.config/nexus-claude-api/logs/nexus-claude-api.log`
|
||||
- Development mode with `--dev`: current-directory `logs/nexus-claude-api.log`
|
||||
|
||||
When `--claude-code` is used, print a PowerShell command that sets:
|
||||
|
||||
@@ -89,7 +114,7 @@ Expose:
|
||||
|
||||
`ANTHROPIC_AUTH_TOKEN` is printed as `dummy` because Claude Code expects an Anthropic auth token variable to exist. This local proxy does not validate that inbound token by default. It is not the Nexus key.
|
||||
|
||||
Inbound authentication headers are accepted for compatibility but not validated by default because the service is local. Outbound Nexus authentication uses `--api-key`, ignored local `nexus-claude-api.local.json`, `NEXUS_API_KEY`, or `AWS_BEARER_TOKEN_BEDROCK`.
|
||||
Inbound authentication headers are accepted for compatibility but not validated by default because the service is local. Outbound Nexus authentication uses `--api-key`, the current-mode config file, `NEXUS_API_KEY`, or `AWS_BEARER_TOKEN_BEDROCK`.
|
||||
|
||||
## Model Mapping
|
||||
|
||||
@@ -182,7 +207,7 @@ Return Anthropic-compatible errors:
|
||||
Status mapping:
|
||||
|
||||
- invalid request: `400`
|
||||
- missing local Nexus credential: startup failure
|
||||
- missing Nexus credential: startup failure
|
||||
- Nexus auth failure: `401` or `403`
|
||||
- Nexus throttling: `429`
|
||||
- Nexus network/timeout: `502` or `504`
|
||||
@@ -215,3 +240,14 @@ CLI tests:
|
||||
- `nexus-claude-api --help`
|
||||
- Claude Code command generation.
|
||||
- Missing API key validation.
|
||||
- User config writing with `nexus-claude-api config set --api-key <key>`.
|
||||
- Default-mode user config lookup from `~/.config/nexus-claude-api/config.json`.
|
||||
- Default mode ignores current-directory `nexus-claude-api.local.json`.
|
||||
- Development mode uses current-directory `nexus-claude-api.local.json`.
|
||||
- `--api-key` overrides config files and config files override environment variables.
|
||||
|
||||
Logging tests:
|
||||
|
||||
- Default-mode log path resolves to `~/.config/nexus-claude-api/logs/nexus-claude-api.log`.
|
||||
- Development-mode log path resolves to current-directory `logs/nexus-claude-api.log`.
|
||||
- Verbose logging enables debug details without logging secrets.
|
||||
|
||||
Reference in New Issue
Block a user