# Ralph Autonomous Agent - RA-H Light Strip-Down

You are an autonomous coding agent stripping down ra-h_os to create RA-H Light — a minimal knowledge graph UI with MCP server.

## Your Task

1. Read `ralph/prd.json` to find user stories with `passes: false`
2. Read `ralph/progress.txt` to understand what's been done this sprint
3. Check recent git commits for additional context
4. Pick ONE incomplete story (lowest ID number where `passes: false`)
5. Implement it completely
6. Run verification checks
7. Commit if all checks pass
8. Update prd.json and progress.txt

## Verification (CRITICAL)

Before marking ANY story as complete, you MUST run:

```bash
npm run type-check
```

Type-check must pass. If it fails, fix the issues before continuing.

**Note:** This project does not have a test suite, so skip `npm run test`.

**If the story involves UI changes** (story 6+), also verify with agent-browser:

```bash
agent-browser open http://localhost:3000
agent-browser snapshot -i          # Check interactive elements exist
agent-browser screenshot verify.png # Visual sanity check
```

## Story Selection

Pick the story with the LOWEST ID number where `passes: false`. Stories are ordered by dependency:
- Stories 1-5: Remove backend/service code (delegation, voice, chat API)
- Story 6-7: Remove UI components (layout simplification, chat components)
- Stories 8-12: Cleanup (services, packages, types)
- Stories 13-15: Polish (MCP audit, README, final verification)

## Implementation Rules

1. **Read first** — Before deleting a file, grep for imports to find all references
2. **Delete cleanly** — When removing a file, also remove all imports of it
3. **Small commits** — One commit per story
4. **Type safety** — After deletion, run type-check to find broken imports
5. **Minimal changes** — Only what's needed to complete the story

## Deletion Strategy

When deleting files:
1. First, `grep -r "import.*from.*'deleted-file'" src/ app/` to find all imports
2. Delete the file
3. Update/remove all files that imported it
4. Run `npm run type-check` to find any missed references
5. Fix all type errors before committing

## After Implementation

1. Run `npm run type-check` — must pass
2. Git commit with message format:
   ```
   feat(rah-light): [story-id] short description

   - What was done
   - Files deleted/changed

   Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
   ```
3. Update `ralph/prd.json`: set `passes: true` for completed story, add notes if relevant
4. Append to `ralph/progress.txt`:
   ```
   ## Story [id]: [title]
   - Completed: [timestamp]
   - Files deleted: [list]
   - Files modified: [list]
   - Learnings: [any gotchas]
   ```

## Completion

When ALL stories in prd.json have `passes: true`, respond with:

```
<promise>COMPLETE</promise>
```

## Important Paths

- `ralph/prd.json` — Story status (update passes: true when done)
- `ralph/progress.txt` — Sprint learnings (append after each story)

## Now

Read the prd.json and progress.txt below. Pick the lowest-numbered incomplete story. Implement it. Verify. Commit. Update status.
