storkit: merge 371_bug_no_arg_storkit_in_empty_directory_skips_scaffold
This commit is contained in:
@@ -876,6 +876,39 @@ mod tests {
|
||||
assert!(content.contains("localhost"), "mcp.json should reference localhost");
|
||||
}
|
||||
|
||||
/// Regression test for bug 371: no-arg `storkit` in empty directory skips scaffold.
|
||||
/// `open_project` on a directory without `.storkit/` must create all required scaffold
|
||||
/// files — the same files that `storkit .` produces.
|
||||
#[tokio::test]
|
||||
async fn open_project_on_empty_dir_creates_full_scaffold() {
|
||||
let dir = tempdir().unwrap();
|
||||
let project_dir = dir.path().join("myproject");
|
||||
fs::create_dir_all(&project_dir).unwrap();
|
||||
let store = make_store(&dir);
|
||||
let state = SessionState::default();
|
||||
|
||||
open_project(project_dir.to_string_lossy().to_string(), &state, &store, 3001)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(
|
||||
project_dir.join(".storkit/project.toml").exists(),
|
||||
"open_project must create .storkit/project.toml"
|
||||
);
|
||||
assert!(
|
||||
project_dir.join(".mcp.json").exists(),
|
||||
"open_project must create .mcp.json"
|
||||
);
|
||||
assert!(
|
||||
project_dir.join("CLAUDE.md").exists(),
|
||||
"open_project must create CLAUDE.md"
|
||||
);
|
||||
assert!(
|
||||
project_dir.join("script/test").exists(),
|
||||
"open_project must create script/test"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn close_project_clears_root() {
|
||||
let dir = tempdir().unwrap();
|
||||
|
||||
@@ -177,13 +177,19 @@ async fn main() -> Result<(), std::io::Error> {
|
||||
config::ProjectConfig::load(&project_root)
|
||||
.unwrap_or_else(|e| panic!("Invalid project.toml: {e}"));
|
||||
} else {
|
||||
// No .storkit/ found — fall back to cwd so existing behaviour is preserved.
|
||||
// TRACE:MERGE-DEBUG — remove once root cause is found
|
||||
slog!(
|
||||
"[MERGE-DEBUG] main: no .storkit/ found, falling back to cwd {:?}",
|
||||
cwd
|
||||
);
|
||||
*app_state.project_root.lock().unwrap() = Some(cwd.clone());
|
||||
// No .storkit/ found in cwd or parents — scaffold cwd as a new
|
||||
// project, exactly like `storkit .` does.
|
||||
io::fs::open_project(
|
||||
cwd.to_string_lossy().to_string(),
|
||||
&app_state,
|
||||
store.as_ref(),
|
||||
port,
|
||||
)
|
||||
.await
|
||||
.unwrap_or_else(|e| {
|
||||
slog!("Warning: failed to scaffold project at {cwd:?}: {e}");
|
||||
cwd.to_string_lossy().to_string()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user