From 967a306ea818906da244e914b9cf8e401bc3341f Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 2 Apr 2026 13:24:15 +0000 Subject: [PATCH] storkit: merge 457_bug_store_json_created_at_project_root_instead_of_inside_storkit --- server/src/http/mcp/wizard_tools.rs | 1 - server/src/io/fs/scaffold.rs | 12 +++++++++--- server/src/main.rs | 12 +++++++++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/server/src/http/mcp/wizard_tools.rs b/server/src/http/mcp/wizard_tools.rs index 91e2fc95..c13f26ea 100644 --- a/server/src/http/mcp/wizard_tools.rs +++ b/server/src/http/mcp/wizard_tools.rs @@ -168,7 +168,6 @@ pub(crate) fn is_bare_project(project_root: &Path) -> bool { || n == "LICENSE" || n == "README.md" || n == "script" - || n == "store.json" }) }) .unwrap_or(true) diff --git a/server/src/io/fs/scaffold.rs b/server/src/io/fs/scaffold.rs index 2ae393c8..d64eaeaa 100644 --- a/server/src/io/fs/scaffold.rs +++ b/server/src/io/fs/scaffold.rs @@ -294,6 +294,7 @@ fn write_story_kit_gitignore(root: &Path) -> Result<(), String> { "logs/", "token_usage.jsonl", "wizard_state.json", + "store.json", ]; let gitignore_path = root.join(".storkit").join(".gitignore"); @@ -330,11 +331,13 @@ fn write_story_kit_gitignore(root: &Path) -> Result<(), String> { } /// Append root-level Story Kit entries to the project `.gitignore`. -/// Only `store.json` and `.storkit_port` remain here because they live at +/// Only `.storkit_port` and `.mcp.json` remain here because they live at /// the project root and git does not support `../` patterns in `.gitignore` /// files, so they cannot be expressed in `.storkit/.gitignore`. +/// `store.json` is excluded via `.storkit/.gitignore` since it now lives +/// inside the `.storkit/` directory. fn append_root_gitignore_entries(root: &Path) -> Result<(), String> { - let entries = [".storkit_port", "store.json", ".mcp.json"]; + let entries = [".storkit_port", ".mcp.json"]; let gitignore_path = root.join(".gitignore"); let existing = if gitignore_path.exists() { @@ -705,11 +708,14 @@ mod tests { // Root .gitignore must contain root-level storkit entries let root_content = fs::read_to_string(dir.path().join(".gitignore")).unwrap(); assert!(root_content.contains(".storkit_port")); - assert!(root_content.contains("store.json")); + // store.json now lives inside .storkit/ and must NOT appear in root .gitignore + assert!(!root_content.contains("store.json")); // Root .gitignore must NOT contain .storkit/ sub-directory patterns assert!(!root_content.contains(".storkit/worktrees/")); assert!(!root_content.contains(".storkit/merge_workspace/")); assert!(!root_content.contains(".storkit/coverage/")); + // store.json must be in .storkit/.gitignore instead + assert!(sk_content.contains("store.json")); } #[test] diff --git a/server/src/main.rs b/server/src/main.rs index a35037c4..d2244bbd 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -139,8 +139,18 @@ async fn main() -> Result<(), std::io::Error> { let app_state = Arc::new(SessionState::default()); let cwd = std::env::current_dir().unwrap_or_else(|_| PathBuf::from(".")); + // Migrate legacy root-level store.json into .storkit/ if the new path does + // not yet exist. This keeps existing deployments working after upgrade. + let legacy_store_path = cwd.join("store.json"); + let store_path = cwd.join(".storkit").join("store.json"); + if legacy_store_path.exists() && !store_path.exists() { + if let Some(parent) = store_path.parent() { + let _ = std::fs::create_dir_all(parent); + } + let _ = std::fs::rename(&legacy_store_path, &store_path); + } let store = Arc::new( - JsonFileStore::from_path(PathBuf::from("store.json")).map_err(std::io::Error::other)?, + JsonFileStore::from_path(store_path).map_err(std::io::Error::other)?, ); // Collect CLI args, skipping the binary name (argv[0]).