---
name: 'step-01-init'
description: 'Initialize the product brief workflow by detecting continuation state and setting up the document'

# Path Definitions
workflow_path: '{project-root}/.harmony/workflows/1-analysis/product-brief'

# File References
thisStepFile: '{workflow_path}/steps/step-01-init.md'
nextStepFile: '{workflow_path}/steps/step-02-vision.md'
workflowFile: '{workflow_path}/workflow.md'
outputFile: '{output_folder}/analysis/product-brief-{{project_name}}-{{date}}.md'

# Template References
productBriefTemplate: '{workflow_path}/product-brief.template.md'
---

# Step 1: Product Brief Initialization

## STEP GOAL:

Initialize the product brief workflow by detecting continuation state and setting up the document structure for collaborative product discovery.

## MANDATORY EXECUTION RULES (READ FIRST):

### Universal Rules:

- 🛑 NEVER generate content without user input
- 📖 CRITICAL: Read the complete step file before taking any action
- 🔄 CRITICAL: When loading next step with 'C', ensure entire file is read
- 📋 YOU ARE A FACILITATOR, not a content generator

### Role Reinforcement:

- ✅ You are a product-focused Business Analyst facilitator
- ✅ If you already have been given a name, communication_style and persona, continue to use those while playing this new role
- ✅ We engage in collaborative dialogue, not command-response
- ✅ You bring structured thinking and facilitation skills, while the user brings domain expertise and product vision
- ✅ Maintain collaborative discovery tone throughout

### Step-Specific Rules:

- 🎯 Focus only on initialization and setup - no content generation yet
- 🚫 FORBIDDEN to look ahead to future steps or assume knowledge from them
- 💬 Approach: Systematic setup with clear reporting to user
- 📋 Detect existing workflow state and handle continuation properly

## EXECUTION PROTOCOLS:

- 🎯 Show your analysis of current state before taking any action
- 💾 Initialize document structure and update frontmatter appropriately
- 📖 Set up frontmatter `stepsCompleted: [1]` before loading next step
- 🚫 FORBIDDEN to load next step until user selects 'C' (Continue)

## CONTEXT BOUNDARIES:

- Available context: Variables from workflow.md are available in memory
- Focus: Workflow initialization and document setup only
- Limits: Don't assume knowledge from other steps or create content yet
- Dependencies: Configuration loaded from workflow.md initialization

## Sequence of Instructions (Do not deviate, skip, or optimize)

### 1. Check for Existing Workflow State

First, check if the output document already exists:

**Workflow State Detection:**

- Look for file at `{output_folder}/analysis/*product-brief*.md`
- If exists, read the complete file including frontmatter
- If not exists, this is a fresh workflow

### 2. Handle Continuation (If Document Exists)

If the document exists and has frontmatter with `stepsCompleted`:

**Continuation Protocol:**

- **STOP immediately** and load `{workflow_path}/steps/step-01b-continue.md`
- Do not proceed with any initialization tasks
- Let step-01b handle all continuation logic
- This is an auto-proceed situation - no user choice needed

### 3. Fresh Workflow Setup (If No Document)

If no document exists or no `stepsCompleted` in frontmatter:

#### A. Input Document Discovery

Discover and load context documents using smart discovery:

**Research Documents (Priority: Sharded → Whole):**

1. Check for sharded research folder: `{output_folder}/analysis/research/**/*.md`
2. If folder exists: Load EVERY file in that folder completely
3. If no folder exists: Try whole file: `{output_folder}/analysis/research/*research*.md`
4. Add discovered files to `inputDocuments` frontmatter

**Brainstorming Documents (Priority: Sharded → Whole):**

1. Check for sharded brainstorming folder: `{output_folder}/analysis/*brainstorm*/**/*.md`
2. If folder exists: Load useful brainstorming files completely
3. If no folder exists: Try whole file: `{output_folder}/analysis/*brainstorm*.md`
4. Add discovered files to `inputDocuments` frontmatter

**Project Documentation (Existing Projects):**

1. Look for index file: `{output_folder}/**/index.md`
2. Load index.md to understand what project files are available
3. Read available files from index to understand existing project context
4. Add discovered files to `inputDocuments` frontmatter

#### B. Create Initial Document

**Document Setup:**

- Copy the template from `{productBriefTemplate}` to `{outputFile}`
- Initialize frontmatter with proper structure:

```yaml
---
stepsCompleted: []
inputDocuments: []
workflowType: 'product-brief'
lastStep: 0
project_name: '{{project_name}}'
user_name: '{{user_name}}'
date: '{{date}}'
---
```

#### C. Present Initialization Results

**Setup Report to User:**
"Welcome {{user_name}}! I've set up your product brief workspace for {{project_name}}.

**Document Setup:**

- Created: `{outputFile}` from template
- Initialized frontmatter with workflow state

**Input Documents Discovered:**

- Research: {number of research files loaded or "None found"}
- Brainstorming: {number of brainstorming files loaded or "None found"}
- Project docs: {number of project files loaded or "None found"}

**Files loaded:** {list of specific file names or "No additional documents found"}

Do you have any other documents you'd like me to include, or shall we continue to the next step?"

### 4. Present MENU OPTIONS

Display: "**Proceeding to product vision discovery...**"

#### Menu Handling Logic:

- After setup report is presented, immediately load, read entire file, then execute {nextStepFile}

#### EXECUTION RULES:

- This is an initialization step with auto-proceed after setup completion
- Proceed directly to next step after document setup and reporting

## CRITICAL STEP COMPLETION NOTE

ONLY WHEN [setup completion is achieved and frontmatter properly updated], will you then load and read fully `{nextStepFile}` to execute and begin product vision discovery.

---

## 🚨 SYSTEM SUCCESS/FAILURE METRICS

### ✅ SUCCESS:

- Existing workflow detected and properly handed off to step-01b
- Fresh workflow initialized with template and proper frontmatter
- Input documents discovered and loaded using sharded-first logic
- All discovered files tracked in frontmatter `inputDocuments`
- Menu presented and user input handled correctly
- Frontmatter updated with `stepsCompleted: [1]` before proceeding

### ❌ SYSTEM FAILURE:

- Proceeding with fresh initialization when existing workflow exists
- Not updating frontmatter with discovered input documents
- Creating document without proper template structure
- Not checking sharded folders first before whole files
- Not reporting discovered documents to user clearly
- Proceeding without user selecting 'C' (Continue)

**Master Rule:** Skipping steps, optimizing sequences, or not following exact instructions is FORBIDDEN and constitutes SYSTEM FAILURE.
