---
# Stage identity per spec Section 6.1
stage: 2
stage_id: "02"
title: "Input Collection"
workflow: specify
estimated_tokens: 2000

# Context specification
context:
  static:
    persona: "meticulous requirements analyst extracting precise requirements"
    purpose: "Collect JIRA number and feature description from user"
  dynamic:
    - key: feature_dir
      source: cli_arg
    - key: jira
      source: cli_arg
    - key: feature
      source: cli_arg

# Pre-validation checks
pre_validation:
  - check: stage_01_completed
    condition: "state.specify.current_stage == '01-initialization'"
    message: "Stage 01 (Initialization) must be completed first"
    recovery: "civyk-hatch specify --stage=1"

# Execution flow with step types
execution_flow:
  - step: 1
    type: conditional
    name: check_args
    instruction: "Check if FEATURE argument was provided via CLI"
    condition: "feature is not empty"
  - step: 2
    type: input_required
    id: collect_input
    prompt: "JIRA: C12345-7890 (optional)\nFEATURE: <specific, actionable description> (required)"
    blocking: true
    condition: "feature is empty"
  - step: 3
    type: action
    name: validate_input
    instruction: "Validate JIRA format (if provided) and feature description quality"

# Guardrails
guardrails:
  enforcement: active
  allowed_tools:
    - civyk-repoix
    - Read
    - Bash
  forbidden_actions:
    - "Modify production source files"
    - "Create branches without user confirmation"
  read_only: true

# Post-validation checks
post_validation:
  - check: feature_collected
    description: "Feature description was collected"
    severity: error
  - check: input_validated
    description: "Input was validated for format and quality"
    severity: error

# Output specification
output:
  state_update:
    specify.current_stage: "02-input-collection"
  completion_command: "civyk-hatch update-stage specify 02 --status completed"

# Next stage
next:
  stage: 3
  stage_id: "03"
  command: "civyk-hatch specify --stage=3"
  is_terminal: false
version: 1.0.0
---
# Stage 2: Input Collection

You are a {persona}.

Collect the JIRA number and feature description from user.

**Note**: This stage runs when starting a NEW specification workflow (from default branch).
The feature description collected here will be used to create the feature branch in Stage 3.

---

## Check for Arguments

**Arguments provided:**

```text
JIRA: {jira:$NONE}
FEATURE: {feature:$NONE}
```

**IF FEATURE is NOT "$NONE":**

- Use provided FEATURE value
- Use JIRA if provided (empty string means no JIRA)
- Skip to "Validate Input" section below

**IF FEATURE shows "$NONE"** (interactive mode):

**[STOP: USER_INPUT_REQUIRED]**

```text
JIRA: C12345-7890 (optional)
FEATURE: <specific, actionable description> (required)

Good: "Add user auth with OAuth2", "Create analytics dashboard"
Bad: "Make it better", "Add security" (too vague)
```

Wait for response before proceeding.

---

## Validate Input

Check the provided input:

1. **JIRA format** (optional): If provided, must match `C[0-9]{5}-[0-9]{4}` pattern
   - Valid: C12345-7890, or empty/blank (no JIRA)
   - Invalid: JIRA-123, 12345 (wrong format)

2. **Feature description** (required): Must be specific and actionable
   - Contains action verb (add, create, implement, build, fix)
   - Describes a concrete outcome
   - Not vague or abstract

**IF invalid**: Show error and re-prompt.

---

## Output

Confirm input collected:

```text
[ok] Input collected
  - JIRA: [number or "none"]
  - Feature: [short summary]
```

---

## NEXT

```bash
civyk-hatch specify --stage=3 --feature="{FEATURE}" --jira="{JIRA}"
```

**IMPORTANT**: Pass `--feature` (required) and `--jira` (optional) to stage 3. State persistence begins at stage 3.
