# Phase 1 — Classify Inputs & Check Index

You are at the project intake step. The user passed `$ARGUMENTS` in this form:

```text
<project-slug> [audio/text paths, globs, and/or inline text]
```

Your job: validate the project slug, build an ordered manifest, and decide which sources are already ready in `docs/inputs/<project-slug>/index.json`. Do NOT transcribe or write resource records yet.

Run the following:

```
1. Parse `$ARGUMENTS`.
   - The first token MUST be `<project-slug>`.
   - If missing, STOP with `⚠️ NEEDS INPUT: indica el project slug, por ejemplo /machine-business:process-input acme-demo`.
   - The project slug MUST be kebab-case ASCII: lowercase letters, numbers, and single hyphens.
   - Everything after the slug is the input list.
   - If the input list is empty, use `docs/inputs/<project-slug>/raw/*`.

2. Resolve the project paths:
   - Input root: `docs/inputs/<project-slug>/`
   - Raw inbox: `docs/inputs/<project-slug>/raw/`
   - Resource records: `docs/inputs/<project-slug>/transcriptions/`
   - Index: `docs/inputs/<project-slug>/index.json`

3. Ensure the project input directories exist:
   - Create `docs/inputs/<project-slug>/raw/` only if missing.
   - Create `docs/inputs/<project-slug>/transcriptions/` only if missing.
   - Do not delete, move, migrate, or overwrite any existing file.

4. Read or initialize `index.json`.
   - If missing, create the initial JSON contract:
     {
       "project": "<project-slug>",
       "inputs": []
     }
   - If present, it MUST be valid JSON, `project` MUST equal `<project-slug>`, and `inputs` MUST be an array.
   - If invalid, STOP with `⚠️ NEEDS INPUT` and explain the exact index problem.

5. Expand and classify the input list, preserving order:
   - AUDIO  — path ends in one of: .m4a .mp3 .wav .ogg .oga .opus .flac .aac .webm .mp4
   - TEXT   — path ends in one of: .txt .md .markdown
   - GLOB   — contains a wildcard (* ? [). Expand it; classify each resulting path. Keep sorted order within the glob.
   - INLINE — anything that is not a path.

6. Validate each item:
   - AUDIO / TEXT path: confirm the file exists and is readable. If not, mark `⚠️ NEEDS INPUT: <path> not found — confirm the correct path or remove it` and STOP.
   - TEXT path: read enough to confirm it is non-empty. Empty text files are `⚠️ NEEDS INPUT`.
   - GLOB matching zero files: STOP with `⚠️ NEEDS INPUT: glob <pattern> matched no files`.
   - Unknown extension on an existing path: ask whether it is audio or text. Do not guess from content.
   - INLINE: keep verbatim. Number inline notes with the current interaction-language inline-note label plus a number.

7. Check each source against `index.inputs`:
   - Use `src` as the identity: `raw/<filename>` for files under the project raw folder, the project-relative path for explicit project files, or `inline:<N>` for inline notes.
   - If an entry exists with matching `src`, `status: ready`, and readable `md`, mark the manifest row `reuse`.
   - If the source exists with `status: failed`, mark the manifest row `retry`.
   - If the source exists but its `md` is missing/unreadable, mark the manifest row `reprocess` and keep the old index data for Phase 3 to update.
   - If the source is new, mark the manifest row `new`.

RULES:
- Preserve manifest order. Order is meaningful in final reports and later proposal synthesis.
- Do not read full audio binaries.
- Do not transcribe in this phase.
- Do not write resource `.md` files in this phase.
- Resolve every `⚠️ NEEDS INPUT` before leaving this phase.
```

OUTPUT FORMAT — present the manifest as a numbered table:

| # | Type | Source | Decision | Status |
|---|------|--------|----------|--------|
| 1 | AUDIO | docs/inputs/acme/raw/memo1.m4a | new | ok |
| 2 | TEXT | docs/inputs/acme/raw/notes.md | reuse | ready: transcriptions/notes.md |
| 3 | INLINE | Nota inline 1 | new | ok |

ADVANCE: show the manifest, then continue straight to Phase 2 without asking for approval.

STOP only if something is unresolved:
- missing/invalid project slug;
- invalid `index.json`;
- missing/unreadable/empty file;
- zero-match glob;
- unknown extension on an existing path.
