Skip to content
This repository was archived by the owner on Oct 4, 2026. It is now read-only.
This repository was archived by the owner on Oct 4, 2026. It is now read-only.

Core plugin: extract existing notify.js with config parsing #2

Description

@athal7

Overview

Extract the existing notification plugin from chezmoi dotfiles and add comprehensive configuration parsing.

Current Implementation

export const Notify = async ({ $ }) => {
  const topic = process.env.NTFY_TOPIC
  if (!topic) return {}

  const cwd = process.cwd()
  const dir = cwd.split("/").pop() || cwd
  const DELAY_MS = 5 * 60 * 1000

  let timer = null

  return {
    event: async ({ event }) => {
      if (event.type === "session.status") {
        const status = event.properties?.status?.type
        if (status === "idle" && !timer) {
          timer = setTimeout(async () => {
            try {
              await $`curl -sf -d ${dir} -H "Title: OpenCode" ${"ntfy.sh/" + topic}`.quiet()
            } catch {}
            timer = null
          }, DELAY_MS)
        } else if (status === "busy" && timer) {
          clearTimeout(timer)
          timer = null
        }
      }
    },
  }
}

Environment Variables

Variable Required Default Description
NTFY_TOPIC Yes - ntfy topic name
NTFY_SERVER No https://ntfy.sh ntfy server URL
NTFY_CALLBACK_HOST No (auto-discover) Callback host for action buttons
NTFY_CALLBACK_PORT No 4097 Callback server port
NTFY_CALLBACK_SECRET No (auto-generate) HMAC secret for tokens
NTFY_IDLE_DELAY_MS No 300000 Idle notification delay (5 min)
NTFY_ERROR_NOTIFY No true Enable error notifications
NTFY_ERROR_DEBOUNCE_MS No 60000 Error debounce window
NTFY_RETRY_NOTIFY_FIRST No true Notify on first retry
NTFY_RETRY_NOTIFY_AFTER No 3 Also notify after N retries

Tasks

  • Create plugin/index.js with config parsing
  • Preserve existing idle notification behavior
  • Add logging for configuration status
  • Handle missing NTFY_TOPIC gracefully (return empty plugin)

Acceptance Criteria

  • Plugin loads without errors
  • Idle notifications work as before
  • All env vars are parsed with defaults

Activity

  1. added a commit that references this issue on Jan 1, 2026
  2. added a commit that references this issue on Jan 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions