min_version = "2026.2.4"

[vars]
platform = "emery"
screenshot = "screenshot_emery.png"
python_version = "3.13"
pebble_tool_version = "5.0.37"
pebble_tool_python = "{{env.HOME}}/.local/share/mise/installs/pipx-pebble-tool/{{vars.pebble_tool_version}}/pebble-tool/bin/python"
app_icons_script = "{{env.HOME}}/.agents/skills/pebble-watchface/scripts/create_app_icons.py"
preview_gif_script = "{{env.HOME}}/.agents/skills/pebble-watchface/scripts/create_preview_gif.py"

[tools]
node = "22"
"aqua:tamasfe/taplo" = "0.10.0"
"npm:prettier" = "3.8.1"
"pipx:pebble-tool" = { version = "{{vars.pebble_tool_version}}", uvx_args = "--python {{vars.python_version}}" }

[tasks.fmt]
description = "Format C, PebbleKit JS, JSON, Markdown, and TOML"
run = ["mise run c:fmt", "mise run prettier:fmt", "mise run toml:fmt"]

[tasks.lint]
description = "Check formatting"
run = ["mise run c:lint", "mise run prettier:lint", "mise run toml:lint"]

[tasks.fix]
description = "Format and run lightweight checks"
run = ["mise run fmt", "mise run lint"]

[tasks.build]
description = "Build the Pebble PBW"
run = "pebble build"

[tasks.check]
description = "Format, lint, and build without requiring an emulator"
run = ["mise run fix", "mise run build"]

[tasks.clean]
description = "Remove Pebble build artifacts"
run = "pebble clean"

[tasks."c:fmt"]
description = "Format Pebble C code"
run = "clang-format -i src/c/main.c"

[tasks."c:lint"]
description = "Check Pebble C formatting"
run = "clang-format --dry-run --Werror src/c/main.c"

[tasks."prettier:fmt"]
description = "Format JS, JSON, and Markdown"
run = "prettier --trailing-comma none --write README.md PRODUCT.md package.json src/pkjs/index.js"

[tasks."prettier:lint"]
description = "Check JS, JSON, and Markdown formatting"
run = "prettier --trailing-comma none --check README.md PRODUCT.md package.json src/pkjs/index.js"

[tasks."toml:fmt"]
description = "Format TOML"
run = "taplo fmt mise.toml"

[tasks."toml:lint"]
description = "Check TOML formatting"
run = "taplo fmt --check mise.toml"

[tasks.size]
description = "Analyze Pebble app ELF size"
depends = ["build"]
run = "pebble analyze-size build/{{vars.platform}}/pebble-app.elf"

[tasks.install]
description = "Install the app in the Pebble emulator"
run = "pebble install --emulator {{vars.platform}}"

[tasks."emu:config"]
description = "Open the app-provided config page in the Pebble emulator"
run = "pebble emu-app-config --emulator {{vars.platform}}"

[tasks."install:cloudpebble"]
description = "Install the app on a paired device through CloudPebble"
run = "pebble install --cloudpebble"

[tasks.screenshot]
description = "Capture an emulator screenshot"
run = "pebble screenshot --no-open --emulator {{vars.platform}} {{vars.screenshot}}"

[tasks.logs]
description = "Stream emulator logs"
run = "pebble logs --emulator {{vars.platform}}"

[tasks."emu:up"]
description = "Press the emulator up button"
run = "pebble emu-button click up --emulator {{vars.platform}}"

[tasks."emu:select"]
description = "Press the emulator select button"
run = "pebble emu-button click select --emulator {{vars.platform}}"

[tasks."emu:down"]
description = "Press the emulator down button"
run = "pebble emu-button click down --emulator {{vars.platform}}"

[tasks."emu:back"]
description = "Long-press the emulator back button"
run = "pebble emu-button click back --duration 2000 --emulator {{vars.platform}}"

[tasks.icons]
description = "Generate app icons from the current emulator screenshot"
run = "{{vars.pebble_tool_python}} {{vars.app_icons_script}} ."

[tasks.gif]
description = "Generate an emulator preview GIF"
run = "{{vars.pebble_tool_python}} {{vars.preview_gif_script}} . --frames 8 --delay 400"
