# =domain <name>: one command, six parallel probes of a domain: DNS (A, MX, TXT,
# NS), TLS certificate expiry, HTTP status and response time, and security
# headers (HSTS, CSP, X-Frame-Options). First row is a health verdict (OK, WARN
# under 30 days to expiry or missing HSTS, FAIL on errors), then one row per probe.
# Network call: only the typed domain is contacted (DNS lookups, one TLS
# connection, one HTTPS request; redirects are followed only within the same
# domain or its www form). The script accepts a plain public hostname only: no
# scheme, path, port, IP address or spaces, nothing starting with a dash, and
# nothing that resolves to a private, loopback or link-local address.
# The summary pane shows a response-time bar chart per probe in text (a chart
# pane cannot share the right-hand side with the detail pane).
#
# Sample data: `=domain demo` always shows a fabricated report. With no domain
# typed the list opens on a "Try with sample data" row followed by the same
# rows. Every sample row says SAMPLE DATA. A typed domain that fails gets honest
# FAIL rows, never sample data. A probe whose tool is missing (dig, openssl) is
# marked SKIPPED, not failed.
schema_version: 1
runtime: bridge
id: domain
chip: domain
title: Domain health
icon: globe
description: "Network call: DNS, TLS expiry, HTTP status and time, security headers for one domain, probed in parallel. =domain demo shows sample data"
placeholder_examples: ["sparcle.app", "github.com", "demo"]
emits: Generic

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

args:
  - { name: domain, from: "query.word(0)", default: "" }

presentation:
  widget: list
  title_field: title
  subtitle_field: subtitle
  searchable: true
  right_widget:
    kind: entity_preview
    mode: selected_row
    bind:
      title: "{{row.domain}}"
      subtitle: "{{row.title}}"
      fields:
        - { label: Status, value: "{{row.status}}", kind: badge }
        - { label: Probe, value: "{{row.probe}}" }
        - { label: Time, value: "{{row.ms}} ms" }
        - { label: URL, value: "{{row.url}}" }
      body: "{{row.body}}"
      actions: [open, copy-value, copy-domain]

actions:
  - { id: open, kind: url, target: row, label: Open site, url_template: "{{row.url}}", primary: true }
  - { id: copy-value, kind: composer, target: row, label: Copy result, insert: "{{row.value}}" }
  - { id: copy-domain, kind: composer, target: row, label: Copy domain, insert: "{{row.domain}}" }
