# code-submit

Project-local Pi skill and extension for submission-oriented workflows.

## Included pieces

- `.agents/skills/code-submit/` — skill for implementing changes, generating `.submissions/<change-slug>.html`, and opening a GitHub draft PR
- `.pi/extensions/submissions-browser.ts` — TUI browser for submission HTML files
- `scripts/test-submissions-browser.sh` — interactive harness for exercising the TUI locally

## Interactive TUI harness

Run:

```bash
./scripts/test-submissions-browser.sh
```

This will:

- ensure `.submissions/` exists
- create a sample HTML submission if one is not present yet
- launch `pi`
- let you run `/submissions` interactively

## TUI usage

Inside Pi:

```bash
/submissions
```

or

```bash
/submissions <directory>
```

### What the TUI shows

- a **navigable list** of submission HTML files on the left
- a **preview pane** on the right with extracted title, key headings, and summary text
- file metadata: size and last-modified timestamp

### Controls

| Key             | Action                                      |
|-----------------|---------------------------------------------|
| `↑` / `↓`      | Navigate the file list                      |
| type any text   | Filter by title, path, headings, or summary |
| `Backspace`     | Delete last filter character                 |
| `Ctrl+S`        | Cycle sort order: name → newest → largest   |
| `Enter`         | Open selected submission in the browser      |
| `Esc`           | Clear filter, or cancel if filter is empty   |

### Sort modes

The TUI cycles through three sort orders with `Ctrl+S`:

1. **name** — alphabetical by filename (default)
2. **newest** — most recently modified first
3. **largest** — biggest file size first

### Filter

Typing any printable character appends it to the filter query. The filter matches against the file path, report title, headings, and summary text. Matching is case-insensitive. The file list and preview update in real time as you type.

## Skill usage

Invoke the skill explicitly:

```bash
/skill:code-submit
```

The skill will:

1. implement the requested changes
2. run tests and lint if configured (non-blocking)
3. derive a `<change-slug>` from the task title (e.g. `Fix cache bug` → `fix-cache-bug`)
4. generate `.submissions/<change-slug>.html`
5. create a branch and commit
6. open a **GitHub draft PR**
7. return a summary with branch, commit, PR URL, report path, and validation results