Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,5 @@ jobs:
- name: Lint
run: bun run lint

- name: Doctor
run: bun run doctor

- name: Fast tests
run: bun run test:fast
62 changes: 20 additions & 42 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,75 +2,53 @@

## Purpose

This repo is an Instagram media export lab. It provides deterministic CLI slices for recommending upload profiles, analyzing fixtures, exporting image/video media, generating overlay guides, previewing grid crops, and running validation matrices.
This repo is a v1 Instagram image-prep tool. The production surface is one command:

```bash
bun run prepare-image <input> --out <file-path> [--border-px <integer>]
```

The command accepts PNG, JPEG, and TIFF images, places them on a white canvas, and exports a high-quality baseline sRGB JPEG for manual Instagram app upload.

## Prerequisites

- Bun 1.3 or newer.
- TypeScript through `bunx tsc`.
- `ffmpeg` and `ffprobe` on `PATH`.
- macOS `sips` only when regenerating PNG/JPEG raster fixtures with `bun run fixtures:images:raster`.

Run `bun run doctor` after install to verify local tools, writable temp/output directories, and required fixture media.

## Install

```bash
bun install --frozen-lockfile
bun run doctor
```

## Quality Gates

Use `bun run check` before small PRs. It runs typecheck, Biome lint, and fast tests.

Use `bun run test:ci` for the same gate CI runs. Use `bun run test:slow` before changing ffmpeg-heavy export, report-export, benchmark, validate-matrix, e2e, visual, or property behavior.

The full test suite is intentionally explicit about timeout with `bun run test:all`, because ffmpeg-heavy tests should not rely on Bun's default 5 second per-test timeout.
Use `bun run check` before PRs. It runs typecheck, Biome lint, unit tests, and the v1 integration test.

## Common Commands

```bash
bun run recommend --mode reliable --surface feed --orientation portrait --json
bun run analyze tests/fixtures/images/portrait_sample_30x40.png --mode reliable --surface feed --json
bun run export-image tests/fixtures/images/portrait_sample_30x40.png --out tests/fixtures/exports/demo.jpg --mode reliable --surface feed --json
bun run export-video tests/fixtures/images/portrait_video_360x640.mp4 --out tests/fixtures/exports/demo.mp4 --mode reliable --surface reel --json
bun run validate-matrix tests/fixtures/matrix/cases_basic.json --json
bun run prepare-image /full/path/input.png --out /full/path/exports/photo
bun run prepare-image /full/path/input.tiff --out /full/path/exports/photo.png --border-px 0
bun run prepare-image --help
```

## Test Layers

- `bun run test:unit`: pure domain and helper tests.
- `bun run test:fast`: unit tests plus lightweight CLI/overlay/grid/watch-folder integration tests.
- `bun run test:slow`: ffmpeg-heavy integration, e2e, visual, and property suites.
- `bun run test:unit`: pure layout and output path tests.
- `bun run test:integration`: the v1 CLI/FFmpeg integration test.
- `bun run test:fast`: unit plus v1 integration tests.
- `bun run test:all`: every Bun test with an explicit 30 second timeout.

## Fixture Regeneration

Only regenerate fixtures when behavior intentionally changes.

```bash
bun run fixtures:images
bun run fixtures:images:raster
bun run fixtures:e2e
bun run fixtures:visual
bun run fixtures:pixel
```

`fixtures:images:raster` uses `sips`, so it is macOS-only. Video fixtures use `ffmpeg`.

## Architecture Map

- `src/cli`: command entry points and argument parsing.
- `src/domain`: deterministic policy, analysis, export, report, benchmark, and validation logic.
- `src/types/contracts.ts`: shared public contracts.
- `config`: versioned ruleset and export profile JSON.
- `tests/fixtures`: source media and golden outputs.

## Known Slow Areas

The slowest tests are export, export-video, report-export, benchmark, validate-matrix, e2e snapshots, and pixel visual checks. They invoke ffmpeg, ffprobe, or compare generated media artifacts.
- `src/cli/prepare_image.ts`: command parsing and stdout/stderr behavior.
- `src/domain/prepare_image.ts`: source probing, layout selection, and FFmpeg export.
- `src/domain/prepare_image_layout.ts`: pure target, border, crop, and contain math.
- `src/domain/output_path.ts`: `.jpg` normalization, parent directory creation, and suffixing.
- `src/domain/media_process.ts`: FFmpeg/ffprobe process boundary.

## Branch Knowledge

For feature branches, update the relevant file in `docs/` with the problem, decisions, commands run, and lessons learned. For this refresh stack, use `docs/repo_refresh_audit.md`.
For feature branches, update the relevant markdown in `docs/plans/` with the problem, decisions, commands run, and lessons learned.
112 changes: 22 additions & 90 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,121 +1,53 @@
# instagram-upload-quality-lab
# Passepartout

Deterministic Bun CLIs for experimenting with Instagram-oriented media recommendations, exports, reports, and validation matrices.
One-command image prep for manual Instagram app uploads.

