config file, bugfixes

This commit is contained in:
leach
2025-08-15 15:41:32 -04:00
parent b171a6b2b2
commit 7d237f692c
7 changed files with 364 additions and 29 deletions

View File

@@ -4,6 +4,8 @@ use serde::{Deserialize, Serialize};
use std::fs;
use std::path::PathBuf;
use crate::config::Config;
const SYSTEM_PROMPT: &str = "You are an AI assistant running in a terminal (CLI) environment. \
Optimise all answers for 80column readability, prefer plain text, \
ASCII art or concise bullet lists over heavy markup, and wrap code \
@@ -62,8 +64,9 @@ impl Session {
}
pub fn sessions_dir() -> Result<PathBuf> {
let config = Config::load().unwrap_or_default();
let home = dirs::home_dir().context("Could not find home directory")?;
let sessions_dir = home.join(".chat_cli_sessions");
let sessions_dir = home.join(&config.session.sessions_dir_name);
if !sessions_dir.exists() {
fs::create_dir_all(&sessions_dir)
@@ -74,7 +77,8 @@ impl Session {
}
pub fn session_path(name: &str) -> Result<PathBuf> {
Ok(Self::sessions_dir()?.join(format!("{}.json", name)))
let config = Config::load().unwrap_or_default();
Ok(Self::sessions_dir()?.join(format!("{}.{}", name, config.session.file_extension)))
}
pub fn save(&self) -> Result<()> {