Improve config lookup and OpenAI streaming decode
This commit is contained in:
23
dev-plan.md
23
dev-plan.md
@@ -8,7 +8,7 @@
|
||||
## Functional Requirements
|
||||
- **Interactive chat loop** Allow continuous message exchange with the AI until the user exits.
|
||||
- **Config-driven startup** Parse `config.yaml` for `api.url`, `api.key`, model defaults, and future options (e.g., system prompts, temperature, streaming flag).
|
||||
- **Persistent history** Store chats in a SQLite database located at `/var/log/goaichat/<username>/goaichat.db`, capturing session metadata and full message transcripts.
|
||||
- **Persistent history** Store chats in a SQLite database located at `$HOME/.local/share/goaichat/goaichat.db` (configurable), capturing session metadata and full message transcripts.
|
||||
- **History commands** Provide `/list` to enumerate saved chats and allow selecting or reopening them within the session.
|
||||
- **Model management** Support `/models` command to display configured/available models, persist the user’s choice, and use it for subsequent requests.
|
||||
- **Graceful exit controls** Support commands like `/exit`, `/reset`, `/help`.
|
||||
@@ -44,20 +44,17 @@ dflow LR
|
||||
ChatCore --> UI
|
||||
Config[(config.yaml + env)] --> ConfigPkg[Configuration]
|
||||
ConfigPkg --> AppCore[Application core]
|
||||
AppCore --> UI
|
||||
AppCore --> ChatCore
|
||||
AppCore --> OpenAIClient
|
||||
AppCore --> Storage
|
||||
```
|
||||
|
||||
## Persistence & Data Storage (`internal/storage`)
|
||||
- **Data directory** Resolve user-specific path `/var/log/goaichat/<username>/` (configurable override) and ensure directories exist with secure permissions.
|
||||
- **Database** SQLite file `goaichat.db` managed via `modernc.org/sqlite` (pure Go) for portability; allow build tag to switch to `mattn/go-sqlite3` if desired.
|
||||
- **Schema**
|
||||
- **`sessions`** (`id`, `name`, `created_at`, `updated_at`, `model_name`, `summary`).
|
||||
- **`messages`** (`id`, `session_id`, `role`, `content`, `token_count`, `created_at`).
|
||||
- **`models`** (`id`, `name`, `display_name`, `provider`, `is_default`, `last_used_at`).
|
||||
- **Migrations** Ship SQL migration files applied on startup; version using goose/atlas or simple in-app migration runner.
|
||||
##- **Persistence & Data Storage (`internal/storage`)
|
||||
- **Data directory** Resolve user-specific path `$HOME/.local/share/goaichat/` (configurable override) and ensure directories exist with secure permissions.
|
||||
- **Database** SQLite file `goaichat.db` managed via `modernc.org/sqlite` (pure Go) for portability; allow build tag to switch to `mattn/go-sqlite3` if desired.
|
||||
- **Schema**
|
||||
- **`sessions`** (`id`, `name`, `created_at`, `updated_at`, `model_name`, `summary`).
|
||||
- **`messages`** (`id`, `session_id`, `role`, `content`, `token_count`, `created_at`).
|
||||
- **`models`** (`id`, `name`, `display_name`, `provider`, `is_default`, `last_used_at`).
|
||||
{{ ... }}
|
||||
- **Data access** Provide repository interfaces for chat service to create sessions, append messages, list chats, update selected model, and fetch transcripts.
|
||||
- **Performance** Enable write-ahead logging, tune connection settings, and guard concurrent access with a request queue or mutex.
|
||||
|
||||
@@ -127,7 +124,7 @@ logging:
|
||||
- **Milestone 4: Persistence foundation**
|
||||
- **Design** SQLite schema and migrations within `internal/storage`.
|
||||
- **Implement** repositories for sessions, messages, and models.
|
||||
- **Ensure** path resolution to `/var/log/goaichat/<username>/` with permission checks and tests.
|
||||
- **Ensure** path resolution to `$HOME/.local/share/goaichat/` with permission checks and tests.
|
||||
|
||||
- **Milestone 5: Chat loop MVP**
|
||||
- **Implement** CLI loop that reads user input, calls chat client, prints responses.
|
||||
|
Reference in New Issue
Block a user