# =pulse <topic>: one ranked feed about a topic, merged from public sources
# that need no account, fetched in parallel (6 s each, one overall deadline):
#   Hacker News (hn.algolia.com search), Mastodon (mastodon.social public hashtag
#   timeline) and a Wikipedia summary card (en.wikipedia.org).
# Bluesky is NOT a source: its public search endpoint answers HTTP 403 without
# an account, so it was dropped rather than faked.
# With no topic it shows the Hacker News front page only, and says so.
#
# Network and privacy: HTTPS only, to a fixed list of host names in
# scripts/bolt_safenet.py. The typed topic is only ever percent-encoded into a
# path or query, never used as a host. No cookies, no sign-in, no tokens; the
# only header that names anything is a User-Agent of "BoltPulse/<version>".
# Responses over 1 MB are ignored. Fetched text is treated as hostile: control
# characters stripped, links replaced by a plain marker, Markdown escaped, only
# links on the source's own domain are offered as "Open post".
# Social posts are NOT moderated. They are shown as written, each with its
# source on the row. Mastodon posts with a content warning or sensitive flag
# are dropped.
#
# Sample data: `=pulse demo`, and the case where no source answered, show
# fabricated rows, each marked SAMPLE DATA. A source that fails on its own is
# reported by name in the first row, never filled with sample data.
schema_version: 1
runtime: bridge
id: pulse
chip: pulse
title: Topic pulse
icon: activity
description: "Network call: what you type is sent to hn.algolia.com, mastodon.social and en.wikipedia.org when you press Enter, and those sites see your IP address. Nothing is sent while you type. Add the word nosocial to skip Mastodon. =pulse demo shows sample data"
placeholder_examples: ["rust", "local first software", "rust nosocial", "demo (sample data)"]
emits: Generic

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

args: []

# Bridge apps never run on keystrokes: the launcher shows this confirm row and
# runs the command only on Enter (the contract rejects any other mode). So
# nothing, not even the empty =pulse front-page lookup, leaves the device early.
dispatch:
  confirm_label: 'Pulse: {{query}}'
  confirm_hint: "Press Enter to send this text to hn.algolia.com, mastodon.social and en.wikipedia.org (they see your IP address). Empty = Hacker News front page only. Add nosocial to skip Mastodon. demo = sample data, nothing sent"

presentation:
  widget: list
  title_field: title
  subtitle_field: subtitle
  right_widget:
    kind: entity_preview
    mode: selected_row
    bind:
      title: "{{row.title}}"
      subtitle: "{{row.subtitle}}"
      fields:
        - { label: Source, value: "{{row.source}}" }
        - { label: Author, value: "{{row.author}}" }
        - { label: Age, value: "{{row.age}}" }
        - { label: Score, value: "{{row.score}}" }
      body: "{{row.body}}"
      actions: [open, copy, narrow]

actions:
  - { id: open, kind: url, target: row, label: Open post, url_template: "{{row.url}}" }
  - { id: copy, kind: composer, target: row, label: Copy quote, insert: "{{row.copy}}" }
  - { id: narrow, kind: utility, target: row, label: Narrow, target_chip: pulse, query_template: "{{row.topic}} " }
