# =resize <path> [width]: shrink or grow an image with the built-in macOS `sips`.
# Default width is 1280. The result is a sibling file named <name>-resized.<ext>
# (a number is added if that name is taken); the original is never touched.
# macOS only: Windows and Linux get one clear "macOS only" row.
#
# Rows are files: `emits: File` with an absolute `path`, so Enter opens the new
# image, Tab gives the file action card and Space previews it. There is
# deliberately NO `primary: true` action, which would take Enter away from the
# file behaviour.
#
# Symlinks: the typed path is resolved first, so the new file is written beside the
# link's TARGET, not beside the link, and the original (the target) is never changed.
# The output name is reserved atomically (O_CREAT|O_EXCL), the work is written to a
# private temp file in the same folder and renamed onto that name, so nothing is ever
# overwritten and a failed run leaves no files behind.
#
# Sample data: `=resize demo` always shows fabricated rows. With no path typed
# the list opens on a "Try with sample data" row followed by the same rows.
# Every sample row says SAMPLE DATA and has no path (it is not a file). A typed
# path that fails gets an honest error row, never sample data.
schema_version: 1
runtime: bridge
id: resize
chip: resize
title: Resize image
icon: image
description: "Resize an image to a width (default 1280) into a sibling name-resized file. macOS only. =resize demo shows sample data"
placeholder_examples: ["~/photos/trip.png", "~/photos/trip.jpg 800", "demo"]
emits: File

dispatch:
  confirm_label: 'Resize: {{query}}'
  confirm_hint: "Press ↵ to resize · path then optional width · original is never changed"

bridge:
  command:
    macos:   "python3 {{scripts_dir}}/bolt-resize.py {{query}}"
    linux:   "python3 {{scripts_dir}}/bolt-resize.py {{query}}"
    windows: "python {{scripts_dir}}/bolt-resize.py {{query}}"
  parse: json
  timeout_seconds: 30

presentation:
  widget: list
  title_field: title
  subtitle_field: subtitle
  searchable: false
  # What happened, in words: which file was kept and which one is new. Enter,
  # Tab and Space on the row stay the launcher's file behaviour.
  right_widget:
    kind: markdown
    mode: selected_row
    bind:
      title: "{{row.title}}"
      subtitle: "{{row.subtitle}}"
      body: "{{row.body}}"
      actions: [copy-path]

actions:
  - { id: copy-path, kind: composer, target: row, label: Copy path, insert: "{{path}}" }
