agent

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const EnvSessionName = "MUXAC_SESSION_NAME"

EnvSessionName is the environment variable used to pass the muxac session name.

Variables

This section is empty.

Functions

func GeminiSessionFilePattern added in v0.0.6

func GeminiSessionFilePattern(homeDir, projectDir, sessionID string) string

GeminiSessionFilePattern returns a glob pattern that matches the Gemini CLI session JSON file for the given project directory and session ID. Returns "" if sessionID is too short (< 8 characters).

func JsonlPath

func JsonlPath(tool Tool, homeDir, projectDir, sessionID string) string

JsonlPath returns the tool-specific JSONL file path. Returns "" for tools that do not support JSONL.

func NormalizeEvent

func NormalizeEvent(tool Tool, rawEvent string) string

NormalizeEvent maps a tool-specific hook event name to the canonical event name used by the status package. For Claude, events are already canonical. For Unknown tools, Claude conventions are used as a fallback.

func ProjectDir

func ProjectDir(tool Tool, geminiProjectDir, claudeProjectDir, hookInputCwd string) string

ProjectDir returns the project directory for the given tool. The hook payload's "cwd" is preferred over env vars because env vars can leak from a parent shell and point at the wrong project.

Types

type Tool

type Tool int

Tool represents a supported agentic coding tool.

const (
	Unknown Tool = iota
	Claude
	Codex
	Gemini
)

func DetectTool

func DetectTool(geminiProjectDir, claudeProjectDir, hookInputCwd string) Tool

DetectTool determines which coding tool is invoking the hook.

The hook payload's "cwd" is the source of truth for the project directory because env vars can leak from a parent shell: e.g. launching `codex` from a Claude Code session inherits CLAUDE_PROJECT_DIR, which would otherwise make us misdetect Codex hook events as Claude.

Detection rules:

  1. GEMINI_PROJECT_DIR matches the hook cwd (or cwd is empty) → Gemini. Gemini CLI sets both GEMINI_PROJECT_DIR and CLAUDE_PROJECT_DIR, so this must be checked before Claude.
  2. CLAUDE_PROJECT_DIR matches the hook cwd (or cwd is empty) → Claude.
  3. cwd is non-empty → Codex. Codex does not set its own project-dir env var on hook commands but always includes "cwd" in the JSON payload.
  4. Otherwise → Unknown.

func ToolFromString

func ToolFromString(s string) Tool

ToolFromString converts a database string back to a Tool value. Empty or unrecognized strings return Unknown.

func (Tool) String

func (t Tool) String() string

String returns the canonical name of the tool.

Jump to

Keyboard shortcuts

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