huskies: merge 1219 story Add runtime artifacts to the default project scaffold .gitignore

This commit is contained in:
Huskies Agent
2026-07-18 13:50:49 +00:00
parent 90cb005019
commit 9c61dfa595
5 changed files with 73 additions and 1 deletions
+33 -1
View File
@@ -5,7 +5,7 @@ use serde_json::json;
use std::fs;
use std::path::PathBuf;
use super::scaffold::scaffold_story_kit;
use super::scaffold::{ensure_gitignore_entries, scaffold_story_kit};
const KEY_LAST_PROJECT: &str = "last_project_path";
const KEY_KNOWN_PROJECTS: &str = "known_projects";
@@ -36,6 +36,10 @@ pub(crate) async fn ensure_project_root_with_story_kit(
}
if !path.join(".huskies").is_dir() {
scaffold_story_kit(&path, port)?;
} else {
// Already-adopted project: pick up any Story Kit gitignore entries
// added since this project was first scaffolded.
ensure_gitignore_entries(&path)?;
}
// Always update .mcp.json with the current port so the bot connects to
// the right endpoint even when HUSKIES_PORT changes between restarts.
@@ -449,6 +453,34 @@ mod tests {
assert!(project_dir.join(".huskies").is_dir());
}
/// Regression test for story 1219: projects scaffolded before
/// `merge_reports/` and `session_store.json` were added to the ignore
/// list must pick up those entries the next time the project is opened,
/// without needing to be re-scaffolded from scratch.
#[tokio::test]
async fn open_project_retrofits_gitignore_entries_for_existing_project() {
let dir = tempdir().unwrap();
let project_dir = dir.path().join("myproject");
let sk_dir = project_dir.join(".huskies");
fs::create_dir_all(&sk_dir).unwrap();
fs::write(sk_dir.join(".gitignore"), "worktrees/\n").unwrap();
let store = make_store(&dir);
let state = SessionState::default();
open_project(
project_dir.to_string_lossy().to_string(),
&state,
&store,
3001,
)
.await
.unwrap();
let content = fs::read_to_string(sk_dir.join(".gitignore")).unwrap();
assert!(content.contains("merge_reports/"));
assert!(content.contains("session_store.json"));
}
#[tokio::test]
async fn open_project_does_not_overwrite_existing_story_kit() {
let dir = tempdir().unwrap();