feat: wizard detects bare projects and prompts user interview for context/stack
wizard_generate now checks if the project has no source code. On bare projects, the generation hints tell the LLM to ask the user what they want to build and what tech stack they plan to use, rather than trying to read a nonexistent codebase. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -152,22 +152,67 @@ pub(super) fn tool_wizard_generate(args: &Value, ctx: &AppContext) -> Result<Str
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return true if the project directory has no meaningful source files.
|
||||||
|
fn is_bare_project(project_root: &Path) -> bool {
|
||||||
|
let dominated_by_storkit = std::fs::read_dir(project_root)
|
||||||
|
.ok()
|
||||||
|
.map(|entries| {
|
||||||
|
let names: Vec<String> = entries
|
||||||
|
.filter_map(|e| e.ok())
|
||||||
|
.map(|e| e.file_name().to_string_lossy().to_string())
|
||||||
|
.collect();
|
||||||
|
// A bare project only has storkit scaffolding and no real code
|
||||||
|
names.iter().all(|n| {
|
||||||
|
n.starts_with('.')
|
||||||
|
|| n == "CLAUDE.md"
|
||||||
|
|| n == "LICENSE"
|
||||||
|
|| n == "README.md"
|
||||||
|
|| n == "script"
|
||||||
|
|| n == "store.json"
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.unwrap_or(true);
|
||||||
|
dominated_by_storkit
|
||||||
|
}
|
||||||
|
|
||||||
/// Return a generation hint for a step based on the project root.
|
/// Return a generation hint for a step based on the project root.
|
||||||
fn generation_hint(step: WizardStep, project_root: &Path) -> String {
|
fn generation_hint(step: WizardStep, project_root: &Path) -> String {
|
||||||
|
let bare = is_bare_project(project_root);
|
||||||
|
|
||||||
match step {
|
match step {
|
||||||
WizardStep::Context => {
|
WizardStep::Context => {
|
||||||
"Read the project source tree and generate a `.storkit/specs/00_CONTEXT.md` describing:\n\
|
if bare {
|
||||||
- High-level goal of the project\n\
|
"This is a bare project with no existing code. Ask the user what they want \
|
||||||
- Core features\n\
|
to build — the project's purpose, goals, target users, and key features. \
|
||||||
- Domain concepts and entities\n\
|
Then generate `.storkit/specs/00_CONTEXT.md` from their answers covering:\n\
|
||||||
- Glossary of abbreviations and technical terms".to_string()
|
- High-level goal of the project\n\
|
||||||
|
- Core features\n\
|
||||||
|
- Domain concepts and entities\n\
|
||||||
|
- Glossary of abbreviations and technical terms".to_string()
|
||||||
|
} else {
|
||||||
|
"Read the project source tree and generate a `.storkit/specs/00_CONTEXT.md` describing:\n\
|
||||||
|
- High-level goal of the project\n\
|
||||||
|
- Core features\n\
|
||||||
|
- Domain concepts and entities\n\
|
||||||
|
- Glossary of abbreviations and technical terms".to_string()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
WizardStep::Stack => {
|
WizardStep::Stack => {
|
||||||
"Read the project source tree and generate a `.storkit/specs/tech/STACK.md` describing:\n\
|
if bare {
|
||||||
- Language, frameworks, and runtimes\n\
|
"This is a bare project with no existing code. Ask the user what language, \
|
||||||
- Coding standards and linting rules\n\
|
frameworks, and tools they plan to use. Then generate `.storkit/specs/tech/STACK.md` \
|
||||||
- Quality gates (commands that must pass before merging)\n\
|
from their answers covering:\n\
|
||||||
- Approved libraries and their purpose".to_string()
|
- Language, frameworks, and runtimes\n\
|
||||||
|
- Coding standards and linting rules\n\
|
||||||
|
- Quality gates (commands that must pass before merging)\n\
|
||||||
|
- Approved libraries and their purpose".to_string()
|
||||||
|
} else {
|
||||||
|
"Read the project source tree and generate a `.storkit/specs/tech/STACK.md` describing:\n\
|
||||||
|
- Language, frameworks, and runtimes\n\
|
||||||
|
- Coding standards and linting rules\n\
|
||||||
|
- Quality gates (commands that must pass before merging)\n\
|
||||||
|
- Approved libraries and their purpose".to_string()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
WizardStep::TestScript => {
|
WizardStep::TestScript => {
|
||||||
let has_cargo = project_root.join("Cargo.toml").exists();
|
let has_cargo = project_root.join("Cargo.toml").exists();
|
||||||
|
|||||||
Reference in New Issue
Block a user