The project currently supports profile recommendations, media inspection, image/video export through ffmpeg, white-canvas variants, crop-safe overlays, profile-grid previews, watch-folder scans, report-export comparisons, and benchmark summaries.
`prepare-image` puts a PNG, JPEG, or TIFF source image on a white canvas and writes a high-quality baseline sRGB JPEG.

## Prerequisites

- Bun 1.3 or newer.
- TypeScript through `bunx tsc`.
- `ffmpeg` and `ffprobe` on `PATH`.
- macOS `sips` only if you regenerate raster image fixtures.

## Install

```bash
bun install --frozen-lockfile
bun run doctor
```

## Run

Recommend an upload profile:

```bash
bun run recommend --mode reliable --surface feed --orientation portrait --json
```

Analyze fixture media:

```bash
bun run analyze tests/fixtures/images/portrait_sample_30x40.png --mode reliable --surface feed --json
```

Export an image:

```bash
bun run export-image tests/fixtures/images/portrait_sample_30x40.png --out tests/fixtures/exports/demo.jpg --mode reliable --surface feed --json
```

Export a video:

```bash
bun run export-video tests/fixtures/images/portrait_video_360x640.mp4 --out tests/fixtures/exports/demo.mp4 --mode reliable --surface reel --json
```

Generate overlay and grid-preview geometry:
## Usage

```bash
bun run overlay --ratio 4:5 --json
bun run grid-preview --ratio 4:5 --json
bun run prepare-image /full/path/input.png --out /full/path/exports/photo
```

Run a validation matrix:

```bash
bun run validate-matrix tests/fixtures/matrix/cases_basic.json --json
```
Options:

## Upload Workflows
- `--out <file-path>`: required output path. The extension is normalized to `.jpg`.
- `--border-px <integer>`: optional non-negative border size. Default is `57`. `0` is valid.

Use `--workflow api_scheduler` for conservative API-compatible feed exports. This keeps feed white-canvas output on the `feed_compat` profile at `1080x1350` and report checks include the 8 MiB image baseline.
Rules:

Use `--workflow app_direct --white-canvas --canvas-profile feed_app_direct` when testing app-only 3:4 feed uploads. This selects the `1080x1440` white-canvas profile and reports a reminder to enable high-quality uploads before posting.
- Landscape inputs (`width > height`) export as `3:2`, up to `2160x1440`.
- Portrait and square inputs export as `3:4`, up to `1440x1920`.
- Small inputs are not upscaled; output shrinks while preserving the selected ratio.
- Existing outputs are never overwritten. Collisions use `photo-1.jpg`, `photo-2.jpg`, and so on.
- Success prints only the actual output path.
- EXIF orientation is applied visually before choosing the export ratio.
- EXIF/XMP metadata is stripped from the output.

## Quality Gates
## Quality Gate

```bash
bun run typecheck
bun run lint
bun run check
```

`bun run check` is the normal pre-PR gate: typecheck, lint, and fast tests.

Test layers:

```bash
bun run test:unit
bun run test:fast
bun run test:ci
bun run test:slow
bun run test:all
```

`test:slow` and `test:all` use an explicit 30 second per-test timeout for ffmpeg-heavy cases.

## Fixtures

Source fixtures live under `tests/fixtures/images`. Generated export outputs go to `tests/fixtures/exports`.

Regenerate fixtures only when behavior intentionally changes:

```bash
bun run fixtures:images
bun run fixtures:images:raster
bun run fixtures:e2e
bun run fixtures:visual
bun run fixtures:pixel
```

`fixtures:images:raster` depends on macOS `sips`. Video fixture generation depends on `ffmpeg`.
This runs typecheck, Biome lint, unit tests, and the v1 integration test.

## Docs

- `AGENTS.md`: fresh-clone setup, quality gates, architecture map, and agent workflow notes.
- `docs/repo_refresh_audit.md`: refresh audit findings, decisions, and follow-up order.
- `docs/repo_refresh_feature_set.md`: current feature inventory for v1 scope splitting.
- `docs/v1_split_plan.md`: actionable plan for cutting the repo down to v1.
- `docs/phase1_knowledge.md`: previous milestone implementation notes.

<!-- status:start -->
## Status
- State: active
- Summary: Repo refresh stack in progress.
- Next: Submit Graphite stack after checks pass.
- Updated: 2026-05-01
- Branch: `repo-refresh-onboarding-ci`
- Working Tree: clean
- Last Commit: chore: add repo refresh onboarding and CI
<!-- status:end -->
- `docs/v1_split_plan.md`: product contract and split plan.
- `docs/plans/decisions-log.md`: decision log.
- `docs/plans/v1-prepare-image-layout.md`: layout slice notes.
- `docs/plans/v1-prepare-image-cli.md`: CLI slice notes.
123 changes: 0 additions & 123 deletions config/export_profiles.v1.json

This file was deleted.

Loading
Loading