# 1.6.0 — restyle: apply a caption font/style preset to every caption

Minor release. The new **`restyle`** command ports the CapCut-CaptionStyling font-mirroring patchers (`restyle.py` + `fix_fonts_full.py` + `fix_content_styles_font.py` + `fix_key_value.py`, ~400 lines of Python) into the engine. It applies a caption style preset — font, contour/stroke, shadow, size — to **every** caption of a draft, and is **span-aware**: a multi-span keyword-highlight caption keeps each word's color and range while the font/stroke/shadow change on all spans. This lets the CapCut-CaptionStyling skill become pure orchestration.

## Highlights

- 🎨 **`restyle <project> --preset <preset.json>`.** Applies the preset to every caption on the target text track(s) — default **all** text tracks, `--track-name` to scope to one. Reuses the existing `preset_captions_style.json` schema (`text_material` + `content_template` + `segment`); the bundled CC-DerStil preset works as-is.
- 🌈 **Keyword colors survive.** The exact inverse of `--clone-style`: clone-style keeps the font and varies the color; restyle varies the font/stroke/shadow and **keeps each span's `fill` (keyword color) + `range`**. A caption with gold/red/green words keeps them after the font changes.
- 🔤 **Full material mirroring.** Grafts `font_path` / `font_resource_id` / `fonts[]` (empty `request_id`, so CapCut doesn't wipe the entry on open), `has_shadow` / `shadow_*` / `border_*`, and forces `content.styles[].font` everywhere it lives. Clears `recognize_task_id` (else Auto-Captions regenerate and wipe the style). Preserves `base_content` / `recognize_text` (a latent bug in the Python `restyle.py` blanked them — not ported).
- 🗂️ **Multi-file sidecar mirroring.** Writes the new state to `template-2.tmp` + `draft_content.json.bak`, patches `Timelines/*/mini_draft.json` + `patch.json`, and injects the `key_value.json` registry entry keyed by `resource_id`. All **skip-if-absent**; `key_value.json` is never fabricated.
- 🧹 **Orphan-safe.** Scopes to materials reachable from text-track segments, so the orphaned text materials `import-captions` leaves behind are never touched.
- 📏 **Range fix.** Legacy single-span `add-text` captions store their range in UTF-16 bytes; restyle promotes them to code units (CapCut rich-text convention).
- 🧪 **265 tracked tests** (241 prior + restyle / mirror / register). Validated against a live CapCut render: CC-DerStil + shadow applied, per-word colors survive.

## CLI surface

```
capcut-david restyle <project> --preset <preset.json> [--track-name <name>]
    # preset.json = { "text_material": {...}, "content_template": { "styles": [...] }, "segment": {...} }
    # default targets ALL text tracks; --track-name scopes to one.
```

## Also in this release

- **`register` surfaces new drafts.** CapCut sorts its draft grid by `tm_draft_modified`. A cloned or engine-generated draft inherited a stale timestamp and sank to the bottom of the list — present in `root_meta_info.json` but effectively invisible. `register` now stamps a fresh `tm_draft_modified` on the add path, so newly registered drafts appear at the top.

## Typical flow (replaces the CaptionStyling Python patchers)

1. Build/inject captions as usual (`import-captions`, optionally `--clone-style`).
2. `capcut-david restyle <draft> --preset <preset_captions_style.json>`
3. Reopen CapCut — every caption now carries the preset font + shadow; keyword colors are intact.

## Migration

**No code changes required.** `restyle` is a new command; existing `add-text` / `import-captions` output is byte-for-byte unchanged. The CapCut-CaptionStyling skill can drop its `fix_*.py` + `restyle.py` patchers and call `restyle` instead.

## Known issue

- CapCut's text **dropdown** may show "System" for a preset font even though it renders correctly (CC-DerStil). Pre-existing cosmetic quirk, documented in the skill — export and preview use the correct font.

## Compatibility

- CapCut ≥ 5.x desktop (Windows + macOS), JianYing 6+ unsupported — unchanged.
- Node `>= 18` — unchanged.
- Runtime dependencies: zero — unchanged.
- `restyle` is a separate code path; default `add-text` / `import-captions` output byte-identical to 1.5.0.

## Roadmap (1.x — non-binding)

Unchanged from 1.0.0:

- `1.x.0` — `capcut-david query` (animation / sticker / effect / filter catalogue lookup)
- `1.x.0` — `capcut-david validate <project>` (schema-invariant linter)
- `1.x.0` — JianYing 6+ research; `psycho-build` dynamic audio ducking
