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:
2026-06-27 10:21:00 +08:00
parent 0e98ce57d4
commit 4685a0165d
10 changed files with 434 additions and 25 deletions

View File

@@ -9,6 +9,7 @@ AI Nexus currently documents AWS Bedrock Converse API as the workaround while An
```powershell
cd nexus-claude-api
uv sync --extra dev
uv run nexus-claude-api config set --api-key "your-nexus-api-key"
uv run nexus-claude-api start --port 4141 --claude-code
```
@@ -32,11 +33,17 @@ The printed command ends with `claude --model <configured-model>` so the current
Credential lookup order:
1. `--api-key`
2. local `nexus-claude-api.local.json`
2. user config `~/.config/nexus-claude-api/config.json`
3. `NEXUS_API_KEY`
4. `AWS_BEARER_TOKEN_BEDROCK`
For local hardcoded configuration, create `nexus-claude-api.local.json`:
To write user config:
```powershell
nexus-claude-api config set --api-key "your-nexus-api-key"
```
This creates `~/.config/nexus-claude-api/config.json`:
```json
{
@@ -44,7 +51,15 @@ For local hardcoded configuration, create `nexus-claude-api.local.json`:
}
```
This file is ignored by git.
Logs are written to `~/.config/nexus-claude-api/logs/nexus-claude-api.log` by default.
For repository-local development only, pass `--dev` and create `nexus-claude-api.local.json` in the current directory:
```powershell
uv run nexus-claude-api start --dev --port 4141 --claude-code
```
In development mode, config is read from `nexus-claude-api.local.json` and logs are written to `logs/nexus-claude-api.log` in the current directory. The local config file is ignored by git.
The service binds to `127.0.0.1` by default and does not persist API keys.
@@ -53,3 +68,4 @@ The service binds to `127.0.0.1` by default and does not persist API keys.
- [PRD](docs/PRD.md)
- [Requirements Design](docs/REQUIREMENTS_DESIGN.md)
- [AI Nexus Claude Documentation](docs/AI_NEXUS_CLAUDE.md)
- [Python Internal Distribution Guide](docs/PACKAGING_DISTRIBUTION.md)