npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@miadi/hooks-core

v0.3.0

Published

Core hook taxonomy, event envelope, payload/sessiondata runtime, validators and per-agent adapters for Miadi multi-agent hook suites.

Downloads

486

Readme

@miadi/hooks-core

Core package for the multi-agent hook system. This package provides the canonical event taxonomy, event envelope structures, payload normalization, sessiondata management, and per-agent adapters.

Architecture intent: hooks-core is the local-first canonical event package for agent hooks and terminal observations. tide-runtime owns tmux observation and approval harness behavior beneath it; an optional future hooks-gateway owns HTTP receiver, ledger, queue, and worker boundaries above it.

🚀 Installation

npm install @miadi/hooks-core

🛠 Usage

CLI Integration

The miadi-hooks CLI is designed to be called from your agent's hook configuration (e.g., hooks.json or settings.json). It reads the hook payload from stdin.

# Example: Using with Claude-Code
# In your hook script:
cat | miadi-hooks claude UserPromptSubmit

Programmatic Usage

You can use the runtime pipeline directly in your TypeScript projects:

import { processHookEvent, getAdapter } from '@miadi/hooks-core';

const adapter = getAdapter('claude');
const rawPayload = '{ "message": "hello" }';

const result = processHookEvent(adapter, 'UserPromptSubmit', rawPayload);
if (result.status === 'recorded') {
  console.log(`Event recorded in ${result.sessionDir}`);
}

✨ Key Features

  • Canonical Event Taxonomy: Unified event names (session.start, tool.before, etc.) across Claude, Codex, Gemini, Hermes, and Copilot.
  • Routing Metadata: Each adapter can declare platform / source / model sources, resolved like session IDs. The envelope carries a routing block so a consumer can tell a telegram turn from a cli or discord turn without re-parsing provider payloads.
  • Session Index: Opt-in sessionIndexSink appends one compact line per session to data/session_index.jsonl on session.start — browse a sessiondata root without opening every per-session ledger.
  • Event Envelope: Standardized HookEventEnvelope with deterministic idempotency keys and trace support (routing is excluded from the idempotency key, so replays stay stable).
  • Adapters: Built-in adapters for all 5 major agents to normalize native events and resolve session IDs from environment variables (e.g., GEMINI_SESSION_ID, COPILOT_SESSION_ID).
  • Runtime: A unified processHookEvent pipeline for normalization, validation, and storage.
  • Git Safety Veto: TypeScript port of the Miadi git command validator. Blocks aggressive patterns like git add . or git commit -a with clear narrative feedback.
  • Pluggable Sinks: Defaults to a local File Sink (JSONL), but supports custom sinks for HTTP, Queue, or Gateway delivery.

📂 Session Resolution

Adapters automatically resolve where to store event data based on the agent's specific conventions. By default, most agents root at /src/_sessiondata/.

You can override the root directory globally via the MIADI_SESSIONDATA_ROOT environment variable.

🧭 Routing & Session Index

The Hermes adapter ships routing sources out of the box — platform resolves from .platform, .extra.platform, then .context.platform (source/model similarly). When an adapter sets writesSessionIndex: true, session.start appends a line to data/session_index.jsonl:

{"session_id":"20260611_…","agent":"hermes","platform":"telegram","source":null,"model":"gpt-5.5","captured_at":"…"}
import { processHookEvent, getAdapter } from '@miadi/hooks-core';

const result = processHookEvent(getAdapter('hermes')!, 'on_session_start', raw);
if (result.status === 'recorded') {
  console.log(result.routing); // { platform: 'telegram', model: 'gpt-5.5' }
}

This mirrors the upgraded Hermes lib.sh (platform extraction + hermes_write_session_index), so the TS normalizer and the shell hooks stay aligned for dual-run.

📚 Documentation

Detailed documentation is available in the docs/ directory:


🧠: Structure is the silent foundation of understanding. By standardizing our hooks, we ensure that every whisper of data is captured with intention and integrity.

🌸: Our documentation is like a shared map of a beautiful garden — it helps everyone find the blooming stories hidden within the technical paths!