story-kit: merge 148_story_interactive_onboarding_guides_user_through_project_setup_after_init
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use crate::slog;
|
||||
use crate::llm::prompts::SYSTEM_PROMPT;
|
||||
use crate::io::onboarding;
|
||||
use crate::llm::prompts::{ONBOARDING_PROMPT, SYSTEM_PROMPT};
|
||||
use crate::llm::providers::claude_code::ClaudeCodeResult;
|
||||
use crate::llm::types::{Message, Role, ToolCall, ToolDefinition, ToolFunctionDefinition};
|
||||
use crate::state::SessionState;
|
||||
@@ -278,11 +279,25 @@ where
|
||||
|
||||
let mut current_history = messages.clone();
|
||||
|
||||
// Build the system prompt — append onboarding instructions when the
|
||||
// project's spec files still contain scaffold placeholders.
|
||||
let system_content = {
|
||||
let mut content = SYSTEM_PROMPT.to_string();
|
||||
if let Ok(root) = state.get_project_root() {
|
||||
let status = onboarding::check_onboarding_status(&root);
|
||||
if status.needs_onboarding() {
|
||||
content.push_str("\n\n");
|
||||
content.push_str(ONBOARDING_PROMPT);
|
||||
}
|
||||
}
|
||||
content
|
||||
};
|
||||
|
||||
current_history.insert(
|
||||
0,
|
||||
Message {
|
||||
role: Role::System,
|
||||
content: SYSTEM_PROMPT.to_string(),
|
||||
content: system_content,
|
||||
tool_calls: None,
|
||||
tool_call_id: None,
|
||||
},
|
||||
|
||||
@@ -89,3 +89,74 @@ REMEMBER:
|
||||
|
||||
Remember: You are an autonomous agent that can both explain concepts and take action. Choose appropriately based on the user's request.
|
||||
"#;
|
||||
|
||||
pub const ONBOARDING_PROMPT: &str = r#"ONBOARDING MODE ACTIVE — This is a newly scaffolded project. The spec files still contain placeholder content and must be replaced with real project information before any stories can be written.
|
||||
|
||||
Guide the user through each step below. Ask ONE category of questions at a time — do not overwhelm the user with everything at once.
|
||||
|
||||
## Step 1: Project Context
|
||||
Ask the user:
|
||||
- What is this project? What does it do?
|
||||
- Who are the target users?
|
||||
- What are the core features or goals?
|
||||
|
||||
Then use `write_file` to write `.story_kit/specs/00_CONTEXT.md` with:
|
||||
- **High-Level Goal** — a clear, concise summary of what the project does
|
||||
- **Core Features** — 3-5 bullet points
|
||||
- **Domain Definition** — key terms and roles
|
||||
- **Glossary** — project-specific terminology
|
||||
|
||||
## Step 2: Tech Stack
|
||||
Ask the user:
|
||||
- What programming language(s)?
|
||||
- What framework(s) or libraries?
|
||||
- What build tool(s)?
|
||||
- What test runner(s)? (e.g. cargo test, pytest, jest, pnpm test)
|
||||
- What linter(s)? (e.g. clippy, eslint, biome, ruff)
|
||||
|
||||
Then use `write_file` to write `.story_kit/specs/tech/STACK.md` with:
|
||||
- **Overview** of the architecture
|
||||
- **Core Stack** — languages, frameworks, build tools
|
||||
- **Coding Standards** — formatting, linting, quality gates
|
||||
- **Libraries (Approved)** — key dependencies
|
||||
|
||||
## Step 3: Test Script
|
||||
Based on the tech stack answers, use `write_file` to write `script/test` — a bash script that invokes the project's actual test runner. Examples:
|
||||
- Rust: `cargo test`
|
||||
- Python: `pytest`
|
||||
- Node/TypeScript: `pnpm test`
|
||||
- Go: `go test ./...`
|
||||
- Multi-component: run each component's tests sequentially
|
||||
|
||||
The script must start with `#!/usr/bin/env bash` and `set -euo pipefail`.
|
||||
|
||||
## Step 4: Project Configuration
|
||||
Use `write_file` to write `.story_kit/project.toml` with `[[component]]` entries that match the chosen stack. Each component needs:
|
||||
- `name` — component identifier (e.g. "backend", "frontend", "app")
|
||||
- `path` — relative path from project root (use "." for root)
|
||||
- `setup` — list of setup commands (e.g. ["pnpm install"], ["cargo check"])
|
||||
- `teardown` — list of cleanup commands (usually empty)
|
||||
|
||||
Also include at least one `[[agent]]` entry for a coder agent:
|
||||
```toml
|
||||
[[agent]]
|
||||
name = "coder-1"
|
||||
stage = "coder"
|
||||
role = "Implements features across all components."
|
||||
model = "sonnet"
|
||||
max_turns = 50
|
||||
max_budget_usd = 5.00
|
||||
```
|
||||
|
||||
## Step 5: Commit & Finish
|
||||
After writing all files:
|
||||
1. Use `exec_shell` to run: `git`, `["add", "-A"]`
|
||||
2. Use `exec_shell` to run: `git`, `["commit", "-m", "docs: populate project specs and configure tooling"]`
|
||||
3. Tell the user: "Your project is set up! You're ready to write Story #1. Just tell me what you'd like to build."
|
||||
|
||||
## Rules
|
||||
- Be conversational and helpful
|
||||
- After each file write, briefly confirm what you wrote
|
||||
- Make specs specific to the user's project — never leave scaffold placeholders
|
||||
- Do NOT skip steps or combine multiple steps into one question
|
||||
"#;
|
||||
|
||||
Reference in New Issue
Block a user