# Project Index Update

## Overview

Updates the project index with handoff status tracking after PRD generation.

Two-tier approach:
- **Primary (ba-006):** Project-level index in `{docs_dir}/index.json` (autonomous per project)
- **Legacy (pre-ba-006):** Global manifest in `docs/index.json` for backward compatibility

## Primary Flow: Update Project-Level Index

For each processed module, update the project's own `{docs_dir}/index.json` manifest.

### Update Logic

1. Read `{docs_dir}/index.json` (project master index)
2. Update status to `"handed-off"` for each processed module
3. Update `metadata.lastModified` timestamp
4. Write back to `{docs_dir}/index.json`
5. Display confirmation: "Project index updated: {docs_dir}/index.json (status: handed-off)"

## Legacy Flow: Update Global Manifest (if exists)

For backward compatibility with pre-ba-006 projects, if `docs/index.json` global manifest exists, also update it.

### Structure

```json
{
  "version": "1.0",
  "updatedAt": "{ISO timestamp}",
  "analyses": [
    {
      "appCode": "{app_code}",
      "appName": "{application_name}",
      "moduleCode": null | "{module_code}",
      "moduleName": "{module_name}",
      "version": "{version}",
      "status": "handed-off",
      "featureDescription": "{description}",
      "path": "{projectSlug}/v{version}/index.json",
      "updatedAt": "{ISO timestamp}"
    }
  ]
}
```

### Fields

| Field | Notes |
|-------|-------|
| `appCode` | Application identifier |
| `appName` | Human-readable application name |
| `moduleCode` | Module identifier (null if global module) |
| `moduleName` | Module name |
| `version` | Feature/module version |
| `status` | Always "handed-off" after update |
| `featureDescription` | Module description from BA |
| `path` | Reference path (format: `{projectSlug}/v{version}/index.json`) |
| `updatedAt` | ISO timestamp of last update |

### Update Steps

1. Read existing `docs/index.json` if present
2. For each module, add or update entry in `analyses` array
3. Set `status: "handed-off"`
4. Update global `updatedAt` timestamp
5. Write back to `docs/index.json`
6. Display confirmation: "Legacy index updated: docs/index.json"

## Execution Order

```
1. Update {docs_dir}/index.json (primary)
   └─ Always execute for ba-006+

2. IF docs/index.json exists
   └─ Update with legacy structure (backward compat)
```

## Display Messages

### Primary Update
```
Project index updated: {docs_dir}/index.json (status: handed-off)
```

### Legacy Update (if applicable)
```
Legacy index updated: docs/index.json ({count} modules)
```

## Key Notes

- **ba-006 Standard:** Projects are autonomous — no global manifest required
- **Backward Compatibility:** Legacy projects using global `docs/index.json` continue to work
- **No Global Dependency:** CLI does not maintain a global registry; each project is self-contained
