presence

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package presence turns Claude Code hook and status-line payloads into presence updates (RFC 6.4, 7.4). Hooks print nothing and always exit 0.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EventFor

func EventFor(hook string) string

EventFor maps a hook name to a presence event.

func InWorker

func InWorker() bool

InWorker reports whether this process runs inside a Smif worker, where user hooks also fire but must not count as an interactive session.

func Locate

func Locate() (pid int, tty string)

Locate finds the claude process this hook runs under (walking up from the parent) and its terminal device, so the human can later type a prompt into that session (ADR-0012). It returns 0, "" when there is none (no claude ancestor, or no terminal).

func Term

func Term() string

Term names the terminal from the hook's environment: "tmux" inside tmux, "herdr" in a herdr pane, else $TERM_PROGRAM (Apple_Terminal, iTerm.app, …). With both set the daemon's process walk decides.

func Transcript

func Transcript(path string) (title, lastPrompt string)

Transcript reads the session's name (claude --name, /rename) and the human's last prompt from the end of its transcript. Missing or unreadable files give "", "".

Types

type Payload

type Payload struct {
	SessionID string `json:"session_id"`
	Cwd       string `json:"cwd"`
	Event     string `json:"hook_event_name"`
	// TranscriptPath is the session's JSONL transcript; Prompt is the
	// submitted text (UserPromptSubmit only).
	TranscriptPath string `json:"transcript_path"`
	Prompt         string `json:"prompt"`
	Workspace      struct {
		CurrentDir string `json:"current_dir"`
		ProjectDir string `json:"project_dir"`
	} `json:"workspace"`
}

Payload is the subset of a hook or status-line stdin JSON we use.

func Parse

func Parse(b []byte) Payload

Parse reads a payload; missing fields fall back to the process cwd.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL