# Screen Extraction

## Context

App: {{APP_NAME}}
Actor docs: {{ACTOR_DOCS}}
Business flow docs: {{BUSINESS_FLOW_DOCS}}
Story docs: {{STORY_DOCS}}

## Available Modules

The following modules are available in erp-kit. Use this to understand which entities exist and what operations are available.

{{MODULE_OVERVIEW}}

To inspect a specific module's model (domain description, state transitions, invariants, commands), run:

```bash
npx erp-kit doc module <module-name> model <model-name>
```

## Instructions

1. Read ALL actor docs at the paths above
2. Read ALL business flow docs at the paths above
3. Read ALL story docs at the paths above
4. Identify screens needed for each business flow and story
5. For screens that display or edit module entities, use `erp-kit doc module <name> model` to understand the entity's domain
6. Return results as a structured markdown report

## Extraction Rules

### Screen Identification

For each business flow step that involves UI:

1. Identify what the user sees or interacts with
2. Classify the screen type
3. Extract fields, columns, and actions

### Screen Types

| Screen Type   | When to Use                                          |
| ------------- | ---------------------------------------------------- |
| ListView      | User browses a list of entities (table with columns) |
| Form (create) | User fills in fields to create a new entity          |
| Form (edit)   | User modifies fields of an existing entity           |
| DetailView    | User views details of a single entity with actions   |

### Screen Content

For each screen, extract:

- **Name**: kebab-case, noun-focused (e.g., `supplier-list`, `supplier-detail`, `supplier-form`)
- **Type**: ListView / Form / DetailView
- **Fields/Columns**: what data is displayed or edited
- **Actions**: navigation actions (create, edit, back) and mutation actions (save, delete, activate)
  - For each mutation action on a DetailView, run `npx erp-kit doc module <module-name>` to list available commands, then run `npx erp-kit doc module <module-name> command <command-name>` to read the command's Business Rules and Error Scenarios
- **Filters** (ListView only): for each column with Filter-able: Yes, determine the filter UI type based on the column's data type and domain
- **Line Items** (Form only): if the story involves creating/editing a parent entity with repeating child rows (e.g., order lines, invoice lines), extract the child fields as a separate Line Items section
- **Sheets**: if the story describes inline display patterns (e.g., row click opens a side panel with detail), create the child screen as a separate screen doc and reference it in a Sheets section. Display is either Right Sheet or Dialog
- **Stories**: which stories reference this screen

### Form Field Types

When extracting Form screens, assign each field a `Field Type` and `Options / Lookup` from the vocabulary below. This determines the frontend component used in implementation.

#### Field Type Vocabulary

| Field Type | Description |
| --- | --- |
| `String` | Short single-line text |
| `Text` | Multi-line text (descriptions, notes) |
| `Email` | Email address |
| `Number` | Integer value |
| `Decimal` | Decimal / float value |
| `Boolean` | True/false checkbox |
| `Date` | Date picker (no time) |
| `DateTime` | Date + time picker |
| `Select` | Single selection from a fixed list or entity |
| `MultiSelect` | Multiple selection from a fixed list or entity |
| `Lookup` | Search and select a single entity reference |
| `MultiLookup` | Search and select multiple entity references |
| `CreatableLookup` | Search and select an entity, or create a new one inline |
| `Autocomplete` | Free-text input with suggestions (value is the typed text) |

#### Options / Lookup Column

For `Select`, `MultiSelect`, `Lookup`, `MultiLookup`, `CreatableLookup`, and `Autocomplete`, specify the `Options / Lookup` column:

| Pattern | Meaning | Example |
| --- | --- | --- |
| Comma-separated values | Fixed list of options (sync) | `Draft, Active, Inactive` |
| `<Entity> entity → <display field(s)>` | Entity reference fetched from API (async) | `Supplier entity → name` |
| `—` | Not applicable (for String, Number, etc.) | `—` |

The text after `→` specifies what to display in the dropdown (e.g., `name`, `code — name`).

#### Form Field Table Format

| Field Name | Field Type | Required (Yes/No) | Options / Lookup |
| --- | --- | --- | --- |
| Name | String | Yes | — |
| Status | Select | Yes | Draft, Active, Inactive |
| Supplier | Lookup | Yes | Supplier entity → name |
| Tags | MultiLookup | No | Tag entity → name |
| Priority | Select | No | High, Medium, Low |

### Deduplication

- Screens can be shared across multiple stories and flows
- If two flows need the same entity list view, create one screen doc referenced by both
- Create/edit forms for the same entity are separate screens (different field requirements)

## Naming Convention

- Screen filename: kebab-case, noun-focused
- Pattern: `<entity>-list.md`, `<entity>-detail.md`, `<entity>-create-form.md`, `<entity>-edit-form.md`

## Output Format

Return your findings as a structured markdown report:

### Screens

For each screen:

- **Screen:** `<screen-name>`
- **Type:** ListView / Form / DetailView
- **Module source:** which module's model provides the data (if applicable)
- **Fields/Columns:** bulleted list of fields with types. For Form screens, use the Field Type vocabulary and include `Options / Lookup` where applicable
- **Actions:** bulleted list of actions
- **Referenced by stories:** which stories use this screen
- **Referenced by flows:** which business flows need this screen

### Summary

- Total screens extracted
- Screens by type (table: ListView, Form, DetailView counts)
