huskies: merge 858

This commit is contained in:
dave
2026-04-29 10:41:32 +00:00
parent be5db846cc
commit 11d111360d
79 changed files with 265 additions and 0 deletions
+1
View File
@@ -39,6 +39,7 @@ pub async fn write_file(path: String, content: String, state: &SessionState) ->
}
#[derive(Serialize, Debug, poem_openapi::Object)]
/// A directory listing entry with its name and kind (file or directory).
pub struct FileEntry {
pub name: String,
pub kind: String,
+5
View File
@@ -1,8 +1,13 @@
//! Filesystem I/O — module declarations and re-exports for file operations.
/// File read/write/list operations.
pub mod files;
/// Path resolution and project-root discovery.
pub mod paths;
/// User model-preference storage.
pub mod preferences;
/// Project open/close/list lifecycle.
pub mod project;
/// `.huskies/` directory scaffolding for new projects.
pub mod scaffold;
pub use files::{
+1
View File
@@ -29,6 +29,7 @@ pub fn find_story_kit_root(start: &Path) -> Option<PathBuf> {
}
}
/// Return the current user's home directory as a string.
pub fn get_home_directory() -> Result<String, String> {
let home = homedir::my_home()
.map_err(|e| format!("Failed to resolve home directory: {e}"))?
+2
View File
@@ -4,6 +4,7 @@ use serde_json::json;
const KEY_SELECTED_MODEL: &str = "selected_model";
/// Read the user's selected LLM model name from the store.
pub fn get_model_preference(store: &dyn StoreOps) -> Result<Option<String>, String> {
if let Some(model) = store
.get(KEY_SELECTED_MODEL)
@@ -15,6 +16,7 @@ pub fn get_model_preference(store: &dyn StoreOps) -> Result<Option<String>, Stri
Ok(None)
}
/// Persist the user's selected LLM model name to the store.
pub fn set_model_preference(model: String, store: &dyn StoreOps) -> Result<(), String> {
store.set(KEY_SELECTED_MODEL, json!(model));
store.save()?;
+4
View File
@@ -84,6 +84,7 @@ pub async fn open_project(
Ok(path)
}
/// Close the active project by clearing the in-memory root and stored path.
#[allow(dead_code)]
pub fn close_project(state: &SessionState, store: &dyn StoreOps) -> Result<(), String> {
{
@@ -99,6 +100,7 @@ pub fn close_project(state: &SessionState, store: &dyn StoreOps) -> Result<(), S
Ok(())
}
/// Return the active project path, restoring it from the store if needed.
#[allow(dead_code)]
pub fn get_current_project(
state: &SessionState,
@@ -133,6 +135,7 @@ pub fn get_current_project(
Ok(None)
}
/// List all previously-opened project paths from the store.
#[allow(dead_code)]
pub fn get_known_projects(store: &dyn StoreOps) -> Result<Vec<String>, String> {
let projects = store
@@ -146,6 +149,7 @@ pub fn get_known_projects(store: &dyn StoreOps) -> Result<Vec<String>, String> {
Ok(projects)
}
/// Remove a project path from the known-projects list in the store.
#[allow(dead_code)]
pub fn forget_known_project(path: String, store: &dyn StoreOps) -> Result<(), String> {
let mut known_projects = get_known_projects(store)?;