# Step 3: Generate repos.yaml

<purpose>
Generate the repos.yaml configuration file based on discovered project structure, with user refinement.
</purpose>

<instructions>
1. Transform discovery data into repos.yaml format
2. Present draft configuration to user
3. Allow user to edit/refine entries
4. Write finalized repos.yaml to project root
</instructions>

<output>
- repos.yaml file created at project root
- All repositories properly configured
- Commands and metadata accurate
- User has approved the configuration
</output>

## REPOS.YAML STRUCTURE

```yaml
# Repository Configuration for {project_name}
# Generated by Pennyfarthing project-setup workflow

repos:
  {repo_key}:
    path: {relative_path}           # Path from project root
    type: {api|ui|cli|library|orchestrator|framework}
    description: {brief_description}
    language: {typescript|python|rust|go|java}

    # Commands (optional - omit if not applicable)
    test_command: {command}
    build_command: {command}
    lint_command: {command}
    dev_command: {command}

    # Additional metadata (optional)
    framework: {express|react|fastapi|etc}
    notes: |
      Any special notes about this repo.

# Architecture notes:
# Add any project-wide architectural notes here
```

## GENERATION RULES

### Repo Keys
- Use lowercase, descriptive names
- For monorepos: use package names (`api`, `ui`, `shared`)
- For orchestrators: use `orchestrator` for root, repo names for subrepos

### Path Rules
- Root repo: use `.`
- Subrepos: use relative path from project root
- Monorepo packages: use package path (`packages/api`)

### Type Classification

| Type | When to Use |
|------|-------------|
| `orchestrator` | Root of multi-repo project with sprint/ |
| `api` | Backend service, REST/GraphQL endpoints |
| `ui` | Frontend application |
| `cli` | Command-line tool |
| `library` | Shared code, npm package |
| `framework` | Distributable framework (like pennyfarthing) |

### Command Extraction

Extract from discovered package.json scripts:
```javascript
{
  "scripts": {
    "test": "jest",      // → test_command: npm test
    "build": "tsc",      // → build_command: npm run build
    "lint": "eslint",    // → lint_command: npm run lint
    "dev": "nodemon"     // → dev_command: npm run dev
  }
}
```

## INTERACTIVE REFINEMENT

Present the generated repos.yaml and ask:

```
📄 Generated repos.yaml
════════════════════════

{yaml_content}

Options:
[A] Accept and write to {output_repos}
[E] Edit a specific repo entry
[N] Add a new repo entry
[D] Delete a repo entry
[P] Preview in different format
```

### Edit Flow
If user selects [E]:
1. List repo keys
2. Ask which to edit
3. Show current values
4. Accept new values
5. Return to main menu

## EXAMPLE OUTPUT

For a typical api+ui project:

```yaml
# Repository Configuration for my-project
# Generated by Pennyfarthing project-setup workflow

repos:
  orchestrator:
    path: .
    type: orchestrator
    description: Project coordination and sprint management
    language: javascript

  api:
    path: my-project-api
    type: api
    description: Backend REST API
    language: typescript
    framework: express
    test_command: npm test
    build_command: npm run build
    lint_command: npm run lint

  ui:
    path: my-project-ui
    type: ui
    description: React frontend application
    language: typescript
    framework: react
    test_command: npm test
    build_command: npm run build
    lint_command: npm run lint
    dev_command: npm run dev
```

## SUCCESS CRITERIA

✅ repos.yaml accurately reflects project structure
✅ All detected repos included
✅ Commands verified and correct
✅ User has reviewed and approved
✅ File written to project root

## NEXT STEP

After repos.yaml is written and approved, proceed to `step-04-claude-md.md` to generate the CLAUDE.md file.
